//: Call
	void call(PARAM1 param1)
	{
		Signal_v1_Generic *data = impl;
		data->in_call = true;

		std::list<SlotIterator> remove_slots;
		try
		{
			data->in_call_remove_slots = &remove_slots;
			
			// call slots connected to signal:
			for (SlotIterator slot_it = data->slots.begin(); slot_it != data->slots.end(); slot_it++)
			{
				Slot slot = *slot_it;

				// skip slot if it has no more references left in application.
				// (make it pending for removal)
				if (slot->get_slot_ref() == 0 && slot->is_persistent() == false)
				{
					if (std::find(remove_slots.begin(), remove_slots.end(), slot_it)==remove_slots.end())
						remove_slots.push_back(slot_it);
				}
				
				slot->call(param1);
				if (data->deleted) break;
			}
		}
		catch (...)
		{
			catch_final(data, remove_slots);
			throw;
		}
		catch_final(data, remove_slots);
	}
Exemple #2
0
/**
 * Build a vector of Slot from the global_slots map with the
 * offset applied.
 *
 * The clears the global_slots map.
 * @returns true if the offset was applied correctly, false otherwise.
 */
bool ApplyOffset(uint16_t offset, SlotList *all_slots) {
  bool ok = true;
  all_slots->reserve(global_slots.size());
  SlotActionMap::const_iterator iter = global_slots.begin();
  for (; iter != global_slots.end(); ++iter) {
    Slot *slots = iter->second;
    if (slots->SlotOffset() + offset >= ola::DMX_UNIVERSE_SIZE) {
      OLA_FATAL << "Slot " << slots->SlotOffset() << " + offset " <<
        offset << " is greater than " << ola::DMX_UNIVERSE_SIZE - 1;
      ok = false;
      break;
    }
    slots->SetSlotOffset(slots->SlotOffset() + offset);
    all_slots->push_back(slots);
  }

  if (!ok) {
    all_slots->clear();
    for (iter = global_slots.begin(); iter != global_slots.end();
         ++iter)
      delete iter->second;
  }

  global_slots.clear();
  return ok;
}
Exemple #3
0
void Pass::runGraphite(Machine & m, FiniteStateMachine & fsm) const
{
	Slot *s = m.slotMap().segment.first();
	if (!s || !testPassConstraint(m)) return;
    Slot *currHigh = s->next();

#if !defined GRAPHITE2_NTRACING
    if (fsm.dbgout)  *fsm.dbgout << "rules"	<< json::array;
	json::closer rules_array_closer(fsm.dbgout);
#endif

    m.slotMap().highwater(currHigh);
    int lc = m_iMaxLoop;
    do
    {
        findNDoRule(s, m, fsm);
        if (s && (m.slotMap().highpassed() || s == m.slotMap().highwater() || --lc == 0)) {
        	if (!lc)
        	{
//        		if (dbgout)	*dbgout << json::item << json::flat << rule_event(-1, s, 1);
        		s = m.slotMap().highwater();
        	}
        	lc = m_iMaxLoop;
            if (s)
            	m.slotMap().highwater(s->next());
        }
    } while (s);
}
Exemple #4
0
void JSONSerializer::Traverse(const shared_ptr<Node>& root) {
  mNodes[root] = ++mNodeCount;

  /// Traverse slots
  for (auto slotPair : root->GetSerializableSlots()) {
    Slot* slot = slotPair.second;
    if (slot->mIsMultiSlot) {
      for (auto& node : slot->GetDirectMultiNodes()) {
        auto it = mNodes.find(node);
        if (it == mNodes.end()) {
          Traverse(node);
        }
      }
    }
    else {
      shared_ptr<Node> node = slot->GetDirectNode();
      if (node == nullptr || slot->IsDefaulted()) continue;
      auto it = mNodes.find(node);
      if (it == mNodes.end()) {
        Traverse(node);
      }
    }
  }

  mNodesList.push_back(root);
}
Exemple #5
0
void Pass::dumpRuleEventOutput(const FiniteStateMachine & fsm, const Rule & r, Slot * const last_slot) const
{
	*fsm.dbgout		<< json::item << json::flat << json::object
						<< "id" 	<< &r - m_rules
						<< "failed" << false
						<< "input" << json::flat << json::object
							<< "start" << objectid(dslot(&fsm.slots.segment, input_slot(fsm.slots, 0)))
							<< "length" << r.sort - r.preContext
							<< json::close // close "input"
						<< json::close	// close Rule object
				<< json::close // close considered array
				<< "output" << json::object
					<< "range" << json::flat << json::object
						<< "start"	<< objectid(dslot(&fsm.slots.segment, input_slot(fsm.slots, 0)))
						<< "end"	<< objectid(dslot(&fsm.slots.segment, last_slot))
					<< json::close // close "input"
					<< "slots"	<< json::array;
	const Position rsb_prepos = last_slot ? last_slot->origin() : fsm.slots.segment.advance();
	fsm.slots.segment.positionSlots(0);

	for(Slot * slot = output_slot(fsm.slots, 0); slot != last_slot; slot = slot->next())
		*fsm.dbgout		<< dslot(&fsm.slots.segment, slot);
	*fsm.dbgout			<< json::close 	// close "slots"
					<< "postshift"	<< (last_slot ? last_slot->origin() : fsm.slots.segment.advance()) - rsb_prepos
				<< json::close;			// close "output" object

}
Exemple #6
0
void Segment::linkClusters(Slot *s, Slot * end)
{
    end = end->next();

    for (; s != end && !s->isBase(); s = s->next());
    Slot * ls = s;

    if (m_dir & 1)
    {
        for (; s != end; s = s->next())
        {
            if (!s->isBase())   continue;

            s->sibling(ls);
            ls = s;
        }
    }
    else
    {
        for (; s != end; s = s->next())
        {
            if (!s->isBase())   continue;

            ls->sibling(s);
            ls = s;
        }
    }
}
Exemple #7
0
// ------------------------------------------------------------------------------------------------
void Signal::DisconnectFunc(Function & func)
{
    // Don't attempt to search anything if there's no head
    if (m_Head == nullptr)
    {
        return;
    }

    const SQHash hash = Slot{NullObject(), func}.mFuncHash;
    // Walk down the chain and remove the matching nodes
    for (Slot * node = m_Head, * next = nullptr; node != nullptr; node = next)
    {
        // Grab the next node upfront
        next = node->mNext;
        // Is this our node?
        if (node->mFuncHash == hash)
        {
            // Is this the head?
            if (node == m_Head)
            {
                m_Head = next; // Move the head to the next one
            }
            // Detach it from the chain
            node->Detach();
            // Delete the node instance
            delete node;
        }
    }
}
Exemple #8
0
 coherence( Target& obj, MPI_Comm comm )
   : myself_( -1 ), comm_( comm ), rslot_(), wslot_(), eslot_(), req_( NULL )
 {
   MPI_Comm_rank( comm_, &myself_ );
   obj.coherence_setup( *this );
   if ( 0 < rslot_.size() ) req_ = new MPI_Request[ rslot_.size() ];
 }
Exemple #9
0
Slot::~Slot() {
  // remove connections with other slots
  Slot * s;
  while( connections_.get(&s)) {
    s->remove_connection(this);
    connections_.pop();
  }
}
		~Signal_v1_Generic()
		{
			for (SlotIterator slot_it = slots.begin(); slot_it != slots.end(); slot_it++)
			{
				Slot slot = *slot_it;
				slot->release_signal_ref(owner);
			}
		}
	Signal_v1(const Signal_v1 &copy) : Signal(copy), impl(new Signal_v1_Generic(this))
	{
		impl->slots = copy.impl->slots;
		for (SlotIterator slot_it = impl->slots.begin(); slot_it != impl->slots.end(); slot_it++)
		{
			Slot slot = *slot_it;
			slot->add_signal_ref(this);
		}
	}
Exemple #12
0
void DropItemBehavior::OnDragLeave(BaseComponent* sender, const DragEventArgs& e)
{
    ContentControl* control = (ContentControl*)sender;
    Slot* slot = (Slot*)control->GetContent();

    slot->SetIsDragOver(false);

    e.handled = true;
}
Exemple #13
0
Slot* Slot::create(Ball* ball, Vec2 pos){
	Slot* slot = new (std::nothrow) Slot();
	if (slot && slot->init(ball,pos)){
		slot->autorelease();
		return slot;
	}
	CC_SAFE_DELETE(slot);
	return nullptr;
}
Exemple #14
0
Slot::Slot(const Slot &cpy) {
    const int *st = cpy.GetStrTime();
    const int *et = cpy.GetEndTime();
    for (register int i = 0; i < 6; i++) {
        str_time[i] = st[i];
        end_time[i] = et[i];
    }
    movieID = cpy.GetMovieID();
    cost = cpy.GetCost();
}
void BaseSkeleton::setAttachment (const string &slotName, const string &attachmentName) {
	for (int i = 0, n = slots.size(); i < n; i++) {
		Slot *slot = slots[i];
		if (slot->data->name == slotName) {
			slot->setAttachment(getAttachment(i, attachmentName));
			return;
		}
	}
	throw invalid_argument("Slot not found: " + slotName);
}
Exemple #16
0
void Segment::doMirror(uint16 aMirror)
{
    Slot * s;
    for (s = m_first; s; s = s->next())
    {
        unsigned short g = glyphAttr(s->gid(), aMirror);
        if (g && (!(dir() & 4) || !glyphAttr(s->gid(), aMirror + 1)))
            s->setGlyph(this, g);
    }
}
Exemple #17
0
static void ConnectAction(
	const std::string & valuestr,
	const SignalMap & signalmap,
	Slot & slot)
{
	typename SignalMap::const_iterator it = signalmap.find(valuestr);
	if (it != signalmap.end())
		slot.connect(*it->second);
	else
		slot.call(valuestr);
}
Exemple #18
0
// ------------------------------------------------------------------------------------------------
void Signal::Tail(Object & env, Function & func)
{
    // Don't attempt to search anything if there's no head
    if (m_Head == nullptr)
    {
        m_Head = new Slot(env, func, nullptr);
        // We're done here
        return;
    }

    const Slot slot{env, func};
    // Don't attempt to search anything if there's only one element
    if (m_Head->mNext == nullptr)
    {
        // Is it already inserted?
        if (*m_Head != slot)
        {
            m_Head->mNext = new Slot(env, func, nullptr);
            // Link with the head
            m_Head->mNext->mPrev = m_Head;
        }
        // We're done here
        return;
    }

    // Grab the head node
    Slot * node = m_Head, * prev = nullptr;
    // Walk down the chain and find a matching node
    for (; node != nullptr; prev = node, node = node->mNext)
    {
        if (*node == slot)
        {
            break; // Found it
        }
    }
    // Have we found anything?
    if (node == nullptr)
    {
        // Create the slot now
        node = new Slot(env, func, nullptr);
    }
    else
    {
        // Walk down the chain until the end
        while (prev->mNext != nullptr)
        {
            prev = prev->mNext;
        }
        // Finally, detach the node from it's current position
        node->Detach();
    }
    // Knowing 'prev' points to last element
    node->AttachPrev(prev);
}
void SSpineWidget::UpdateMesh(int32 LayerId, FSlateWindowElementList& OutDrawElements, const FGeometry& AllottedGeometry, Skeleton* Skeleton) {
	TArray<FVector> vertices;
	TArray<int32> indices;
	TArray<FVector2D> uvs;
	TArray<FColor> colors;
	TArray<FVector> darkColors;

	int idx = 0;
	int meshSection = 0;
	UMaterialInstanceDynamic* lastMaterial = nullptr;

	SkeletonClipping &clipper = widget->clipper;
	Vector<float> &worldVertices = widget->worldVertices;

	float depthOffset = 0;
	unsigned short quadIndices[] = { 0, 1, 2, 0, 2, 3 };

	for (int i = 0; i < (int)Skeleton->getSlots().size(); ++i) {
		Vector<float> &attachmentVertices = worldVertices;
		unsigned short* attachmentIndices = nullptr;
		int numVertices;
		int numIndices;
		AtlasRegion* attachmentAtlasRegion = nullptr;
		Color attachmentColor;
		attachmentColor.set(1, 1, 1, 1);
		float* attachmentUvs = nullptr;

		Slot* slot = Skeleton->getDrawOrder()[i];
		Attachment* attachment = slot->getAttachment();
		if (!attachment) continue;
		if (!attachment->getRTTI().isExactly(RegionAttachment::rtti) && !attachment->getRTTI().isExactly(MeshAttachment::rtti) && !attachment->getRTTI().isExactly(ClippingAttachment::rtti)) continue;

		if (attachment->getRTTI().isExactly(RegionAttachment::rtti)) {
			RegionAttachment* regionAttachment = (RegionAttachment*)attachment;
			attachmentColor.set(regionAttachment->getColor());
			attachmentAtlasRegion = (AtlasRegion*)regionAttachment->getRendererObject();
			regionAttachment->computeWorldVertices(slot->getBone(), attachmentVertices, 0, 2);
			attachmentIndices = quadIndices;
			attachmentUvs = regionAttachment->getUVs().buffer();
			numVertices = 4;
			numIndices = 6;
		}
		else if (attachment->getRTTI().isExactly(MeshAttachment::rtti)) {
			MeshAttachment* mesh = (MeshAttachment*)attachment;
			attachmentColor.set(mesh->getColor());
			attachmentAtlasRegion = (AtlasRegion*)mesh->getRendererObject();
			mesh->computeWorldVertices(*slot, 0, mesh->getWorldVerticesLength(), attachmentVertices, 0, 2);
			attachmentIndices = mesh->getTriangles().buffer();
			attachmentUvs = mesh->getUVs().buffer();
			numVertices = mesh->getWorldVerticesLength() >> 1;
			numIndices = mesh->getTriangles().size();
		}
		else /* clipping */ {
Exemple #20
0
bool Segment::initCollisions()
{
    m_collisions = grzeroalloc<SlotCollision>(slotCount());
    if (!m_collisions) return false;

    for (Slot *p = m_first; p; p = p->next())
        if (p->index() < slotCount())
            ::new (collisionInfo(p)) SlotCollision(this, p);
        else
            return false;
    return true;
}
Exemple #21
0
void Parser::makeConnection(Graph *_g,std::string _input, std::string _output)
{
	Slot *in = Utilities::findSlot(_g, _input);
	Slot *out = Utilities::findSlot(_g, _output);
	if(in->getName() != "empty" && out->getName() != "empty")
	{
		in->linkToSlot(out);
		return;
	}
	std::cout<<"something went wrong\n";

}
Exemple #22
0
static void dispatch_event(struct epoll_event *event) {
	Slot *slot = (Slot*) event->data.ptr;
	if (!slot->handler(slot->fd, event->events, slot->data)) {
		/* We are assuming here that the set of events returned by epoll doesn't
		 * contain this file descriptor more than once. epoll(7) says that events
		 * will be combined, so we should be safe.
		 *
		 * Note that closing the file descriptor automatically removes it from the
		 * epoll set. */
		close(slot->fd);
		free(slot);
	}
}
Exemple #23
0
//Create and return slot object
Slot* Slot::create(cocos2d::Vec2 position)
{
    Slot* pSprite = new Slot();
    if (pSprite)
    {
        pSprite->autorelease();
        pSprite->init(position);
        return pSprite;
    }
    
    CC_SAFE_DELETE(pSprite);
    return NULL;
}
	Signal_v1 &operator =(const Signal_v1 &copy)
	{
		if (impl->in_call) impl->deleted = true;
		else delete impl;

		impl = new Signal_v1_Generic(this);
		impl->slots = copy.impl->slots;
		for (SlotIterator slot_it = impl->slots.begin(); slot_it != impl->slots.end(); slot_it++)
		{
			Slot slot = *slot_it;
			slot->add_signal_ref(this);
		}
		return *this;
	}
	void catch_final(Signal_v1_Generic *data, std::list<SlotIterator> &remove_slots)
	{
		data->in_call_remove_slots = 0;

		// remove all slots no longer connected to any Slot.
		typename std::list<SlotIterator>::iterator remove_it;
		for (remove_it = remove_slots.begin(); remove_it != remove_slots.end(); remove_it++)
		{
			Slot slot = **remove_it;
			slot->release_signal_ref(this);
			data->slots.erase(*remove_it);
		}

		data->in_call = false;
		if (data->deleted) delete data;
	}
Exemple #26
0
bool Face::runGraphite(Segment *seg, const Silf *aSilf) const
{
#if !defined GRAPHITE2_NTRACING
    json * dbgout = logger();
    if (dbgout)
    {
        *dbgout << json::object
                    << "id"         << objectid(seg)
                    << "passes"     << json::array;
    }
#endif

//    if ((seg->dir() & 1) != aSilf->dir())
//        seg->reverseSlots();
    if ((seg->dir() & 3) == 3 && aSilf->bidiPass() == 0xFF)
        seg->doMirror(aSilf->aMirror());
    bool res = aSilf->runGraphite(seg, 0, aSilf->positionPass(), true);
    if (res)
    {
        seg->associateChars(0, seg->charInfoCount());
        if (aSilf->flags() & 0x20)
            res &= seg->initCollisions();
        res &= aSilf->runGraphite(seg, aSilf->positionPass(), aSilf->numPasses(), false);
    }

#if !defined GRAPHITE2_NTRACING
    if (dbgout)
{
        seg->positionSlots(0, 0, 0, aSilf->dir());
        *dbgout             << json::item
                            << json::close // Close up the passes array
                << "output" << json::array;
        for(Slot * s = seg->first(); s; s = s->next())
            *dbgout     << dslot(seg, s);
        seg->finalise(0);                   // Call this here to fix up charinfo back indexes.
        *dbgout         << json::close
                << "advance" << seg->advance()
                << "chars"   << json::array;
        for(size_t i = 0, n = seg->charInfoCount(); i != n; ++i)
            *dbgout     << json::flat << *seg->charinfo(i);
        *dbgout         << json::close  // Close up the chars array
                    << json::close;     // Close up the segment object
    }
#endif

    return res;
}
Exemple #27
0
// ------------------------------------------------------------------------------------------------
void Signal::Head(Object & env, Function & func)
{
    // Don't attempt to search anything if there's no head
    if (m_Head == nullptr)
    {
        m_Head = new Slot(env, func, nullptr);
        // We're done here
        return;
    }

    const Slot slot{env, func};
    // Don't attempt to search anything if there's only one element
    if (m_Head->mNext == nullptr)
    {
        // Is it already inserted?
        if (*m_Head != slot)
        {
            m_Head = new Slot(env, func, m_Head);
        }
        // We're done here
        return;
    }

    // Grab the head node
    Slot * node = m_Head;
    // Walk down the chain and find a matching node
    for (; node != nullptr; node = node->mNext)
    {
        if (*node == slot)
        {
            break; // Found it
        }
    }
    // Have we found anything?
    if (node == nullptr)
    {
        m_Head = new Slot(env, func, m_Head); // Lead everyone
    }
    // Is it the head already?
    else if (m_Head != node)
    {
        node->AttachNext(m_Head);
        // We're the head now
        m_Head = node;
    }
}
void SceneSaveLoad::saveSlot(int position)
{
	// First save at that position
	if(slots.size() < position){
		Slot slot;
		slot.setPlayer(*game_obj->player);
		slots.push_back(slot);
	}
	// Update save
	else{
		Slot slot = slots[position-1];
		slot.setPlayer(*game_obj->player);
		slots[position-1] = slot;
	}

	game_obj->file_loader->saveSlots(&slots);
}
Exemple #29
0
  void operator()( void *base )
  {
    if ( comm_ == NULL ) return;
    for ( unsigned int i = 0; i < rslot_.size(); ++i )
    {
      coherent_type& slot( rslot_[ i ] );

      MPI_Irecv( base, 1, slot.type, slot.pair, myself_, comm_, &req_[ i ] );
    }
    for ( unsigned int i = 0; i < wslot_.size(); ++i )
    {
      coherent_type& slot( wslot_[ i ] );

      MPI_Send( base, 1, slot.type, slot.pair, slot.pair, comm_ );
    }
    if ( 0 < rslot_.size() ) MPI_Waitall( rslot_.size(), req_, MPI_STATUSES_IGNORE );
  }
Exemple #30
0
bool Slot::connect(Slot& target) {
	if (!&target) {
		raise("Slot::connect(): invalid target slot given (null)");
	}
	bool ret = true;
	ret &= _addTarget(&target);
	ret &= target._addTarget(this);
	return ret;
}