Exemplo n.º 1
0
		T* add(T* component) {
			if (componentOperationHandler != nullptr && componentOperationHandler->isActive())
				componentOperationHandler->add(this, component);
			else
				addInternal(component);
			return component;
		}
Exemplo n.º 2
0
 void FieldInfos::read(IndexInputPtr input, const String& fileName)
 {
     int32_t firstInt = input->readVInt();
     format = firstInt < 0 ? firstInt : FORMAT_PRE; // This is a real format?
     
     if (format != FORMAT_PRE && format != FORMAT_START)
         boost::throw_exception(CorruptIndexException(L"unrecognized format " + StringUtils::toString(format) + L" in file \"" + fileName + L"\""));
     
     int32_t size = format == FORMAT_PRE ? firstInt : input->readVInt(); // read in the size if required
     for (int32_t i = 0; i < size; ++i)
     {
         String name(input->readString());
         uint8_t bits = input->readByte();
         
         addInternal(name, (bits & IS_INDEXED) != 0, (bits & STORE_TERMVECTOR) != 0, (bits & STORE_POSITIONS_WITH_TERMVECTOR) != 0,
                     (bits & STORE_OFFSET_WITH_TERMVECTOR) != 0, (bits & OMIT_NORMS) != 0, (bits & STORE_PAYLOADS) != 0,
                     (bits & OMIT_TERM_FREQ_AND_POSITIONS) != 0);
     }
     
     if (input->getFilePointer() != input->length())
     {
         boost::throw_exception(CorruptIndexException(L"did not read all bytes from file \"" + fileName + L"\": read " + 
                                                      StringUtils::toString(input->getFilePointer()) + L" vs size " + 
                                                      StringUtils::toString(input->length())));
     }
 }
Exemplo n.º 3
0
void KdTree::addInternal(KdNode* node,int cd,VecItem* item){
	if( item->getPosition()[cd] < node->item->getPosition()[cd] ){
		if( node->left == 0){
			node->left = new KdNode(item,node->left);
			m_size++;
		}else{
			addInternal(node->left,(cd+1)%m_k,item);
		}
	}else{
		if( node->right == 0){
			node->right = new KdNode(item,node->right);
			m_size++;
		}else{
			addInternal(node->right,(cd+1)%m_k,item);
		}
	}
}
Exemplo n.º 4
0
void KdTree::addItem(VecItem* item){
	if( m_root == 0){
		m_root = new KdNode(item,m_root);
		m_size++;
	}else{
		addInternal(m_root,0,item);
	}
}
Exemplo n.º 5
0
 FieldInfoPtr FieldInfos::add(const String& name, bool isIndexed, bool storeTermVector, bool storePositionWithTermVector, 
                              bool storeOffsetWithTermVector, bool omitNorms, bool storePayloads, bool omitTermFreqAndPositions)
 {
     SyncLock syncLock(this);
     FieldInfoPtr fi(fieldInfo(name));
     if (!fi)
         return addInternal(name, isIndexed, storeTermVector, storePositionWithTermVector, storeOffsetWithTermVector, omitNorms, storePayloads, omitTermFreqAndPositions);
     else
         fi->update(isIndexed, storeTermVector, storePositionWithTermVector, storeOffsetWithTermVector, omitNorms, storePayloads, omitTermFreqAndPositions);
     return fi;
 }
Exemplo n.º 6
0
bool DOMSettableTokenList::toggle(const AtomicString& token, ExceptionCode& ec)
{
    if (!validateToken(token, ec))
        return false;
    if (m_tokens.contains(token)) {
        removeInternal(token);
        return false;
    }
    addInternal(token);
    return true;
}
Exemplo n.º 7
0
bool DOMTokenList::toggle(const AtomicString& token, ExceptionState& exceptionState)
{
    if (!validateToken(token, exceptionState))
        return false;

    if (containsInternal(token)) {
        removeInternal(token);
        return false;
    }
    addInternal(token);
    return true;
}
Exemplo n.º 8
0
bool DOMTokenList::toggle(const AtomicString& token, bool force, ExceptionState& exceptionState)
{
    if (!validateToken(token, exceptionState))
        return false;

    if (force)
        addInternal(token);
    else
        removeInternal(token);

    return force;
}
Exemplo n.º 9
0
	/**
	 * <p>Adds a component via a unqiue ptr to an existing component via moving.</p>
	 *
	 * <p>In short, if you create a component stored in a std::unique_ptr, you want to call: <br>
	 * <tt>entity->add(std::move(component));</tt><br>
	 * and remember not to use the component after moving it; use getComponent.
	 * </p>
	 * @param component the component to add.
	 * @return this {@link Entity} for chaining.
	 */
	template<typename C> Entity &add(std::unique_ptr<C> &&component) {
		internal::verify_component_type<C>();

		auto typeIndex = std::type_index(typeid(C));

		if (operationHandler != nullptr) {
			operationHandler->add(this, std::move(component), typeIndex);
		} else {
			addInternal(std::move(component), typeIndex);
		}

		return *this;
	}
Exemplo n.º 10
0
void Operation::add() {
	backup();
	runInternal();
	if ( addInternal() ) {
		list.push(this);
		createParamUi();
		button=new RadioButton(names[type],tips[type],historyCbk,this);
		button->setGroup(0);
		history->addWidget(button);
		button->select();
		currentOp=this;
	} else delete this;
}
Exemplo n.º 11
0
	/**
	 * <p>Constructs a new object of type C (subclassing ashley::Component) using <em>args...</em> for construction.</p>
	 *
	 * <p>If a {@link Component} of the same type already exists, it'll be replaced and destroyed without being retrievable
	 * from this class again.</p>
	 * @return This {@link Entity} for easy chaining
	 */
	template<typename C, typename ...Args> Entity &add(Args&&... args) {
		internal::verify_component_type<C>();

		const auto typeIndex = std::type_index(typeid(C));
		auto component = std::unique_ptr<Component>(new C(args...));

		if (operationHandler != nullptr) {
			operationHandler->add(this, std::move(component), typeIndex);
		} else {
			addInternal(std::move(component), typeIndex);
		}

		return *this;

//		return add<C>(std::unique_ptr<C>(new C(args...)));
	}
Exemplo n.º 12
0
    /**
     *   
     * @brief creates transitions for 'dup' mirroring 'orig' outgoing transitions
     *
     * @param - orig: the state that is being duplicated
     * @param - dup: the state that is duplicating 'orig'
     *  
     */
    void TransitionStorage::dupTransOutgoing( State orig, State dup )
    { 
      // Duplicate outgoing internal transitions.
      const Info::Internals & from = T_info.fromTrans(orig);
      for( Info::InternalIterator it = from.begin(); it != from.end(); it++ )
      {
        Internal iTrans(dup,getInternalSym(*it),getTarget(*it));
        addInternal(iTrans);
      }

      // Duplicate call site call transitions.
      const Info::Calls & call = T_info.callTrans(orig);
      for( Info::CallIterator it = call.begin(); it != call.end(); it++ )
      {
        Call cTrans(dup,getCallSym(*it),getEntry(*it));
        addCall(cTrans);

      }

      // Duplicate exit point return transitions.
      const Info::Returns & exit = T_info.exitTrans(orig);
      for( Info::ReturnIterator it = exit.begin(); it != exit.end(); it++ )
      {
        Return rTrans(dup,getCallSite(*it),getReturnSym(*it),getReturnSite(*it));
        addReturn(rTrans);
      }

      // Q: Do we want to do these? Seems inconsistent. -Evan
      // A: Aditya says 'yes', and thinks we need it. So we definitely don't
      //    want to change it without looking at uses and compensating.
      // Duplicate call predecessor return transitions.
      const Info::Returns & pred = T_info.predTrans(orig);
      for( Info::ReturnIterator it = pred.begin(); it != pred.end(); it++ )
      {
        Return rTrans(getExit(*it),dup,getReturnSym(*it),getReturnSite(*it));
        addReturn(rTrans);
      }
    }
Exemplo n.º 13
0
    /**
     *
     * @brief add all transitions in the given collection of transitions to this
     *        collection of transitions
     *
     * @param - addTransitionStorage: the collection of transitions to add to this 
     *          collection of transitions
     *
     */
    void TransitionStorage::addAllTrans( TransitionStorage addTransSet )
    {   
      //Add call transitions.
      for(CallIterator it = addTransSet.beginCall(); 
          it != addTransSet.endCall(); it ++ )
      {
        addCall(*it);
      }

      //Add internal transitions.
      for(InternalIterator it = addTransSet.beginInternal(); 
          it != addTransSet.endInternal(); it ++ )
      {
        addInternal(*it);
      }

      //Add return transitions.
      for(ReturnIterator it = addTransSet.beginReturn(); 
          it != addTransSet.endReturn(); it ++ )
      {
        addReturn(*it);
      }
    }
Exemplo n.º 14
0
void EntityEngine::processPendingComponentOperations()
{
    for (auto componentOperation : componentOperations)
    {
        auto entity = componentOperation->entity;
        auto component = componentOperation->component;
        auto componentId = componentOperation->componentId;

        switch (componentOperation->type)
        {
            case ComponentOperation::ADD:
                entity->addInternal(component, componentId);
                break;

            case ComponentOperation::REMOVE:
                entity->removeInternal(componentId);
                break;
        }

        updateFamilyMembership(entity);
    }

    componentOperations.clear();
}
Exemplo n.º 15
0
 /**
  *
  * @brief add an internal transition to the NWA
  *
  * @param - from: the state the edge departs from
  * @param - sym: the symbol labeling the edge
  * @param - to: the state the edge arrives to  
  * @return false if the internal transition already exists in the NWA
  *
  */
 bool TransitionStorage::addInternal( State from, Symbol sym, State to )
 {
   Internal it(from,sym,to);
   return addInternal(it);
 }
Exemplo n.º 16
0
    /**
     *  
     * @brief creates transitions for 'dup' mirroring 'orig' transitions
     *
     * @param - orig: the state that is being duplicated
     * @param - dup: the state that is duplicating 'orig'
     *  
     */
    void TransitionStorage::dupTrans( State orig, State dup )
    { 
      //Duplicate outgoing internal transitions.
      const Info::Internals & from = T_info.fromTrans(orig);
      for( Info::InternalIterator it = from.begin(); it != from.end(); it++ )
      {
        Internal iTrans(dup,getInternalSym(*it),getTarget(*it));
        addInternal(iTrans);

        // Q: This is also inconsistent with dupTransOutgoing, which didn't do
        //    anything special with self loops. -Evan
        // A: Aditya says yes, but this is again what McVeto(?) needs.
        //    dupTrans is used in 'duplicateState', but dupTransOutgoing is
        //    different.
        if( orig == getTarget(*it) )   //Handle self-loops.
        {
          Internal loop(dup,getInternalSym(*it),dup);
          addInternal(loop);
        }
      }

      //Duplicate incoming internal transitions.
      const Info::Internals & to = T_info.toTrans(orig);
      for( Info::InternalIterator it = to.begin(); it != to.end(); it++ )
      {
        Internal iTrans(getSource(*it),getInternalSym(*it),dup);
        addInternal(iTrans);
      }

      //Duplicate call site call transitions.
      const Info::Calls & call = T_info.callTrans(orig);
      for( Info::CallIterator it = call.begin(); it != call.end(); it++ )
      {
        Call cTrans(dup,getCallSym(*it),getEntry(*it));
        addCall(cTrans);
        if( orig == getEntry(*it) )   //Handle self-loops.
        {
          Call loop(dup,getCallSym(*it),dup);
          addCall(loop);
        }
      }

      //Duplicate entry point call transitions.
      const Info::Calls & entry = T_info.entryTrans(orig);
      for( Info::CallIterator it = entry.begin(); it != entry.end(); it++ )
      {
        Call cTrans(getCallSite(*it),getCallSym(*it),dup);
        addCall(cTrans);
      }

      //Duplicate exit point return transitions.
      const Info::Returns & exit = T_info.exitTrans(orig);
      for( Info::ReturnIterator it = exit.begin(); it != exit.end(); it++ )
      {
        Return rTrans(dup,getCallSite(*it),getReturnSym(*it),getReturnSite(*it));
        addReturn(rTrans);
        if( orig == getCallSite(*it) )   //Handle self-loops.
        {
          Return loop(dup,dup,getReturnSym(*it),getReturnSite(*it));
          addReturn(loop);
        }
        if( orig == getReturnSite(*it) )   //Handle self-loops.
        {
          Return loop(dup,getCallSite(*it),getReturnSym(*it),dup);
          addReturn(loop);
        }
        if( orig == getCallSite(*it) && orig == getReturnSite(*it) )   //Handle self-loops.
        {
          Return loop(dup,dup,getReturnSym(*it),dup);
          addReturn(loop);
        }
      }

      //Duplicate call predecessor return transitions.
      const Info::Returns & pred = T_info.predTrans(orig);
      for( Info::ReturnIterator it = pred.begin(); it != pred.end(); it++ )
      {
        Return rTrans(getExit(*it),dup,getReturnSym(*it),getReturnSite(*it));
        addReturn(rTrans);
        if( orig == getReturnSite(*it) )   //Handle self-loops.
        {
          Return loop(getExit(*it),dup,getReturnSym(*it),dup);
          addReturn(loop);
        }
      }

      //Duplicate return site return transitions.
      const Info::Returns & ret = T_info.retTrans(orig);
      for( Info::ReturnIterator it = ret.begin(); it != ret.end(); it++ )
      {
        Return rTrans(getExit(*it),getCallSite(*it),getReturnSym(*it),dup);
        addReturn(rTrans);
      }
    }
Exemplo n.º 17
0
void DOMTokenList::add(const Vector<String>& tokens, ExceptionCode& ec)
{
    addInternal(tokens.data(), tokens.size(), ec);
}
Exemplo n.º 18
0
void DOMTokenList::add(const WTF::AtomicString& token, ExceptionCode& ec)
{
    addInternal(&token.string(), 1, ec);
}
Exemplo n.º 19
0
void DOMSettableTokenList::add(const AtomicString& token, ExceptionCode& ec)
{
    if (!validateToken(token, ec) || m_tokens.contains(token))
        return;
    addInternal(token);
}