Renamed Registry -> GenericRegistry to make it clear that this registry does
[core.git] / framework / main / classes / lists / class_BaseList.php
index df6e7c08fe5d50a138b2bcbdb4058aa13e26eebb..bb58363627f216a7fff2c56cc2c68282b760f1d7 100644 (file)
@@ -1,12 +1,12 @@
 <?php
 // Own namespace
-namespace CoreFramework\Lists;
+namespace Org\Mxchange\CoreFramework\Lists;
 
 // Import framework stuff
-use CoreFramework\Factory\ObjectFactory;
-use CoreFramework\Generic\FrameworkInterface;
-use CoreFramework\Object\BaseFrameworkSystem;
-use CoreFramework\Visitor\Visitable;
+use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
+use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
+use Org\Mxchange\CoreFramework\Visitor\Visitable;
 
 // Import SPL stuff
 use \IteratorAggregate;
@@ -34,7 +34,7 @@ use \Countable;
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
-class BaseList extends BaseFrameworkSystem implements IteratorAggregate, Countable {
+abstract class BaseList extends BaseFrameworkSystem implements IteratorAggregate, Countable {
        // Exception constants
        const EXCEPTION_GROUP_ALREADY_ADDED = 0xf20;
        const EXCEPTION_GROUP_NOT_FOUND     = 0xf21;
@@ -148,11 +148,7 @@ class BaseList extends BaseFrameworkSystem implements IteratorAggregate, Countab
                $hash = $this->generateHash($groupName, $subGroup, $visitableInstance);
 
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: this=' . $this->__toString() . ',groupName=' . $groupName  . ',subGroup=' . $subGroup . ',hash=' . $hash . ' - Calling addEntry() ...');
-
-               // Now add it to the group list and hash it
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: this=' . $this->__toString() . ',this->listGroups[' . $groupName . ']=' . $this->listGroups[$groupName]->__toString());
-               //$this->listGroups[$groupName]->addEntry($subGroup, $hash);
 
                // Add the hash to the index
                array_push($this->listIndex, $hash);
@@ -308,9 +304,12 @@ class BaseList extends BaseFrameworkSystem implements IteratorAggregate, Countab
                } elseif ((is_array($entry)) && (isset($entry['id']))) {
                        // Supported array found
                        $entry2 = crc32($entry['id']) . ':' . count($entry);
+               } elseif (($this->getCallbackInstance() instanceof FrameworkInterface) && (method_exists($this->getCallbackInstance(), 'generateListHashFromEntry'))) {
+                       // Call it instead
+                       $entry2 = $this->getCallbackInstance()->generateListHashFromEntry($entry);
                } else {
                        // Unsupported type detected
-                       self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST[' . __METHOD__ . ':' . __LINE__ . ']: Entry type ' . gettype($entry) . ' is unsupported.');
+                       self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST[' . __METHOD__ . ':' . __LINE__ . ']: Entry type ' . gettype($entry) . ' is unsupported (this->callbackInstance=' . $this->getCallbackInstance() . ').');
 
                        // At least take all keys from array
                        $entry2 = gettype($entry) . ':' . implode(':', array_keys($entry));