当前位置: 首页>>代码示例>>C++>>正文


C++ DataManager::addSource方法代码示例

本文整理汇总了C++中DataManager::addSource方法的典型用法代码示例。如果您正苦于以下问题:C++ DataManager::addSource方法的具体用法?C++ DataManager::addSource怎么用?C++ DataManager::addSource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataManager的用法示例。


在下文中一共展示了DataManager::addSource方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char** argv)
{
	SoundTest app;

	// Read config file name from command line or use default one.
	const char* cfgName = "soundTest.cfg";
	if(argc == 2) cfgName = argv[1];

	Config* cfg = new Config(cfgName);

	DataManager* dm = DataManager::getInstance();
	// Add a default filesystem data source using current work dir.
	dm->addSource(new FilesystemDataSource("./"));
	dm->addSource(new FilesystemDataSource(OMICRON_DATA_PATH));

	ServiceManager* sm = new ServiceManager();
	sm->setupAndStart(cfg);

	float delay = -0.01f; // Seconds to delay sending events (<= 0 disables delay)
#ifdef _DEBUG
	bool printOutput = true;
#else
	bool printOutput = false;
#endif

	while(true)
	{
		sm->poll();

		// Get events
		int av = sm->getAvailableEvents();
		if(av != 0)
		{
			// TODO: Instead of copying the event list, we can lock the main one.
			Event evts[OMICRON_MAX_EVENTS];
			sm->getEvents(evts, OMICRON_MAX_EVENTS);
			for( int evtNum = 0; evtNum < av; evtNum++)
			{
				app.handleEvent(evts[evtNum]);
			}
			app.update();
			//if( printOutput )
			//	printf("------------------------------------------------------------------------------\n");
		}
	}

	sm->stop();
	delete sm;
	delete cfg;
	delete dm;
	
	return 0;
}
开发者ID:OKaluza,项目名称:omicron,代码行数:53,代码来源:soundtest.cpp

示例2: main

void main(int argc, char** argv)
{
	OInputServer app;

	// Read config file name from command line or use default one.
	const char* cfgName = "oinputserver.cfg";
	if(argc == 2) cfgName = argv[1];

	Config* cfg = new Config(cfgName);

	DataManager* dm = DataManager::getInstance();
	// Add a default filesystem data source using current work dir.
	dm->addSource(new FilesystemDataSource("./"));
	dm->addSource(new FilesystemDataSource(OMICRON_DATA_PATH));

	ServiceManager* sm = new ServiceManager();
	sm->setupAndStart(cfg);

	app.startConnection();
	
	float delay = -0.01f; // Seconds to delay sending events (<= 0 disables delay)
	bool testStream = false;
	char* testPacket;

	bool printOutput = true;

	printf("OInputServer: Starting to listen for clients... \n");
	while(true){
		if( delay > 0.0 )
			Sleep(1000.0*delay); // Delay sending of data out

		sm->poll(); // Required for DirectInputService

		// Start listening for clients (non-blocking)
		app.startListening();

		// Get events
		int av = sm->getAvailableEvents();
		if(av != 0 && !testStream )
		{
			/*
			// @todo: Instead of copying the event list, we can lock the main one.
			Event evts[OMICRON_MAX_EVENTS];
			sm->getEvents(evts, OMICRON_MAX_EVENTS);
			for( int evtNum = 0; evtNum < av; evtNum++)
			{
				if( app.handleEvent(evts[evtNum]) ){ // is there an event?
					// Send event to clients
					if( printOutput )
						printf("%s\n", app.getEvent());
					app.sendToClients( app.getEvent() );
				}
			}
			if( printOutput )
				printf("------------------------------------------------------------------------------\n");
				*/
		}// if
		else if( testStream ){
			testPacket = new char[99];
			// example touch string: '2:-10,0.5,0.5,0.1,0.1 '
			itoa(1, testPacket, 10); // Append input type
			strcat( testPacket, ":42,0.5,0.5,0.1,0.1 " );
			printf("OInputServer: main() ----- WARNING: TEST STREAM MODE ACTIVE -----\n");
			printf("%s\n",testPacket);
			app.sendToClients( testPacket );
		}
		

	}// while

	sm->stop();
	delete sm;
	delete cfg;
	delete dm;
}
开发者ID:uic-evl,项目名称:omicron,代码行数:75,代码来源:legacy-oinputserver.cpp


注:本文中的DataManager::addSource方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。