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


C++ ConfigurationTable::set方法代码示例

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


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

示例1: gLogInit

void gLogInit(const char* defaultLevel)
{
	// Define defaults in the global config
	if (!gConfig.defines("Log.Level")) {
		gConfig.set("Log.Level",defaultLevel);
		LOG(FORCE) << "Setting initial global logging level to " << defaultLevel;
	}
	if (!gConfig.defines("Log.Alarms.TargetPort")) {
		gConfig.set("Log.Alarms.TargetPort",DEFAULT_ALARM_PORT);
	}
	if (!gConfig.defines("Log.Alarms.Max")) {
		gConfig.set("Log.Alarms.Max",DEFAULT_MAX_ALARMS);
	}
}
开发者ID:EricYoel,项目名称:openbts-2.6,代码行数:14,代码来源:Logger.cpp

示例2: gLogInit

void gLogInit(const char* name, const char* level, int facility)
{
	// Set the level if one has been specified.
	if (level) {
		gConfig.set("Log.Level",level);
	}
	gPid = getpid();

	// Pat added, tired of the syslog facility.
	// Both the transceiver and OpenBTS use this same facility, but only OpenBTS/OpenNodeB may use this log file:
	string str = gConfig.getStr("Log.File");
	if (gLogToFile==0 && str.length() && 0==strncmp(gCmdName,"Open",4)) {
		const char *fn = str.c_str();
		if (fn && *fn && strlen(fn)>3) {	// strlen because a garbage char is getting in sometimes.
			gLogToFile = fopen(fn,"w"); // New log file each time we start.
			if (gLogToFile) {
                                time_t now = time(NULL);
                                std::string result;
                                Timeval::isoTime(now, result);
                                fprintf(gLogToFile,"Starting at %s",result.c_str());
				fflush(gLogToFile);
				std::cout << name <<" logging to file: " << fn << "\n";
			}
		}
	}

	// Open the log connection.
	openlog(name,0,facility);

	// We cant call this from the Mutex itself because the Logger uses Mutex.
	gMutexLogLevel = gGetLoggingLevel("Mutex.cpp");
}
开发者ID:telenoobie,项目名称:CommonLibs,代码行数:32,代码来源:Logger.cpp

示例3: testConfig

/* Run sanity check on configuration table
 *     The global table constructor cannot provide notification in the
 *     event of failure. Make sure that we can access the database,
 *     write to it, and that it contains the bare minimum required keys.
 */
bool testConfig()
{
    int val = 9999;
    std::string test = "asldfkjsaldkf";
    const char *key = "Log.Level";

    /* Attempt to query */
    try {
        gConfig.getStr(key);
    } catch (...) {
        std::cerr << std::endl;
        std::cerr << "Config: Failed query required key " << key
                  << std::endl;
        return false;
    }

    /* Attempt to set a test value in the global config */
    if (!gConfig.set(test, val)) {
        std::cerr << std::endl;
        std::cerr << "Config: Failed to set test key" << std::endl;
        return false;
    } else {
        gConfig.remove(test);
    }

    return true;
}
开发者ID:kkroo,项目名称:osmo-trx,代码行数:32,代码来源:osmo-trx.cpp

示例4: gLogInitWithFile

// Allow applications to also pass in a filename.  Filename should come from the database
void gLogInitWithFile(const char* name, const char* level, int facility, char * LogFilePath)
{
	// Set the level if one has been specified.
	if (level) {
		gConfig.set("Log.Level",level);
	}

	if (gLogToFile==0 && LogFilePath != 0 && *LogFilePath != 0 && strlen(LogFilePath) > 0) {
		gLogToFile = fopen(LogFilePath,"w"); // New log file each time we start.
		if (gLogToFile) {
			time_t now = time(NULL);
                        std::string result;
                        Timeval::isoTime(now, result);
			fprintf(gLogToFile,"Starting at %s",result.c_str());
			fflush(gLogToFile);
			std::cout << name <<" logging to file: " << LogFilePath << "\n";
		}
	}

	// Open the log connection.
	openlog(name,0,facility);

	// We cant call this from the Mutex itself because the Logger uses Mutex.
	gMutexLogLevel = gGetLoggingLevel("Mutex.cpp");
}
开发者ID:telenoobie,项目名称:CommonLibs,代码行数:26,代码来源:Logger.cpp

示例5: levelStringToInt

/** Given a string, return the corresponding level name. */
static int lookupLevel2(const string& key, const string &keyVal)
{
	int level = levelStringToInt(keyVal);

	if (level == -1) {
		string defaultLevel = gConfig.mSchema["Log.Level"].getDefaultValue();
		level = levelStringToInt(defaultLevel);
		_LOG(CRIT) << "undefined logging level (" << key << " = \"" << keyVal << "\") defaulting to \"" << defaultLevel << ".\" Valid levels are: EMERG, ALERT, CRIT, ERR, WARNING, NOTICE, INFO or DEBUG";
		gConfig.set(key, defaultLevel);
	}

	return level;
}
开发者ID:telenoobie,项目名称:CommonLibs,代码行数:14,代码来源:Logger.cpp

示例6: main

int main(int argc, char *argv[]) {

	SubscriberRegistry gHLR;

	gLogInit("HLRTest");
	gConfig.set("Log.Level","DEBUG");

	if (argc!=2) {
		std::cerr << "usage: " << argv[0] << " <number>" << std::endl;
		exit(-1);
	}
	const char *targ = argv[1];

	char *IMSI = gHLR.getIMSI(targ);
	if (IMSI) std::cout << "IMSI for " << targ << " is " << IMSI << std::endl;
	else std::cout << "no IMSI found for " << targ << std::endl;

	char *CLID = gHLR.getCLIDLocal(IMSI);
	if (CLID) std::cout << "CLID for " << IMSI << " is " << CLID << std::endl;
	else std::cout << "no CLID found for " << IMSI << std::endl;

	char *regIP = gHLR.getRegistrationIP("234100223456161");
	if (regIP) std::cout << "registration IP for " << IMSI << " is " << regIP << std::endl;
	else std::cout << "no regIP found for " << IMSI << std::endl;

	IMSI = gHLR.getIMSI(targ);
	if (IMSI) std::cout << "IMSI for " << targ << " is " << IMSI << std::endl;
	else std::cout << "no IMSI found for " << targ << std::endl;

	CLID = gHLR.getCLIDLocal(IMSI);
	if (CLID) std::cout << "CLID for " << IMSI << " is " << CLID << std::endl;
	else std::cout << "no CLID found for " << IMSI << std::endl;


	const char targ2[] = "1234567890";
	gHLR.addUser("123456789012345",targ2);

	sleep(2);

	IMSI = gHLR.getIMSI(targ2);
	if (IMSI) std::cout << "IMSI for " << targ2 << " is " << IMSI << std::endl;
	else std::cout << "no IMSI found for " << targ2 << std::endl;

	CLID = gHLR.getCLIDLocal(IMSI);
	if (CLID) std::cout << "CLID for " << IMSI << " is " << CLID << std::endl;
	else std::cout << "no CLID found for " << IMSI << std::endl;



}
开发者ID:5728136cs,项目名称:Mobile_Netze_HM_OpenBTS_Handover,代码行数:50,代码来源:HLRTest.cpp

示例7: doVisibles

void doVisibles()
{
	gVisibleSipColumns = "";
	map<string,string>::iterator it;
	bool first = true;
	for (it = gArgs.begin(); it != gArgs.end(); it++) {
		if (it->first == "what") continue;
		if (first) {
			first = false;
		} else {
			gVisibleSipColumns += " ";
		}
		gVisibleSipColumns += it->first;
	}
	if (!gConfig.set("SubscriberRegistry.Manager.VisibleColumns", gVisibleSipColumns)) {
		LOG(ERR) << "unable to update SubscriberRegistry.Manager.VisibleColumns";
	}
}
开发者ID:Gabotero,项目名称:OpenBTS,代码行数:18,代码来源:srmanager.cpp

示例8: main

int main(int argc, char *argv[])
{
	//mtrace();       // (pat) Enable memory leak detection.  Unfortunately, huge amounts of code have been started in the constructors above.
	gLogGroup.setAll();
	// TODO: Properly parse and handle any arguments
	if (argc > 1) {
		bool testflag = false;
		for (int argi = 1; argi < argc; argi++) {		// Skip argv[0] which is the program name.
			if (!strcmp(argv[argi], "--version") || !strcmp(argv[argi], "-v")) {
				// Print the version number and exit immediately.
				cout << gVersionString << endl;
				return 0;
			}
			if (!strcmp(argv[argi], "--test")) {
				testflag = true;
				continue;
			}
			if (!strcmp(argv[argi], "--gensql")) {
				cout << gConfig.getDefaultSQL(string(argv[0]), gVersionString) << endl;
				return 0;
			}
			if (!strcmp(argv[argi], "--gentex")) {
				cout << gConfig.getTeX(string(argv[0]), gVersionString) << endl;
				return 0;
			}

			// (pat) Adding support for specified sql file.
			// Unfortunately, the Config table was inited quite some time ago,
			// so stick this arg in the environment, whence the ConfigurationTable can find it, and then reboot.
			if (!strcmp(argv[argi],"--config")) {
				if (++argi == argc) {
					LOG(ALERT) <<"Missing argument to --config option";
					exit(2);
				}
				setenv(cOpenBTSConfigEnv,argv[argi],1);
				execl(argv[0],"OpenBTS",NULL);
				LOG(ALERT) <<"execl failed?  Exiting...";
				exit(0);
			}
			if (!strcmp(argv[argi],"--help")) {
				printf("OpenBTS [--version --gensql --gentex] [--config file.db]\n");
				printf("OpenBTS exiting...\n");
				exit(0);
			}

			printf("OpenBTS: unrecognized argument: %s\nexiting...\n",argv[argi]);
		}

		if (testflag) { GSM::TestTCHL1FEC(); return 0; }
	}

	createStats();

	gConfig.setCrossCheckHook(&configurationCrossCheck);

	gReports.incr("OpenBTS.Starts");

	gNeighborTable.NeighborTableInit(
		gConfig.getStr("Peering.NeighborTable.Path").c_str());

	int sock = socket(AF_UNIX,SOCK_DGRAM,0);
	if (sock<0) {
		perror("creating CLI datagram socket");
		LOG(ALERT) << "cannot create socket for CLI";
		gReports.incr("OpenBTS.Exit.CLI.Socket");
		exit(1);
	}

	try {

	srandom(time(NULL));

	gConfig.setUpdateHook(purgeConfig);
	LOG(ALERT) << "OpenBTS (re)starting, ver " << VERSION << " build date " << __DATE__;
	LOG(ALERT) << "OpenBTS reading config file "<<cOpenBTSConfigFile;

	COUT("\n\n" << gOpenBTSWelcome << "\n");
	Control::controlInit();		// init Layer3: TMSITable, TransactionTable.
	gPhysStatus.open(gConfig.getStr("Control.Reporting.PhysStatusTable").c_str());
	gBTS.init();
	gParser.addCommands();

	COUT("\nStarting the system...");

	// is the radio running?
	// Start the transceiver interface.
	LOG(INFO) << "checking transceiver";
	//gTRX.ARFCN(0)->powerOn();
	//sleep(gConfig.getNum("TRX.Timeout.Start"));
	//bool haveTRX = gTRX.ARFCN(0)->powerOn(false);		This prints an inapplicable warning message.
	bool haveTRX = gTRX.ARFCN(0)->trxRunning();			// This does not print an inapplicable warning message.

	Thread transceiverThread;
	if (!haveTRX) {
		LOG(ALERT) << "starting the transceiver";
		transceiverThread.start((void*(*)(void*)) startTransceiver, NULL);
		// sleep to let the FPGA code load
		// TODO: we should be "pinging" the radio instead of sleeping
		sleep(5);
	} else {
//.........这里部分代码省略.........
开发者ID:5728136cs,项目名称:OpenBTS-nuand,代码行数:101,代码来源:OpenBTS.cpp

示例9: main

int main(int argc, char *argv[])
{
	// TODO: Properly parse and handle any arguments
	if (argc > 1) {
		for (int argi = 0; argi < argc; argi++) {
			if (!strcmp(argv[argi], "--version") ||
			    !strcmp(argv[argi], "-v")) {
				cout << gVersionString << endl;
			}
		}

		return 0;
	}

	createStats();
 
	gReports.incr("OpenBTS.Starts");

	int sock = socket(AF_UNIX,SOCK_DGRAM,0);
	if (sock<0) {
		perror("creating CLI datagram socket");
		LOG(ALERT) << "cannot create socket for CLI";
		gReports.incr("OpenBTS.Exit.CLI.Socket");
		exit(1);
	}

	try {

	srandom(time(NULL));

	gConfig.setUpdateHook(purgeConfig);
	gLogInit("openbts",gConfig.getStr("Log.Level").c_str());
	LOG(ALERT) << "OpenBTS starting, ver " << VERSION << " build date " << __DATE__;

	COUT("\n\n" << gOpenBTSWelcome << "\n");
	gTMSITable.open(gConfig.getStr("Control.Reporting.TMSITable").c_str());
	gTransactionTable.init(gConfig.getStr("Control.Reporting.TransactionTable").c_str());
	gPhysStatus.open(gConfig.getStr("Control.Reporting.PhysStatusTable").c_str());
	gBTS.init();
	gSubscriberRegistry.init();
	gParser.addCommands();

	COUT("\nStarting the system...");

	// is the radio running?
	// Start the transceiver interface.
	LOG(INFO) << "checking transceiver";
	//gTRX.ARFCN(0)->powerOn();
	//sleep(gConfig.getNum("TRX.Timeout.Start",2));
	bool haveTRX = gTRX.ARFCN(0)->powerOn(false);

	Thread transceiverThread;
	if (!haveTRX) {
		transceiverThread.start((void*(*)(void*)) startTransceiver, NULL);
		// sleep to let the FPGA code load
		// TODO: we should be "pinging" the radio instead of sleeping
		sleep(5);
	} else {
		LOG(NOTICE) << "transceiver already running";
	}

	// Start the SIP interface.
	gSIPInterface.start();


	//
	// Configure the radio.
	//

	gTRX.start();

	// Set up the interface to the radio.
	// Get a handle to the C0 transceiver interface.
	ARFCNManager* C0radio = gTRX.ARFCN(0);

	// Tuning.
	// Make sure its off for tuning.
	//C0radio->powerOff();
	// Get the ARFCN list.
	unsigned C0 = gConfig.getNum("GSM.Radio.C0");
	unsigned numARFCNs = gConfig.getNum("GSM.Radio.ARFCNs");
	for (unsigned i=0; i<numARFCNs; i++) {
		// Tune the radios.
		unsigned ARFCN = C0 + i*2;
		LOG(INFO) << "tuning TRX " << i << " to ARFCN " << ARFCN;
		ARFCNManager* radio = gTRX.ARFCN(i);
		radio->tune(ARFCN);
	}

	// Send either TSC or full BSIC depending on radio need
	if (gConfig.getBool("GSM.Radio.NeedBSIC")) {
		// Send BSIC to 
		C0radio->setBSIC(gBTS.BSIC());
	} else {
		// Set TSC same as BCC everywhere.
		C0radio->setTSC(gBTS.BCC());
	}

	// Set maximum expected delay spread.
	C0radio->setMaxDelay(gConfig.getNum("GSM.Radio.MaxExpectedDelaySpread"));
//.........这里部分代码省略.........
开发者ID:TeamFSS,项目名称:public,代码行数:101,代码来源:OpenBTS.cpp

示例10: main

int main(int argc, char *argv[])
{

	gConfig.setUpdateHook(purgeConfig);

	const char *keys[5] = {"key1", "key2", "key3", "key4", "key5"};

	for (int i=0; i<5; i++) {
		gConfig.set(keys[i],i);
	}

	for (int i=0; i<5; i++) {
		cout << "table[" << keys[i] << "]=" << gConfig.getStr(keys[i]) <<  endl;
		cout << "table[" << keys[i] << "]=" << gConfig.getNum(keys[i]) <<  endl;
	}

	for (int i=0; i<5; i++) {
		cout << "defined table[" << keys[i] << "]=" << gConfig.defines(keys[i]) <<  endl;
	}

	gConfig.set("key5","100 200 300  400 ");
	std::vector<unsigned> vect = gConfig.getVector("key5");
	cout << "vect length " << vect.size() << ": ";
	for (unsigned i=0; i<vect.size(); i++) cout << " " << vect[i];
	cout << endl;
	std::vector<string> svect = gConfig.getVectorOfStrings("key5");
	cout << "vect length " << svect.size() << ": ";
	for (unsigned i=0; i<svect.size(); i++) cout << " " << svect[i] << ":";
	cout << endl;

	cout << "bool " << gConfig.getBool("booltest") << endl;
	gConfig.set("booltest",1);
	cout << "bool " << gConfig.getBool("booltest") << endl;
	gConfig.set("booltest",0);
	cout << "bool " << gConfig.getBool("booltest") << endl;

	gConfig.getStr("newstring");
	gConfig.getNum("numnumber");


	SimpleKeyValue pairs;
	pairs.addItems(" a=1 b=34 dd=143 ");
	cout<< pairs.get("a") << endl;
	cout<< pairs.get("b") << endl;
	cout<< pairs.get("dd") << endl;

	gConfig.set("fkey","123.456");
	float fval = gConfig.getFloat("fkey");
	cout << "fkey " << fval << endl;

	cout << "search fkey:" << endl;
	gConfig.find("fkey",cout);
	cout << "search fkey:" << endl;
	gConfig.find("fkey",cout);
	gConfig.remove("fkey");
	cout << "search fkey:" << endl;
	gConfig.find("fkey",cout);

	try {
		gConfig.getNum("supposedtoabort");
	} catch (ConfigurationTableKeyNotFound) {
		cout << "ConfigurationTableKeyNotFound exception successfully caught." << endl;
	}
}
开发者ID:5728136cs,项目名称:CommonLibs,代码行数:64,代码来源:ConfigurationTest.cpp


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