本文整理汇总了C++中ConfigurationTable::defines方法的典型用法代码示例。如果您正苦于以下问题:C++ ConfigurationTable::defines方法的具体用法?C++ ConfigurationTable::defines怎么用?C++ ConfigurationTable::defines使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConfigurationTable
的用法示例。
在下文中一共展示了ConfigurationTable::defines方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
示例2: addAlarm
// Add an alarm to the alarm list, and send it out via udp
//
// On the first call we read the ip and port from the configuration
// TODO - is there any global setup function where this should be done? -- Alon
void addAlarm(const string& s)
{
// Socket open and close on every alarm - wise?
// Probably. That way we are sure to pick up changes in the target address.
// Alarms should not happen often.
if (gConfig.defines("Log.Alarms.TargetIP")) {
UDPSocket alarmsocket(0,
gConfig.getStr("Log.Alarms.TargetIP"),
gConfig.getNum("Log.Alarms.TargetPort"));
alarmsocket.write(s.c_str());
}
// append to list and reduce list to max alarm count
alarmsLock.lock();
alarmsList.push_back(s);
unsigned maxAlarms = gConfig.getNum("Log.Alarms.Max");
while (alarmsList.size() > maxAlarms) alarmsList.pop_front();
alarmsLock.unlock();
}
示例3: setAll
// Set all the Log.Group debug levels based on database settings
void LogGroup::setAll()
{
LOG(DEBUG);
string prefix = string(LogGroupPrefix);
for (unsigned g = 0; g < _NumberOfLogGroups; g++) {
int level = 0;
string param = prefix + mGroupNames[g];
if (gConfig.defines(param)) {
string levelName = gConfig.getStr(param);
// (pat) The "unconfig" command does not remove the value, it just gives it an empty value, so check for that.
if (levelName.size()) {
//LOG(DEBUG) << "Setting "<<LOGVAR(param)<<LOGVAR(levelName);
level = lookupLevel2(param,levelName);
}
}
mDebugLevel[g] = level;
}
}
示例4: getLoggingLevel
int getLoggingLevel(const char* filename)
{
// Default level?
if (!filename) return lookupLevel("Log.Level");
// This can afford to be inefficient since it is not called that often.
string keyName;
keyName.reserve(100);
keyName.append("Log.Level.");
keyName.append(filename);
if (gConfig.defines(keyName)) {
string keyVal = gConfig.getStr(keyName);
// (pat 4-2014) The CLI 'unconfig' command does not unset the value, it just gives an empty value,
// so check for that and treat it as an unset value, ie, do nothing.
if (keyVal.size()) {
return lookupLevel2(keyName,keyVal);
}
}
return lookupLevel("Log.Level");
}
示例5: gLoggingLevel
/** Return the current logging level for a given source file. */
Log::Level gLoggingLevel(const char* filename)
{
const string keyName = string("Log.Level.") + string(filename);
if (gConfig.defines(keyName)) return gLookupLevel(gConfig.getStr(keyName));
return gLookupLevel(gConfig.getStr("Log.Level"));
}
示例6: main
//.........这里部分代码省略.........
CCCH1.downstream(C0radio);
CCCH1.open();
CCCHLogicalChannel CCCH2(gCCCH_2Mapping);
CCCH2.downstream(C0radio);
CCCH2.open();
// use CCCHs as AGCHs
gBTS.addAGCH(&CCCH0);
gBTS.addAGCH(&CCCH1);
gBTS.addAGCH(&CCCH2);
// C-V C0T0 SDCCHs
SDCCHLogicalChannel C0T0SDCCH[4] = {
SDCCHLogicalChannel(0,gSDCCH_4_0),
SDCCHLogicalChannel(0,gSDCCH_4_1),
SDCCHLogicalChannel(0,gSDCCH_4_2),
SDCCHLogicalChannel(0,gSDCCH_4_3),
};
Thread C0T0SDCCHControlThread[4];
for (int i=0; i<4; i++) {
C0T0SDCCH[i].downstream(C0radio);
C0T0SDCCHControlThread[i].start((void*(*)(void*))Control::DCCHDispatcher,&C0T0SDCCH[i]);
C0T0SDCCH[i].open();
gBTS.addSDCCH(&C0T0SDCCH[i]);
}
//
// Configure the other slots.
//
// Count configured slots.
unsigned sCount = 1;
if (gConfig.defines("GSM.Channels.C1sFirst")) {
// Create C-I slots.
for (int i=0; i<gConfig.getNum("GSM.Channels.NumC1s"); i++) {
gBTS.createCombinationI(gTRX,sCount);
sCount++;
}
}
// Create C-VII slots.
for (int i=0; i<gConfig.getNum("GSM.Channels.NumC7s"); i++) {
gBTS.createCombinationVII(gTRX,sCount);
sCount++;
}
if (!gConfig.defines("GSM.Channels.C1sFirst")) {
// Create C-I slots.
for (int i=0; i<gConfig.getNum("GSM.Channels.NumC1s"); i++) {
gBTS.createCombinationI(gTRX,sCount);
sCount++;
}
}
// Set up idle filling on C0 as needed.
while (sCount<8) {
gBTS.createCombination0(gTRX,sCount);
sCount++;
}
/*
Note: The number of different paging subchannels on
the CCCH is:
示例7: calleridstr
char *processBuffer(char *buffer)
{
int i;
// parse sip message
osip_message_t *sip;
i=osip_message_init(&sip);
if (i!=0) {
LOG(ERR) << "cannot allocate";
osip_message_free(sip);
return NULL;
}
i=osip_message_parse(sip, buffer, strlen(buffer));
if (i!=0) {
LOG(ERR) << "cannot parse sip message";
osip_message_free(sip);
return NULL;
}
prettyPrint("request", sip);
// response starts as clone of message
osip_message_t *response;
osip_message_clone(sip, &response);
osip_from_t * contact_header = (osip_from_t*)osip_list_get(&sip->contacts,0);
osip_uri_t* contact_url = contact_header->url;
char *remote_host = contact_url->host;
char *remote_port = contact_url->port;
// return via
ostringstream newvia;
// newvia << "SIP/2.0/UDP localhost:5063;branch=1;[email protected]";
const char *my_ipaddress = "localhost";
newvia << "SIP/2.0/UDP " << my_ipaddress << ":" << my_udp_port << ";branch=1;received="
<< "[email protected]"; // << my_network.string_addr((struct sockaddr *)netaddr, netaddrlen, false);
osip_message_append_via(response, newvia.str().c_str());
// no method
osip_message_set_method(response, NULL);
string imsi = imsiClean(imsiFromSip(sip));
string imsiTo = imsiClean(imsiToSip(sip));
if ((imsi == "EXIT") && (imsiTo == "EXIT")) exit(0); // for testing only
if (!imsiFound(imsi)) {
LOG(NOTICE) << "imsi unknown";
// imsi problem => 404 IMSI Not Found
osip_message_set_status_code (response, 404);
osip_message_set_reason_phrase (response, osip_strdup("IMSI Not Found"));
} else if (gConfig.defines("SubscriberRegistry.IgnoreAuthentication")) {
osip_message_set_status_code (response, 200);
osip_message_set_reason_phrase (response, osip_strdup("OK"));
LOG(INFO) << "success, imsi " << imsi << " registering for IP address " << remote_host;
gSubscriberRegistry.imsiSet(imsi,"ipaddr", remote_host, "port", remote_port);
} else {
// look for rand and sres in Authorization header (assume imsi same as in from)
string randx;
string sres;
// sip parser is not working reliably for Authorization, so we'll do the parsing
char *RAND = strcasestr(buffer, "nonce=");
char *SRES = strcasestr(buffer, "response=");
if (RAND && SRES) {
// find RAND digits
RAND += 6;
while (!isalnum(*RAND)) { RAND++; }
RAND[32] = 0;
int j=0;
// FIXME -- These loops should use strspn instead.
while(isalnum(RAND[j])) { j++; }
RAND[j] = '\0';
// find SRES digits
SRES += 9;
while (!isalnum(*SRES)) { SRES++; }
int i=0;
// FIXME -- These loops should use strspn instead.
while(isalnum(SRES[i])) { i++; }
SRES[i] = '\0';
LOG(INFO) << "rand = /" << RAND << "/";
LOG(INFO) << "sres = /" << SRES << "/";
}
if (!RAND || !SRES) {
LOG(NOTICE) << "imsi " << imsi << " known, 1st register";
// no rand and sres => 401 Unauthorized
osip_message_set_status_code (response, 401);
osip_message_set_reason_phrase (response, osip_strdup("Unauthorized"));
// but include rand in www_authenticate
osip_www_authenticate_t *auth;
osip_www_authenticate_init(&auth);
// auth type is required by osip_www_authenticate_to_str (and therefore osip_message_to_str)
string auth_type = "Digest";
osip_www_authenticate_set_auth_type(auth, osip_strdup(auth_type.c_str()));
// returning RAND in www_authenticate header
string randz = generateRand(imsi);
osip_www_authenticate_set_nonce(auth, osip_strdup(randz.c_str()));
i = osip_list_add (&response->www_authenticates, auth, -1);
if (i < 0) LOG(ERR) << "problem adding www_authenticate";
} else {
string kc;
bool sres_good = authenticate(imsi, RAND, SRES, &kc);
LOG(INFO) << "imsi " << imsi << " known, 2nd register, good = " << sres_good;
//.........这里部分代码省略.........
示例8: main
int main(int argc, char *argv[])
{
srandom(time(NULL));
COUT("\n\n" << gOpenBTSWelcome << "\n");
COUT("\nStarting the system...");
gSetLogLevel(gConfig.getStr("LogLevel"));
if (gConfig.defines("LogFileName")) {
gSetLogFile(gConfig.getStr("LogFileName"));
}
// Start the transceiver binary, if the path is defined.
// If the path is not defined, the transceiver must be started by some other process.
const char *TRXPath = NULL;
if (gConfig.defines("TRX.Path")) TRXPath=gConfig.getStr("TRX.Path");
pid_t transceiverPid = 0;
if (TRXPath) {
const char *TRXLogLevel = gConfig.getStr("TRX.LogLevel");
const char *TRXLogFileName = NULL;
if (gConfig.defines("TRX.LogFileName")) TRXLogFileName=gConfig.getStr("TRX.LogFileName");
transceiverPid = vfork();
assert(transceiverPid>=0);
if (transceiverPid==0) {
execl(TRXPath,"transceiver",TRXLogLevel,TRXLogFileName,NULL);
LOG(ERROR) << "cannot start transceiver";
_exit(0);
}
}
// Start the SIP interface.
gSIPInterface.start();
// Start the transceiver interface.
gTRX.start();
// Set up the interface to the radio.
// Get a handle to the C0 transceiver interface.
ARFCNManager* radio = gTRX.ARFCN(0);
// Tuning.
// Make sure its off for tuning.
radio->powerOff();
// Set TSC same as BSC everywhere.
radio->setTSC(gBTS.BCC());
// Tune.
radio->tune(gConfig.getNum("GSM.ARFCN"));
// C-V on C0T0
radio->setSlot(0,5);
// Turn on and power up.
radio->powerOn();
radio->setPower(gConfig.getNum("GSM.PowerAttenDB"));
// set up a combination V beacon set
// SCH
SCHL1FEC SCH;
SCH.downstream(radio);
SCH.open();
// FCCH
FCCHL1FEC FCCH;
FCCH.downstream(radio);
FCCH.open();
// BCCH
BCCHL1FEC BCCH;
BCCH.downstream(radio);
BCCH.open();
// RACH
RACHL1FEC RACH(gRACHC5Mapping);
RACH.downstream(radio);
RACH.open();
// CCCHs
CCCHLogicalChannel CCCH0(gCCCH_0Mapping);
CCCH0.downstream(radio);
CCCH0.open();
CCCHLogicalChannel CCCH1(gCCCH_1Mapping);
CCCH1.downstream(radio);
CCCH1.open();
CCCHLogicalChannel CCCH2(gCCCH_2Mapping);
CCCH2.downstream(radio);
CCCH2.open();
// use CCCHs as AGCHs
gBTS.addAGCH(&CCCH0);
gBTS.addAGCH(&CCCH1);
gBTS.addAGCH(&CCCH2);
// C-V C0T0 SDCCHs
SDCCHLogicalChannel SDCCH[4] = {
SDCCHLogicalChannel(0,gSDCCH_4_0),
SDCCHLogicalChannel(0,gSDCCH_4_1),
SDCCHLogicalChannel(0,gSDCCH_4_2),
SDCCHLogicalChannel(0,gSDCCH_4_3)
};
Thread SDCCHControlThread[4];
for (int i=0; i<4; i++) {
SDCCH[i].downstream(radio);
SDCCHControlThread[i].start((void*(*)(void*))Control::DCCHDispatcher,&SDCCH[i]);
SDCCH[i].open();
gBTS.addSDCCH(&SDCCH[i]);
//.........这里部分代码省略.........
示例9: main
//.........这里部分代码省略.........
SDCCHLogicalChannel(0,0,gSDCCH_4_2),
SDCCHLogicalChannel(0,0,gSDCCH_4_3),
};
Thread C0T0SDCCHControlThread[4];
// Subchannel 2 used for CBCH if SMSCB enabled.
bool SMSCB = (gConfig.getStr("Control.SMSCB.Table").length() != 0);
CBCHLogicalChannel CBCH(gSDCCH_4_2);
Thread CBCHControlThread;
for (int i=0; i<4; i++) {
if (SMSCB && (i==2)) continue;
C0T0SDCCH[i].downstream(C0radio);
C0T0SDCCHControlThread[i].start((void*(*)(void*))Control::DCCHDispatcher,&C0T0SDCCH[i]);
C0T0SDCCH[i].open();
gBTS.addSDCCH(&C0T0SDCCH[i]);
}
// Install CBCH if used.
if (SMSCB) {
LOG(INFO) << "creating CBCH for SMSCB";
CBCH.downstream(C0radio);
CBCH.open();
gBTS.addCBCH(&CBCH);
CBCHControlThread.start((void*(*)(void*))Control::SMSCBSender,NULL);
}
//
// Configure the other slots.
//
// Count configured slots.
unsigned sCount = 1;
if (!gConfig.defines("GSM.Channels.NumC1s")) {
int numChan = numARFCNs*7;
LOG(CRIT) << "GSM.Channels.NumC1s not defined. Defaulting to " << numChan << ".";
gConfig.set("GSM.Channels.NumC1s",numChan);
}
if (!gConfig.defines("GSM.Channels.NumC7s")) {
int numChan = numARFCNs-1;
LOG(CRIT) << "GSM.Channels.NumC7s not defined. Defaulting to " << numChan << ".";
gConfig.set("GSM.Channels.NumC7s",numChan);
}
// sanity check on channel counts
// the clamp here could be improved to take the customer's current ratio of C1:C7 and scale it back to fit in the window
if (((numARFCNs * 8) - 1) < (gConfig.getNum("GSM.Channels.NumC1s") + gConfig.getNum("GSM.Channels.NumC7s"))) {
LOG(CRIT) << "scaling back GSM.Channels.NumC1s and GSM.Channels.NumC7s to fit inside number of available timeslots";
gConfig.set("GSM.Channels.NumC1s",numARFCNs*7);
gConfig.set("GSM.Channels.NumC7s",numARFCNs-1);
}
if (gConfig.getBool("GSM.Channels.C1sFirst")) {
// Create C-I slots.
for (int i=0; i<gConfig.getNum("GSM.Channels.NumC1s"); i++) {
gBTS.createCombinationI(gTRX,sCount/8,sCount%8);
sCount++;
}
}
// Create C-VII slots.
for (int i=0; i<gConfig.getNum("GSM.Channels.NumC7s"); i++) {
gBTS.createCombinationVII(gTRX,sCount/8,sCount%8);
sCount++;
}
示例10: main
//.........这里部分代码省略.........
CCCH1.downstream(C0radio);
CCCH1.open();
CCCHLogicalChannel CCCH2(gCCCH_2Mapping);
CCCH2.downstream(C0radio);
CCCH2.open();
// use CCCHs as AGCHs
gBTS.addAGCH(&CCCH0);
gBTS.addAGCH(&CCCH1);
gBTS.addAGCH(&CCCH2);
// C-V C0T0 SDCCHs
SDCCHLogicalChannel C0T0SDCCH[4] = {
SDCCHLogicalChannel(0,0,gSDCCH_4_0),
SDCCHLogicalChannel(0,0,gSDCCH_4_1),
SDCCHLogicalChannel(0,0,gSDCCH_4_2),
SDCCHLogicalChannel(0,0,gSDCCH_4_3),
};
Thread C0T0SDCCHControlThread[4];
for (int i=0; i<4; i++) {
C0T0SDCCH[i].downstream(C0radio);
C0T0SDCCHControlThread[i].start((void*(*)(void*))Control::DCCHDispatcher,&C0T0SDCCH[i]);
C0T0SDCCH[i].open();
gBTS.addSDCCH(&C0T0SDCCH[i]);
}
//
// Configure the other slots.
//
// Count configured slots.
unsigned sCount = 1;
if (gConfig.defines("GSM.Channels.C1sFirst")) {
// Create C-I slots.
for (int i=0; i<gConfig.getNum("GSM.Channels.NumC1s"); i++) {
gBTS.createCombinationI(gTRX,sCount/8,sCount%8);
sCount++;
}
}
// Create C-VII slots.
for (int i=0; i<gConfig.getNum("GSM.Channels.NumC7s"); i++) {
gBTS.createCombinationVII(gTRX,sCount/8,sCount%8);
sCount++;
}
if (!gConfig.defines("GSM.Channels.C1sFirst")) {
// Create C-I slots.
for (int i=0; i<gConfig.getNum("GSM.Channels.NumC1s"); i++) {
gBTS.createCombinationI(gTRX,sCount/8,sCount%8);
sCount++;
}
}
// Set up idle filling on C0 as needed.
while (sCount<8) {
gBTS.createCombination0(gTRX,sCount);
sCount++;
}
/*
Note: The number of different paging subchannels on
the CCCH is:
示例11: 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;
}
}
示例12: trx_setup_config
/* Setup configuration values
* Don't query the existence of the Log.Level because it's a
* mandatory value. That is, if it doesn't exist, the configuration
* table will crash or will have already crashed. Everything else we
* can survive without and use default values if the database entries
* are empty.
*/
bool trx_setup_config(struct trx_config *config)
{
std::string refstr, fillstr, divstr;
if (!testConfig())
return false;
if (config->log_level == "")
config->log_level = gConfig.getStr("Log.Level");
if (!config->port) {
if (gConfig.defines("TRX.Port"))
config->port = gConfig.getNum("TRX.Port");
else
config->port = DEFAULT_TRX_PORT;
}
if (config->addr == "") {
if (gConfig.defines("TRX.IP"))
config->addr = gConfig.getStr("TRX.IP");
else
config->addr = DEFAULT_TRX_IP;
}
if (!config->extref) {
if (gConfig.defines("TRX.Reference"))
config->extref = gConfig.getNum("TRX.Reference");
else
config->extref = DEFAULT_EXTREF;
}
if (!config->diversity) {
if (gConfig.defines("TRX.Diversity"))
config->diversity = gConfig.getNum("TRX.Diversity");
else
config->diversity = DEFAULT_DIVERSITY;
}
/* Diversity only supported on 2 channels */
if (config->diversity)
config->chans = 2;
refstr = config->extref ? "Enabled" : "Disabled";
divstr = config->diversity ? "Enabled" : "Disabled";
switch (config->filler) {
case Transceiver::FILLER_DUMMY:
fillstr = "Dummy bursts";
break;
case Transceiver::FILLER_ZERO:
fillstr = "Disabled";
break;
case Transceiver::FILLER_RAND:
fillstr = "Normal busrts with random payload";
break;
}
std::ostringstream ost("");
ost << "Config Settings" << std::endl;
ost << " Log Level............... " << config->log_level << std::endl;
ost << " Device args............. " << config->dev_args << std::endl;
ost << " TRX Base Port........... " << config->port << std::endl;
ost << " TRX Address............. " << config->addr << std::endl;
ost << " Channels................ " << config->chans << std::endl;
ost << " Samples-per-Symbol...... " << config->sps << std::endl;
ost << " External Reference...... " << refstr << std::endl;
ost << " C0 Filler Table......... " << fillstr << std::endl;
ost << " Diversity............... " << divstr << std::endl;
ost << " Tuning offset........... " << config->offset << std::endl;
ost << " RSSI to dBm offset...... " << config->rssi_offset << std::endl;
ost << " Swap channels........... " << config->swap_channels << std::endl;
std::cout << ost << std::endl;
return true;
}