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;
}
Esempio n. 2
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;
	}
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);
                }
            }
        }
    }
}
Esempio n. 4
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));
    }
}
Esempio n. 5
0
int main(int argc, char **argv)
{
    // Read the configuration from the arguments
    Configuration config(argc, argv);

    // Get the include list and definition list
    u32 includeCount = config.GetIncludeCount();
    const char **pIncludes = new const char * [includeCount];
    for (u32 i = 0; i < includeCount; i++) {
        pIncludes[i] = config.GetInclude(i).c_str();
    }

    u32 definitionCount = config.GetDefinitionCount();
    const char **pDefinitions = new const char * [definitionCount];
    for (u32 i = 0; i < definitionCount; i++) {
        pDefinitions[i] = config.GetDefinition(i).c_str();
    }

    // Create a ContextSet to read in all of the contexts from the
    // header file(s)
    ContextSet *pContextSet = CreateContextSet();

    bool success = true;
    u32 inputCount = config.GetInputCount();
    for (u32 i = 0; i < inputCount; i++) {
        const char *pInput = config.GetInput(i).c_str();
        string tmpFile = config.GetTempFile();
        if (!pContextSet->AddHeader(pInput, includeCount, 
                                    (const char **) pIncludes,
                                    definitionCount, 
                                    (const char **) pDefinitions, 
                                    tmpFile.c_str())) {
            fprintf(stderr, "Failed to process header file: %s\n", pInput);
            fprintf(stderr, pContextSet->GetLastError());
            fprintf(stderr, "\n");
            success = false;
            break;
        }
    }

    delete [] pDefinitions;
    delete [] pIncludes;

    if (!success) {
        delete pContextSet;
        return -1;
    }

    {
        Generator generator(config, *pContextSet);

        if (!generator.Generate()) {
            delete pContextSet;
            return -1;
        }
    }

    delete pContextSet;

    return 0;
}