ObservationTable::ContextSet ObservationTable::_getDistributionByK(const string k)
{
    ContextSet distribution;
    for (Context context : this->F) {
        if (this->_mat.Mem(context.first, k, context.second)) {
            distribution.insert(context);
        }
    }
    return distribution;
}
Example #2
0
void CompositeViewer::getContexts(Contexts& contexts, bool onlyValid)
{
    typedef std::set<osg::GraphicsContext*> ContextSet;
    ContextSet contextSet;

    for(RefViews::iterator vitr = _views.begin();
            vitr != _views.end();
            ++vitr)
    {
        osgViewer::View* view = vitr->get();
        if (view->getCamera() &&
                view->getCamera()->getGraphicsContext() &&
                (view->getCamera()->getGraphicsContext()->valid() || !onlyValid))
        {
            contextSet.insert(view->getCamera()->getGraphicsContext());
        }

        for(unsigned int i=0; i<view->getNumSlaves(); ++i)
        {
            View::Slave& slave = view->getSlave(i);
            if (slave._camera.valid() &&
                    slave._camera->getGraphicsContext() &&
                    (slave._camera->getGraphicsContext()->valid() || !onlyValid))
            {
                contextSet.insert(slave._camera->getGraphicsContext());
            }
        }
    }

    contexts.clear();
    contexts.reserve(contextSet.size());

    for(ContextSet::iterator itr = contextSet.begin();
            itr != contextSet.end();
            ++itr)
    {
        contexts.push_back(const_cast<osg::GraphicsContext*>(*itr));
    }
}
void CompositeViewer::getContexts(Contexts& contexts, bool onlyValid)
{
    typedef std::set<osg::GraphicsContext*> ContextSet;
    ContextSet contextSet;

    contexts.clear();

    for(RefViews::iterator vitr = _views.begin();
            vitr != _views.end();
            ++vitr)
    {
        osgViewer::View* view = vitr->get();
        osg::GraphicsContext* gc = view->getCamera() ? view->getCamera()->getGraphicsContext() : 0;
        if (gc && (gc->valid() || !onlyValid))
        {
            if (contextSet.count(gc)==0)
            {
                contextSet.insert(gc);
                contexts.push_back(gc);
            }
        }

        for(unsigned int i=0; i<view->getNumSlaves(); ++i)
        {
            View::Slave& slave = view->getSlave(i);
            osg::GraphicsContext* sgc = slave._camera.valid() ? slave._camera->getGraphicsContext() : 0;
            if (sgc && (sgc->valid() || !onlyValid))
            {
                if (contextSet.count(sgc)==0)
                {
                    contextSet.insert(sgc);
                    contexts.push_back(sgc);
                }
            }
        }
    }
}
Example #4
0
	int ArdbServer::Watch(ArdbConnContext& ctx, RedisCommandFrame& cmd)
	{
		ctx.reply.type = REDIS_REPLY_STATUS;
		ctx.reply.str = "OK";
		m_db->GetDBWatcher().on_key_update = ArdbServer::OnKeyUpdated;
		m_db->GetDBWatcher().on_key_update_data = this;
		if (NULL == ctx.watch_key_set)
		{
			ctx.watch_key_set = new WatchKeySet;
		}
		ArgumentArray::iterator it = cmd.GetArguments().begin();
		while (it != cmd.GetArguments().end())
		{
			WatchKey k(ctx.currentDB, *it);
			ctx.watch_key_set->insert(k);
			LockGuard<ThreadMutex> guard(m_watch_mutex);
			WatchKeyContextTable::iterator found = m_watch_context_table.find(
			        k);
			if (found == m_watch_context_table.end())
			{
				ContextSet set;
				set.insert(&ctx);
				m_watch_context_table.insert(
				        WatchKeyContextTable::value_type(k, set));
			}
			else
			{
				ContextSet& set = found->second;
				ContextSet::iterator lit = set.begin();
				while (lit != set.end())
				{
					if (*lit == &ctx)
					{
						set.erase(lit);
						break;
					}
					lit++;
				}
				set.insert(&ctx);
			}
			it++;
		}
		return 0;
	}