]> git.mxchange.org Git - core.git/commitdiff
Generic method hashCode() added. Please overwrite it, if you need better hashes.
authorRoland Häder <roland@mxchange.org>
Tue, 4 Aug 2009 23:23:54 +0000 (23:23 +0000)
committerRoland Häder <roland@mxchange.org>
Tue, 4 Aug 2009 23:23:54 +0000 (23:23 +0000)
inc/classes/interfaces/class_FrameworkInterface.php
inc/classes/main/class_BaseFrameworkSystem.php
inc/config/class_FrameworkConfiguration.php

index 5848674c54c2ead573fd75057a7975b4185b4df3..2859d7a3489bea85bfe4607e2dadb5d7d7ce8bbe 100644 (file)
@@ -31,6 +31,13 @@ interface FrameworkInterface {
         * @throws      NullPointerException    If the result instance is null
         */
        function getField ($fieldName);
+
+       /**
+        * Generates a code for hashes from this class
+        *
+        * @return      $hashCode       The hash code respresenting this class
+        */
+       function hashCode ();
 }
 
 //
index 8976961e03920bac0183f0a8f4243311655a1ecf..5f961a1c925828af16e3447953362e3a00141f66 100644 (file)
@@ -1115,6 +1115,17 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                        $this->partialStub('Developer mode inactive. Message:' . $message);
                }
        }
+
+       /**
+        * Generates a generic hash code of this class. You should really overwrite
+        * this method with your own hash code generator code. But keep KISS in mind.
+        *
+        * @return      $hashCode       A generic hash code respresenting this whole class
+        */
+       public function hashCode () {
+               // Simple hash code
+               return crc32($this->__toString());
+       }
 }
 
 // [EOF]
index 7692132a1941dc9647206660909182360d510454..0494722ee770334cd03df4917af483e4718cedcb 100644 (file)
@@ -302,7 +302,16 @@ class FrameworkConfiguration implements Registerable {
        public final function getField ($fieldName) {
                // Our super interface "FrameworkInterface" requires this
        }
+
+       /**
+        * Generates a code for hashes from this class
+        *
+        * @return      $hashCode       The hash code respresenting this class
+        */
+       public function hashCode () {
+               return crc32($this->__toString());
+       }
 }
 
-// [EOF]
+//
 ?>