本文整理汇总了C++中Messenger类的典型用法代码示例。如果您正苦于以下问题:C++ Messenger类的具体用法?C++ Messenger怎么用?C++ Messenger使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Messenger类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IOException
Notebook::Notebook() {
pugi::xml_node note = XmlInterface::get()->GetDocument()->child("Configuration").child("Notebook");
file_name_ = std::string(note.attribute("file").as_string());
mode_ = std::string(note.attribute("mode").as_string("a"));
Messenger m;
m.detail("Notebook: " + file_name_ + " mode: " + mode_);
std::ofstream note_file;
if (mode_ == "r") {
note_file.open(file_name_.c_str(), std::ios::out);
} else if (mode_ == "a") {
note_file.open(file_name_.c_str(), std::ios::out | std::ios::app);
} else {
std::stringstream ss;
ss << "Notebook: unknown mode";
ss << " : " << mode_;
throw IOException(ss.str());
}
if (!note_file.good()) {
std::stringstream ss;
ss << "Notebook: error opening output file";
ss << " : " << file_name_;
throw IOException(ss.str());
}
note_file << "# Starting notebook on : " << currentDateTime() << std::endl;
note_file.close();
}
示例2: ReadCalXml
void DetectorDriver::Init(RawEvent& rawev) {
for (vector<TraceAnalyzer *>::iterator it = vecAnalyzer.begin();
it != vecAnalyzer.end(); it++) {
(*it)->Init();
(*it)->SetLevel(20);
}
for (vector<EventProcessor *>::iterator it = vecProcess.begin();
it != vecProcess.end(); it++) {
(*it)->Init(rawev);
}
try {
ReadCalXml();
ReadWalkXml();
} catch (GeneralException &e) {
//! Any exception in reading calibration and walk correction
//! will be intercepted here
cout << endl;
cout << "Exception caught at DetectorDriver::Init" << endl;
cout << "\t" << e.what() << endl;
Messenger m;
m.fail();
exit(EXIT_FAILURE);
} catch (GeneralWarning &w) {
cout << "Warning caught at DetectorDriver::Init" << endl;
cout << "\t" << w.what() << endl;
}
}
示例3: userAddTest
static void userAddTest(Node& node, TestRunner& tr)
{
tr.group("user add");
Messenger* messenger = node.getMessenger();
tr.test("add (valid)");
{
Url url("/api/3.0/users");
// password update
User user;
user["email"] = "[email protected]";
user["username"] = "testuser1";
user["password"] = "password";
user["confirm"] = "password";
user["tosAgree"] = "agree";
assertNoException(
messenger->postSecureToBitmunk(
&url, &user, NULL, node.getDefaultUserId()));
printf("\nUser added.\n");
}
tr.passIfNoException();
tr.ungroup();
}
示例4: BM_USER_ID
void DownloadStateEventReactor::directiveCreated(Event& e)
{
UserId userId = BM_USER_ID(e["details"]["userId"]);
const char* directiveId = e["details"]["directiveId"]->getString();
MO_CAT_DEBUG(BM_EVENTREACTOR_DS_CAT,
"Event reactor handling 'directiveCreated' event for user %" PRIu64 "...",
userId);
// process the directive if it is of type "peerbuy":
DynamicObject& directive = e["details"]["directive"];
if(strcmp(directive["type"]->getString(), "peerbuy") == 0)
{
Messenger* messenger = mNode->getMessenger();
Url url;
url.format("%s/api/3.0/system/directives/process/%s?nodeuser=%" PRIu64,
messenger->getSelfUrl(true).c_str(), directiveId, userId);
DynamicObject in;
if(!messenger->post(&url, NULL, &in, userId))
{
// schedule exception event
Event e2;
e2["type"] = "bitmunk.eventreactor.EventReactor.exception";
e2["details"]["userId"] = userId;
e2["details"]["exception"] = Exception::getAsDynamicObject();
mNode->getEventController()->schedule(e2);
}
}
}
示例5: SanityCheck
void Globals::SanityCheck() {
Messenger m;
std::stringstream ss;
if (!(revision_ == "A" || revision_ == "D" || revision_ == "F")) {
ss << "Globals: unknown revision version named "
<< revision_;
throw GeneralException(ss.str());
}
if (clockInSeconds_ <= 0) {
ss << "Globals: illegal value of clockInSeconds "
<< clockInSeconds_;
throw GeneralException(ss.str());
}
if (adcClockInSeconds_ <= 0) {
ss << "Globals: illegal value of adcClockInSeconds "
<< adcClockInSeconds_;
throw GeneralException(ss.str());
}
if (filterClockInSeconds_ <= 0) {
ss << "Globals: illegal value of filterClockInSeconds "
<< filterClockInSeconds_;
throw GeneralException(ss.str());
}
if (eventInSeconds_ <= 0) {
ss << "Globals: illegal value of eventInSeconds "
<< eventInSeconds_;
throw GeneralException(ss.str());
}
if (hasReject_) {
ss << "Total number of rejection regions: " << reject_.size();
m.detail(ss.str());
} else {
ss << "Not using rejection regions";
m.detail(ss.str());
}
ss.str("");
if (energyContraction_ <= 0) {
ss << "Globals: Surely you don't want to use Energy contraction = "
<< energyContraction_ << ". I'd better stop the program.";
throw GeneralException(ss.str());
} else {
ss << "Energy contraction: " << energyContraction_;
m.detail(ss.str());
}
m.done();
}
示例6: split_names
void TreeCorrelator::createPlace(std::map<std::string, std::string>& params,
bool verbose) {
bool replace = false;
if (params["replace"] != "")
replace = strings::to_bool(params["replace"]);
vector<string> names = split_names(params["name"]);
for (vector<string>::iterator it = names.begin();
it != names.end();
++it) {
if (params["type"] != "") {
if (replace) {
if (places_.count((*it)) != 1) {
stringstream ss;
ss << "TreeCorrelator: cannot replace Place " << (*it)
<< ", it doesn't exist";
throw TreeCorrelatorException(ss.str());
}
delete places_[(*it)];
if (verbose) {
Messenger m;
stringstream ss;
ss << "Replacing place " << (*it);
m.detail(ss.str(), 1);
}
} else {
if (places_.count((*it)) == 1) {
stringstream ss;
ss << "TreeCorrelator: place" << (*it) << " already exists";
throw TreeCorrelatorException(ss.str());
}
if (verbose) {
Messenger m;
stringstream ss;
ss << "Creating place " << (*it);
m.detail(ss.str(), 1);
}
}
Place* current = builder.create(params, verbose);
places_[(*it)] = current;
if (strings::to_bool(params["init"]))
current->activate(0.0);
}
if (params["parent"] != "root") {
bool coincidence = strings::to_bool(params["coincidence"]);
addChild(params["parent"], (*it), coincidence, verbose);
}
}
}
示例7: contributorGetTest
static void contributorGetTest(Node& node, TestRunner& tr)
{
tr.group("contributors");
Messenger* messenger = node.getMessenger();
tr.test("id");
{
Url url("/api/3.0/contributors/1");
// get contributor
DynamicObject contributor;
assertNoException(
messenger->getFromBitmunk(&url, contributor));
printf("\nContributor:\n");
dumpDynamicObject(contributor, false);
}
tr.passIfNoException();
tr.test("owner");
{
Url url("/api/3.0/contributors/?owner=900");
// get contributor
DynamicObject contributors;
assertNoException(
messenger->getFromBitmunk(&url, contributors));
printf("\nContributors:\n");
dumpDynamicObject(contributors, false);
}
tr.passIfNoException();
tr.test("media");
{
Url url("/api/3.0/contributors/?media=1");
// get contributor
DynamicObject contributors;
assertNoException(
messenger->getFromBitmunk(&url, contributors));
printf("\nContributors:\n");
dumpDynamicObject(contributors, false);
}
tr.passIfNoException();
tr.ungroup();
}
示例8: l_Messenger_retrieveMessages
static int l_Messenger_retrieveMessages(lua_State *L) {
Messenger* messenger = nullptr;
if (lua_hasMessenger(L)) {
messenger = lua_getMessenger(L);
}
else {
luaL_error(L, "Messenger has not been registered in lua");
}
auto messageVector = messenger->retrieveMessages();
lua_newtable(L);
int index = 1;
for (auto msg : messageVector) {
lua_pushmessage(L, &msg);
lua_rawseti(L, -1, index++);
}
return 1;
}
示例9: place
void TreeCorrelator::addChild(std::string parent, std::string child,
bool coin, bool verbose) {
if (places_.count(parent) == 1 && places_.count(child) == 1) {
place(parent)->addChild(place(child), coin);
if (verbose) {
Messenger m;
stringstream ss;
ss << "Setting " << child
<< " as a child of " << parent;
m.detail(ss.str(), 1);
}
} else {
stringstream ss;
ss << "TreeCorrelator: could not set " << child
<< " as a child of " << parent << endl;
throw TreeCorrelatorException(ss.str());
}
}
示例10: pingPerfTest
static void pingPerfTest(Node& node, TestRunner& tr)
{
tr.group("ping perf");
Messenger* messenger = node.getMessenger();
// number of loops for each test
Config cfg = tr.getApp()->getConfig();
//node.getConfigManager()->getConfig(
// tester->getApp()->getMetaConfig()["groups"]["main"]->getString());
int n = cfg->hasMember("loops") ? cfg["loops"]->getInt32() : 50;
tr.test("insecure get");
{
Url url("/api/3.0/system/test/ping");
DynamicObject dummy;
uint64_t startTime = Timer::startTiming();
for(int i = 0; i < n; ++i)
{
messenger->getFromBitmunk(&url, dummy);
}
double dt = Timer::getSeconds(startTime);
printf("t=%g ms, r=%g ms, r/s=%g", dt * 1000.0, dt/n * 1000.0, n/dt);
}
tr.passIfNoException();
tr.test("secure get");
{
Url url("/api/3.0/system/test/ping");
DynamicObject dummy;
uint64_t startTime = Timer::startTiming();
for(int i = 0; i < n; ++i)
{
messenger->getSecureFromBitmunk(&url, dummy, node.getDefaultUserId());
}
double dt = Timer::getSeconds(startTime);
printf("t=%g ms, r=%g ms, r/s=%g", dt * 1000.0, dt/n * 1000.0, n/dt);
}
tr.passIfNoException();
tr.ungroup();
}
示例11: histo
DetectorDriver::DetectorDriver() : histo(OFFSET, RANGE, "DetectorDriver") {
Messenger m;
try {
m.start("Loading Processors");
LoadProcessors(m);
} catch (GeneralException &e) {
/// Any exception in registering plots in Processors
/// and possible other exceptions in creating Processors
/// will be intercepted here
m.fail();
cout << "Exception caught at DetectorDriver::DetectorDriver" << endl;
cout << "\t" << e.what() << endl;
exit(EXIT_FAILURE);
} catch (GeneralWarning &w) {
cout << "Warning found at DetectorDriver::DetectorDriver" << endl;
cout << "\t" << w.what() << endl;
}
m.done();
}
示例12: _doReverseNetTest
static bool _doReverseNetTest(
Node* node, Config& cfg, UserId userId, const char* token,
string& serverUrl)
{
bool rval = false;
// start creating public server URL
serverUrl = "https://";
// setup post data, use blank host to indicate to the reverse netaccess
// service that our public IP should be used in the netaccess test
// use a 15 seconds timeout in waiting for a response
DynamicObject out;
out["host"] = "";
out["port"] = cfg["port"];
out["path"] = "/api/3.0/catalog/netaccess/test";
out["sellerId"] = userId;
out["token"] = token;
out["timeout"] = 15;
DynamicObject in;
// post to bitmunk
Url url;
url.format("/api/3.0/catalog/netaccess/rtest");
Messenger* m = node->getMessenger();
if(m->postSecureToBitmunk(&url, &out, &in, userId))
{
rval = true;
serverUrl.append(in["ip"]->getString());
serverUrl.push_back(':');
serverUrl.append(cfg["port"]->getString());
// send event
Event ev;
ev["type"] = EVENT_NET_ACCESS_SUCCESS;
ev["details"]["userId"] = userId;
ev["details"]["serverUrl"] = serverUrl.c_str();
node->getEventController()->schedule(ev);
}
return rval;
}
示例13: accountGetPerfTest
static void accountGetPerfTest(Node& node, TestRunner& tr)
{
tr.group("accounts perf");
Messenger* messenger = node.getMessenger();
// number of loops
int n = 25;
tr.test("insecure get");
{
Url url("/api/3.0/accounts/?owner=900");
uint64_t startTime = Timer::startTiming();
for(int i = 0; i < n; ++i)
{
User user;
messenger->getFromBitmunk(&url, user);
}
double dt = Timer::getSeconds(startTime);
printf("t=%g ms, r=%g ms, r/s=%g", dt * 1000.0, dt/n * 1000.0, n/dt);
}
tr.passIfNoException();
tr.test("secure get");
{
Url url("/api/3.0/accounts/?owner=900");
uint64_t startTime = Timer::startTiming();
for(int i = 0; i < n; ++i)
{
User user;
messenger->getFromBitmunk(&url, user, node.getDefaultUserId());
}
double dt = Timer::getSeconds(startTime);
printf("t=%g ms, r=%g ms, r/s=%g", dt * 1000.0, dt/n * 1000.0, n/dt);
}
tr.passIfNoException();
tr.ungroup();
}
示例14: accountGetTest
static void accountGetTest(Node& node, TestRunner& tr)
{
tr.group("accounts");
Messenger* messenger = node.getMessenger();
tr.test("get");
{
Url url("/api/3.0/accounts/?owner=900");
// get all accounts
User user;
messenger->getSecureFromBitmunk(&url, user, node.getDefaultUserId());
printf("\nAccounts:\n");
dumpDynamicObject(user);
}
tr.passIfNoException();
tr.ungroup();
tr.group("account");
tr.test("get");
{
// create url for obtaining users
Url url("/api/3.0/accounts/9000");
// get account
Account account;
assertNoException(
messenger->getSecureFromBitmunk(
&url, account, node.getDefaultUserId()));
printf("\nAccount:\n");
dumpDynamicObject(account, false);
}
tr.passIfNoException();
tr.ungroup();
}
示例15: reviewGetTest
static void reviewGetTest(Node& node, TestRunner& tr)
{
tr.group("reviews");
Messenger* messenger = node.getMessenger();
tr.test("user get");
{
// create url for obtaining user reviews
Url url("/api/3.0/reviews/user/900");
// get account
DynamicObject reviews;
assertNoException(
messenger->getSecureFromBitmunk(
&url, reviews, node.getDefaultUserId()));
printf("\nReviews:\n");
dumpDynamicObject(reviews, false);
}
tr.passIfNoException();
tr.test("media get");
{
// create url for obtaining media reviews
Url url("/api/3.0/reviews/media/1");
// get account
DynamicObject reviews;
assertNoException(
messenger->getSecureFromBitmunk(
&url, reviews, node.getDefaultUserId()));
printf("\nReviews:\n");
dumpDynamicObject(reviews, false);
}
tr.passIfNoException();
tr.ungroup();
}