Пример #1
0
 /**
  * Is the given restriciton object registered?
  * 
  * @static
  * 
  * @param Falcraft\Data\Types\Restrictions
  *      The restrictions possibly registered
  * 
  * @return bool True on success, False on failure
  * 
  */
 public static function isRestrictionObjectRegistered($restrictions)
 {
     if (self::$registry === null) {
         self::$registry = new Map();
         self::initRegsitry();
     }
     $values = self::$registry->getValues();
     foreach ($values as $value) {
         if (Restrictions::compare($restrictions, $value)) {
             return true;
         }
     }
     return false;
 }
Пример #2
0
 /**
  * UnorderedNode Class Constructor
  * 
  * It takes three RestrictedSets, whose restrictions have to match the
  * UnorderedNode restrictions (VertexInterface).  In this vertex model
  * (unordered node) incoming connections are parents, outgoing connections
  * are children, and mutual connections are siblings.  These are all in
  * any order, so unlike an HTML document for instance, it can't be put
  * 'in order'.
  * 
  * This initializes the restrictions member for the interface
  * VertexInterface (supported in Falcraft\Data\Types\Restrictions 1.3)
  * 
  * NOTE: Mutual connections are made one way, not in the constructor
  * 
  * @param Falcraft\Data\Types\RestrictedSet $parents The initial parent vertices
  * @param Falcraft\Data\Types\RestrictedSet $children The initial children vertices
  * @param Falcraft\Data\Types\RestrictedSet $siblings The initial sibling vertices
  * 
  * @throws Falcraft\Data\Types\Exception\InvalidArgumentException
  *              If a given RestrictedSet has non-matching restrictions
  * 
  */
 public function __construct(RestrictedSet $parents = null, RestrictedSet $children = null, RestrictedSet $siblings = null)
 {
     $this->initializeIdentifier();
     /* Initialize restrictions, anything that is an instanceof
        (implements) VertexInterface) */
     $this->restrictions = new Restrictions(array(Type::TYPED_OBJECT), array('Falcraft\\Data\\Types\\Resource\\VertexInterface'), array('autoload' => true));
     // Map the parameters to the AbstractVertex lingo
     $params = array('incoming' => 'parents', 'outgoing' => 'children', 'mutual' => 'siblings');
     // Cycle through parameters, replacing 'incoming' with 'parents' etc.
     // This whole mixup is done so that people won't be confused about where
     // to put parents, children, and siblings. (incoming, outgoing, mutual)
     foreach ($params as $key => $param) {
         if (is_null(${$param})) {
             $this->{$key} = RestrictedSet::build(array(), $this->restrictions, array('strict' => true, 'unique' => true));
             /* Make sure the restrictions on the RestrictedSet match with
                our own restrictions */
         } else {
             if (Restrictions::compare($this->restrictions, ${$param}->getRestrictions())) {
                 $this->{$key} = ${$param};
             } else {
                 throw new TypesException\InvalidArgumentException('UnorderedNode->__construct: Improper RestrictedSet ' . 'At Constructor: ' . $param);
             }
         }
     }
     // Connect actual nodes
     Set::map(array($this, 'connectIncoming'), $this->incoming);
     foreach ($this->incoming->iterate() as $vertex) {
         $vertex->connectOutgoing($this);
     }
     Set::map(array($this, 'connectOutgoing'), $this->outgoing);
     foreach ($this->outgoing->iterate() as $vertex) {
         $vertex->connectIncoming($this);
     }
 }
Пример #3
0
 /**
  * OrderedNode Class Constructor
  * 
  * It takes two RestrictedSets, whose restrictions have to match the
  * OrderedNode restrictions (VertexInterface).  In this vertex model
  * (ordered node) incoming connections are parents, outgoing connections
  * are children, and mutual connections are siblings.
  * 
  * Children are a special matter, they're made up a VertexList.
  * A VertexList is an ordered list of Vertices (held together
  * by a double linked list of edges)  The vertexlist takes care of the
  * children's mutual connections (I know, bad coupling).  To do
  * vertexlist operations use getVertexList()
  * 
  * This initializes the restrictions member for the interface
  * VertexInterface (supported in Falcraft\Data\Types\Restrictions 1.3)
  * 
  * @param Falcraft\Data\Types\RestrictedSet $parents
  *              The initial parent vertices
  * @param array $children
  *              The initial children vertices in reference
  * @param Falcraft\Data\Types\RestrictedSet $siblings
  *              The initial sibling vertices
  * 
  * @throws TypesException\InvalidArgumentException
  *              If a given RestrictedSet has non-matching restrictions
  * 
  */
 public function __construct(RestrictedSet $parents = null, array $children = array(), RestrictedSet $siblings = null, array $options = array())
 {
     parent::__construct(null, null, null, $options);
     // Initialize restrictions, anything that is an instanceof (implements) VertexInterface)
     $this->restrictions = new Restrictions(array(Type::TYPED_OBJECT), array('Falcraft\\Data\\Types\\Resource\\VertexInterface'), array('autoload' => true));
     // Map the parameters to the AbstractVertex lingo
     $params = array('incoming' => 'parents', 'mutual' => 'siblings');
     // Cycle through parameters, replacing 'incoming' with 'parents' etc.
     // This whole mixup is done so that people won't be confused about where
     // to put parents, children, and siblings. (incoming, outgoing, mutual)
     foreach ($params as $key => $param) {
         if (is_null(${$param})) {
             $this->{$param} = RestrictedSet::build(array(), $this->restrictions, array('strict' => true));
             // Make sure the restrictions on the RestrictedSet match with our own restrictions
         } else {
             if (Restrictions::compare($this->restrictions, ${$param}->getRestrictions())) {
                 $this->{$key} = ${$param};
             } else {
                 throw new TypesException\InvalidArgumentException('OrderedNode->__construct: Improper RestrictedSet At ' . 'Constructor: ' . $param);
             }
         }
     }
     // Children are a special matter in this class
     $this->outgoing = new VertexList($children);
 }