code: function factory( name, parentName, decorator, cfg ){
  
          var instance
              ,result
              ,parent = proto
              ,tmp
              ;
  
          // set parent if specified
          if ( typeof parentName !== 'string' ){
  
              // ... otherwise reassign parameters
              cfg = decorator;
              decorator = parentName;
  
          } else {
  
              // extend the specified module
              parent = registry[ parentName ];
  
              if ( !parent ){
  
                  throw 'Error: "' + parentName + '" ' + type + ' not defined';
              }
  
              parent = parent.prototype;
          }
  
          if ( typeof decorator === 'function' ){
  
              result = registry[ name ];
  
              if ( result ){
  
                  result.prototype = extend(result.prototype, decorator( getProto(result.prototype) ));
  
              } else {
                  // newly defined
                  // store the new class
                  result = registry[ name ] = function constructor( opts ){
                      if (this.init){
                          this.init( opts );
                      }
                  };
  
                  result.prototype = objectCreate( parent );
                  result.prototype = extend(result.prototype, decorator( parent, result.prototype ));
              }
  
              result.prototype.type = type;
              result.prototype.name = name;
  
          } else {
  
              cfg = decorator || {};
              result = registry[ name ];
              if (!result){
  
                  throw 'Error: "' + name + '" ' + type + ' not defined';
              }
          }
  
          if ( cfg ) {
  
              // create a new instance from the provided decorator
              return new result( cfg );
          }
      }
docs: belongs to: Physics.util.decorator
  factory( name[, parentName], decorator[, cfg] )
  factory( name, cfg ) -> Object
  -  name       (String):  The class name
  -  parentName (String): The name of parent class to extend
  -  decorator  (Function): The decorator function that should define and return methods to extend (decorate) the base class
  -  cfg        (Object): The configuration to pass to the class initializer
  
  Factory function for definition and instantiation of subclasses.
  
  Use the first signature (once) to define it first.
  If defining without the "cfg" parameter, void will be returned. Otherwise the class instance will be returned.
  
  See [[Physics.util.decorator]] for more information.