]> git.mxchange.org Git - core.git/blobdiff - framework/main/classes/class_BaseFrameworkSystem.php
imported InputStream
[core.git] / framework / main / classes / class_BaseFrameworkSystem.php
index ab2e5540a5d5bb7fc0136fe42afdc04225127bdc..f03df720824ff5112ccb5755149836f2f2f488ac 100644 (file)
@@ -19,11 +19,13 @@ use CoreFramework\Factory\ObjectFactory;
 use CoreFramework\Filesystem\Block;
 use CoreFramework\Filesystem\FilePointer;
 use CoreFramework\Filesystem\FrameworkDirectory;
+use CoreFramework\Filesystem\PathWriteProtectedException;
 use CoreFramework\Generic\FrameworkInterface;
 use CoreFramework\Generic\NullPointerException;
+use CoreFramework\Generic\UnsupportedOperationException;
+use CoreFramework\Handler\Handleable;
 use CoreFramework\Handler\Stream\IoHandler;
 use CoreFramework\Index\Indexable;
-use CoreFramework\Listener\Listenable;
 use CoreFramework\Lists\Listable;
 use CoreFramework\Loader\ClassLoader;
 use CoreFramework\Manager\ManageableApplication;
@@ -36,6 +38,8 @@ use CoreFramework\Resolver\Resolver;
 use CoreFramework\Result\Database\CachedDatabaseResult;
 use CoreFramework\Result\Search\SearchableResult;
 use CoreFramework\Stacker\Stackable;
+use CoreFramework\State\Stateable;
+use CoreFramework\Stream\Input\InputStream;
 use CoreFramework\Stream\Output\OutputStreamer;
 use CoreFramework\Template\CompileableTemplate;
 use CoreFramework\User\ManageableAccount;
@@ -165,11 +169,6 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         */
        private $parserInstance = NULL;
 
-       /**
-        * A HandleableProtocol instance
-        */
-       private $protocolInstance = NULL;
-
        /**
         * A database wrapper instance
         */
@@ -201,7 +200,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
        private $outputStreamInstance = NULL;
 
        /**
-        * Networkable handler instance
+        * Handler instance
         */
        private $handlerInstance = NULL;
 
@@ -210,11 +209,6 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         */
        private $visitorInstance = NULL;
 
-       /**
-        * DHT instance
-        */
-       private $dhtInstance = NULL;
-
        /**
         * An instance of a database wrapper class
         */
@@ -245,11 +239,6 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         */
        private $directoryInstance = NULL;
 
-       /**
-        * Listener instance
-        */
-       private $listenerInstance = NULL;
-
        /**
         * An instance of a communicator
         */
@@ -305,11 +294,6 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         */
        private $controllerName = '';
 
-       /**
-        * Name of used protocol
-        */
-       private $protocolName = 'invalid';
-
        /**
         * Array with bitmasks and such for pack/unpack methods to support both
         * 32-bit and 64-bit systems
@@ -404,6 +388,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
        const EXCEPTION_PATH_CANNOT_BE_WRITTEN       = 0x03b;
        const EXCEPTION_DATABASE_UPDATED_NOT_ALLOWED = 0x03c;
        const EXCEPTION_FILTER_CHAIN_INTERCEPTED     = 0x03d;
+       const EXCEPTION_INVALID_SOCKET               = 0x03e;
 
        /**
         * Hexadecimal->Decimal translation array
@@ -495,8 +480,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                        $this->setRealClass('DestructedObject');
                } elseif ((defined('DEBUG_DESTRUCTOR')) && (is_object($this->getDebugInstance()))) {
                        // Already destructed object
-                       self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:] The object <span class="object_name">%s</span> is already destroyed.',
-                               __CLASS__,
+                       self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('The object <span class="object_name">%s</span> is already destroyed.',
                                $this->__toString()
                        ));
                } else {
@@ -588,7 +572,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
 
                // Output stub message
                // @TODO __CLASS__ does always return BaseFrameworkSystem but not the extending (=child) class
-               self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[unknown::%s:] Stub! Args: %s',
+               self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[unknown::%s]: Stub! Args: %s',
                        $methodName,
                        $argsString
                ));
@@ -1139,25 +1123,6 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                return $this->parserInstance;
        }
 
-       /**
-        * Setter for HandleableProtocol instance
-        *
-        * @param       $protocolInstance       An instance of an HandleableProtocol
-        * @return      void
-        */
-       public final function setProtocolInstance (HandleableProtocol $protocolInstance) {
-               $this->protocolInstance = $protocolInstance;
-       }
-
-       /**
-        * Getter for HandleableProtocol instance
-        *
-        * @return      $protocolInstance       An instance of an HandleableProtocol
-        */
-       public final function getProtocolInstance () {
-               return $this->protocolInstance;
-       }
-
        /**
         * Setter for DatabaseWrapper instance
         *
@@ -1327,7 +1292,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
        /**
         * Getter for handler instance
         *
-        * @return      $handlerInstance        A Networkable instance
+        * @return      $handlerInstance        A Handleable instance
         */
        protected final function getHandlerInstance () {
                return $this->handlerInstance;
@@ -1352,25 +1317,6 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                return $this->visitorInstance;
        }
 
-       /**
-        * Setter for DHT instance
-        *
-        * @param       $dhtInstance    A Distributable instance
-        * @return      void
-        */
-       protected final function setDhtInstance (Distributable $dhtInstance) {
-               $this->dhtInstance = $dhtInstance;
-       }
-
-       /**
-        * Getter for DHT instance
-        *
-        * @return      $dhtInstance    A Distributable instance
-        */
-       protected final function getDhtInstance () {
-               return $this->dhtInstance;
-       }
-
        /**
         * Setter for raw package Data
         *
@@ -1521,25 +1467,6 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                return $this->directoryInstance;
        }
 
-       /**
-        * Setter for listener instance
-        *
-        * @param       $listenerInstance       A Listenable instance
-        * @return      void
-        */
-       protected final function setListenerInstance (Listenable $listenerInstance) {
-               $this->listenerInstance = $listenerInstance;
-       }
-
-       /**
-        * Getter for listener instance
-        *
-        * @return      $listenerInstance       A Listenable instance
-        */
-       protected final function getListenerInstance () {
-               return $this->listenerInstance;
-       }
-
        /**
         * Getter for communicator instance
         *
@@ -1635,25 +1562,6 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                return $this->controllerName;
        }
 
-       /**
-        * Getter for protocol name
-        *
-        * @return      $protocolName   Name of used protocol
-        */
-       public final function getProtocolName () {
-               return $this->protocolName;
-       }
-
-       /**
-        * Setter for protocol name
-        *
-        * @param       $protocolName   Name of used protocol
-        * @return      void
-        */
-       protected final function setProtocolName ($protocolName) {
-               $this->protocolName = $protocolName;
-       }
-
        /**
         * Checks whether an object equals this object. You should overwrite this
         * method to implement own equality checks
@@ -1831,7 +1739,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                } // END - if
 
                // Construct the full message
-               $stubMessage = sprintf('[%s:] Partial stub!',
+               $stubMessage = sprintf('[%s]: Partial stub!',
                        $methodName
                );
 
@@ -2600,20 +2508,6 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                return $ret;
        }
 
-       /**
-        * Checks whether start/end marker are set
-        *
-        * @param       $data   Data to be checked
-        * @return      $isset  Whether start/end marker are set
-        */
-       public final function ifStartEndMarkersSet ($data) {
-               // Determine it
-               $isset = ((substr($data, 0, strlen(BaseRawDataHandler::STREAM_START_MARKER)) == BaseRawDataHandler::STREAM_START_MARKER) && (substr($data, -1 * strlen(BaseRawDataHandler::STREAM_END_MARKER), strlen(BaseRawDataHandler::STREAM_END_MARKER)) == BaseRawDataHandler::STREAM_END_MARKER));
-
-               // ... and return it
-               return $isset;
-       }
-
        /**
         * Determines if an element is set in the generic array
         *
@@ -3326,7 +3220,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                } // END - if
 
                // Add it
-               $fqfn = $basePath . '/' . $fileName;
+               $fqfn = $basePath . DIRECTORY_SEPARATOR . $fileName;
 
                // Is it reachable?
                if (!FrameworkBootstrap::isReachableFilePath($fqfn)) {
@@ -3360,50 +3254,4 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                return $stateName;
        }
 
-       /**
-        * Handles socket error for given socket resource and peer data. This method
-        * validates $socketResource if it is a valid resource (see is_resource())
-        * but assumes valid data in array $recipientData, except that
-        * count($recipientData) is always 2.
-        *
-        * @param       $method                         Value of __METHOD__ from calling method
-        * @param       $line                           Value of __LINE__ from calling method
-        * @param       $socketResource         A valid socket resource
-        * @param       $socketData                     A valid socket data array (0 = IP/file name, 1 = port)
-        * @return      void
-        * @throws      InvalidSocketException  If $socketResource is no socket resource
-        * @throws      NoSocketErrorDetectedException  If socket_last_error() gives zero back
-        * @todo        Move all this socket-related stuff into own class, most of it resides in BaseListener
-        */
-       protected final function handleSocketError ($method, $line, $socketResource, array $socketData) {
-               // This method handles only socket resources
-               if (!is_resource($socketResource)) {
-                       // No resource, abort here
-                       throw new InvalidSocketException(array($this, $socketResource), BaseListener::EXCEPTION_INVALID_SOCKET);
-               } // END - if
-
-               // Check socket array, 1st element is mostly IP address (or file name), 2nd is port number
-               //* DEBUG-DIE: */ die(__METHOD__ . ':socketData=' . print_r($socketData, true));
-               assert(isset($socketData[0]));
-               assert(isset($socketData[1]));
-
-               // Get error code for first validation (0 is not an error)
-               $errorCode = socket_last_error($socketResource);
-
-               // If the error code is zero, someone called this method without an error
-               if ($errorCode == 0) {
-                       // No error detected (or previously cleared outside this method)
-                       throw new NoSocketErrorDetectedException(array($this, $socketResource), BaseListener::EXCEPTION_NO_SOCKET_ERROR);
-               } // END - if
-
-               // Get handler (method) name
-               $handlerName = $this->getSocketErrorHandlerFromCode($errorCode);
-
-               // Call-back the error handler method
-               call_user_func_array(array($this, $handlerName), array($socketResource, $socketData));
-
-               // Finally clear the error because it has been handled
-               socket_clear_error($socketResource);
-       }
-
 }