本文整理汇总了C++中communicator函数的典型用法代码示例。如果您正苦于以下问题:C++ communicator函数的具体用法?C++ communicator怎么用?C++ communicator使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了communicator函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: LINFO
bool RobotBrainServiceService::start(int argc, char* argv[])
{
char adapterStr[255];
LINFO("Creating Topic!");
//Create the topics
// SimEventsUtils::createTopic(communicator(), "RetinaMessageTopic");
//Create the adapter
int port = RobotBrainObjects::RobotBrainPort;
bool connected = false;
LDEBUG("Opening Connection");
while(!connected)
{
try
{
LINFO("Trying Port:%d", port);
sprintf(adapterStr, "default -p %i", port);
itsAdapter = communicator()->createObjectAdapterWithEndpoints("Retina",
adapterStr);
connected = true;
}
catch(Ice::SocketException)
{
port++;
}
}
//Create the manager and its objects
itsMgr = new ModelManager("RetinaService");
LINFO("Starting Retina");
nub::ref<RetinaI> ret(new RetinaI(0, *itsMgr, "Retina1", "Retina2"));
LINFO("Retina Created");
itsMgr->addSubComponent(ret);
LINFO("Retina Added As Sub Component");
ret->init(communicator(), itsAdapter);
LINFO("Retina Inited");
itsMgr->parseCommandLine((const int)argc, (const char**)argv, "", 0, 0);
itsAdapter->activate();
itsMgr->start();
return true;
}
开发者ID:ulyssesrr,项目名称:carmen_lcad,代码行数:48,代码来源:test-Retina.C
示例2: BOOST_MPI_CHECK_RESULT
communicator communicator::split(int color, int key) const
{
MPI_Comm newcomm;
BOOST_MPI_CHECK_RESULT(MPI_Comm_split,
(MPI_Comm(*this), color, key, &newcomm));
return communicator(newcomm, comm_take_ownership);
}
开发者ID:AsherBond,项目名称:PDAL,代码行数:7,代码来源:communicator.cpp
示例3: appName
int HelloServer::run(int argc, char* argv[])
{
if (argc > 1)
{
std::cerr << appName() << ": too many arguments" << std::endl;
return EXIT_FAILURE;
}
Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Hello");
Demo::HelloPtr hello = new HelloI;
adapter->add(hello, communicator()->stringToIdentity("hello"));
adapter->activate();
communicator()->waitForShutdown();
return EXIT_SUCCESS;
}
开发者ID:jim-yefeng,项目名称:redwine,代码行数:16,代码来源:Server.cpp
示例4: main
int main(int argc, char *argv[])
{
int const port = 8888;
QApplication app(argc, argv);
QString configPath = "./";
if (app.arguments().contains("-c")) {
int const index = app.arguments().indexOf("-c");
if (app.arguments().count() <= index + 1) {
qDebug() << "Usage: ./trikServer [-c <config file path>]";
return 1;
}
configPath = app.arguments()[index + 1];
if (configPath.right(1) != "/") {
configPath += "/";
}
}
qDebug() << "Running TrikServer on port" << port;
trikCommunicator::TrikCommunicator communicator(configPath);
communicator.listen(port);
return app.exec();
}
开发者ID:Esenin,项目名称:trikRuntime,代码行数:27,代码来源:main.cpp
示例5: preciceTrace2
void MPIPortsCommunication:: requestConnection
(
const std::string& nameAcceptor,
const std::string& nameRequester,
int requesterProcessRank,
int requesterCommunicatorSize )
{
preciceTrace2 ( "requestConnection()", nameAcceptor, nameRequester );
assertion ( not _isConnection );
int argc = 1;
char* arg = new char[8];
strcpy(arg, "precice");
char** argv = &arg;
utils::Parallel::initialize ( &argc, &argv, nameRequester );
delete[] arg;
std::string portFilename(_publishingDirectory + "." + nameRequester + "-portname");
std::ifstream inFile;
do {
inFile.open ( portFilename.c_str(), std::ios::in );
usleep(100000);
} while ( not inFile );
inFile.getline ( _portname, MPI_MAX_PORT_NAME );
inFile.close();
preciceDebug ( "Read connection info \"" + std::string(_portname) +
"\" from file " + portFilename );
preciceDebug("Calling MPI_Comm_connect() with portname = " << _portname);
MPI_Comm localComm = utils::Parallel::getLocalCommunicator();
MPI_Comm_connect ( _portname, MPI_INFO_NULL, 0, localComm, &communicator() );
_isConnection = true;
}
开发者ID:Alexander-Shukaev,项目名称:precice,代码行数:32,代码来源:MPIPortsCommunication.cpp
示例6: main
int main(int argc, char *argv[])
{
const int port = 8888;
QApplication app(argc, argv);
app.setApplicationName("TrikServer");
trikKernel::ApplicationInitHelper initHelper(app);
if (!initHelper.parseCommandLine()) {
return 0;
}
initHelper.init();
QLOG_INFO() << "TrikServer started on port" << port;
qDebug() << "Running TrikServer on port" << port;
QScopedPointer<trikControl::BrickInterface> brick(trikControl::BrickFactory::create(
initHelper.configPath(), trikKernel::Paths::mediaPath()));
trikKernel::Configurer configurer(
initHelper.configPath() + "/system-config.xml"
, initHelper.configPath() + "/model-config.xml"
);
QScopedPointer<trikNetwork::MailboxInterface> mailbox(trikNetwork::MailboxFactory::create(configurer));
trikCommunicator::TrikCommunicator communicator(*brick, mailbox.data());
communicator.startServer(port);
return app.exec();
}
开发者ID:Kseniya-Gonta,项目名称:trikRuntime,代码行数:32,代码来源:trikServerMain.cpp
示例7: communicator
bool Application::configGetBool (const std::string name, bool &value, const int default_value)
{
string tmp;
tmp = communicator()->getProperties()->getProperty( name );
if ( tmp.length() == 0 )
{
if (default_value != -1)
{
std::cout << name << " property does not exist. Using default value." << std::endl;
value = default_value;
return false;
}
else
{
printf("Can't read configuration parameter %s. Got %s.", name.c_str(), tmp.c_str());
qFatal("Error\n");
}
}
if(tmp == "true" or tmp == "True" or tmp == "yes" or tmp == "Yes" or tmp == "1")
{
value = true;
}
else if (tmp == "false" or tmp == "False" or tmp == "no" or tmp == "No" or tmp == "0")
{
value = false;
}
else
{
qFatal("Reading config file: '%s' is not a valid boolean", name.c_str());
}
std::cout << name << " " << value << std::endl;
return true;
}
开发者ID:BasilMVarghese,项目名称:robocomp,代码行数:33,代码来源:rapplication.cpp
示例8: localFiles
void QUHttpCollector::processNetworkOperationDone(bool error) {
int count = localFiles().size();
closeLocalFiles();
if(error) {
setState(Idle);
communicator()->send(http()->errorString());
communicator()->send(QUCommunicatorInterface::Failed);
return;
}
if(state() == SearchRequest) {
ignoredUrls = 0;
processSearchResults();
} else if(state() == ImageRequest)
processImageResults(count);
}
开发者ID:escaped,项目名称:uman,代码行数:17,代码来源:QUHttpCollector.cpp
示例9: getRemoteCommunicatorSize
int MPIPortsCommunication:: getRemoteCommunicatorSize()
{
preciceTrace ( "getRemoteCommunicatorSize()" );
assertion ( _isConnection );
int remoteSize = 0;
MPI_Comm_remote_size ( communicator(), &remoteSize );
return remoteSize;
}
开发者ID:Alexander-Shukaev,项目名称:precice,代码行数:8,代码来源:MPIPortsCommunication.cpp
示例10: UTIL_THROW
/*
* Read and execute commands from a specified command file.
*/
void McSimulation::readCommands(std::istream &in)
{
if (!isInitialized_) {
UTIL_THROW("McSimulation is not initialized");
}
std::string command;
std::string filename;
std::ifstream inputFile;
std::ofstream outputFile;
#ifndef UTIL_MPI
std::istream& inBuffer = in;
#else
std::stringstream inBuffer;
std::string line;
#endif
bool readNext = true;
while (readNext) {
// iffdef UTIL_MPI, read a line and copy to stringstream inBuffer
// ifndef UTIL_MPI, inBuffer is simply a reference to istream in.
#ifdef UTIL_MPI
// Read a command line, and broadcast if necessary.
if (!hasIoCommunicator() || isIoProcessor()) {
getNextLine(in, line);
}
if (hasIoCommunicator()) {
bcast<std::string>(communicator(), line, 0);
}
// Copy the command line to inBuffer.
inBuffer.clear();
for (unsigned i=0; i < line.size(); ++i) {
inBuffer.put(line[i]);
}
#endif
inBuffer >> command;
Log::file() << command;
if (isRestarting_) {
if (command == "RESTART") {
int endStep;
inBuffer >> endStep;
Log::file() << " " << iStep_ << " to "
<< endStep << std::endl;
simulate(endStep, isRestarting_);
isRestarting_ = false;
} else {
UTIL_THROW("Missing RESTART command");
}
} else {
开发者ID:TaherGhasimakbari,项目名称:simpatico,代码行数:60,代码来源:McSimulation.cpp
示例11: run
virtual int run(int argc, char* argv[])
{
ClientOrServer::run(argc, argv);
// Register a new object adapter
Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("SonarEventListener.Subscriber");
// Subscribe to the event
IceStorm::QoS qos;
Ice::ObjectPrx subscriber = adapter->addWithUUID(new SonarEventPrinter);
sonarTopic->subscribe(qos, subscriber);
// Start the adapter and keep going until the program is killed
adapter->activate();
shutdownOnInterrupt();
communicator()->waitForShutdown();
sonarTopic->unsubscribe(subscriber);
return EXIT_SUCCESS;
}
开发者ID:ChrisCarlsen,项目名称:tortuga,代码行数:19,代码来源:client.cpp
示例12: duplicate
void
diy::mpi::communicator::
duplicate(const communicator& other)
{
#ifndef DIY_NO_MPI
MPI_Comm newcomm;
MPI_Comm_dup(other.comm_, &newcomm);
(*this) = std::move(communicator(newcomm,true));
#endif
}
开发者ID:ElsevierSoftwareX,项目名称:SOFTX-D-15-00004,代码行数:10,代码来源:communicator.hpp
示例13: shutdownOnInterrupt
int Server::run(int argc, char* argv[])
{
int ret;
if ((ret = SPI_init())) return ret;
shutdownOnInterrupt();
Ice::ObjectAdapterPtr adapter = communicator()->
createObjectAdapterWithEndpoints("Guitar", "default -p 10000");
guitarlib::ApplicationI *app = new guitarlib::ApplicationI(adapter);
adapter->add(app, communicator()->stringToIdentity("Application"));
adapter->activate();
communicator()->waitForShutdown();
ret = SPI_exit();
return ret;
}
开发者ID:swidge,项目名称:iPhoneGUITAR,代码行数:19,代码来源:main.cpp
示例14: communicator
int ClientApp::initializeDetector(cvac::DetectorPrx detector)
{
cvac::DetectorData detectorData;
cvac::localAndClientMsg(VLogger::DEBUG, NULL, "Client using Detector-name: %s\n", detector->ice_getIdentity().name.c_str());
detectorData.type = ::cvac::FILE;
// If a detector dat file was passed then use that instead of getting it from the config file
if (m_detectorData.length() > 0)
{
detectorData.file.directory.relativePath = cvac::getFilePath(m_detectorData);
detectorData.file.filename = cvac::getFileName(m_detectorData);
}
else
{ // Determine which data files to pass as detector data based on .DetectorFilename in 'config.client'
std::string filenameStr = m_detectorName + ".DetectorFilename";
Ice::PropertiesPtr props = communicator()->getProperties();
std::string filename = props->getProperty(filenameStr);
if (filename.length() == 0)
{
cvac::localAndClientMsg(VLogger::WARN, NULL, "No .DetectorFilename pair found for %s.\n", m_detectorName.c_str());
return EXIT_FAILURE;
}
if ((filename.length() > 1 && filename[1] == ':' )||
filename[0] == '/' ||
filename[0] == '\\')
{ // absolute path
int idx = filename.find_last_of('/');
detectorData.file.directory.relativePath = filename.substr(0, idx);
detectorData.file.filename = filename.substr(idx+1, filename.length() - idx);
}
else
{ //Add the current directory
detectorData.file.directory.relativePath = "DefaultDetectors";
detectorData.file.filename = filename;
}
}
try
{
cvac::localAndClientMsg(VLogger::INFO, NULL, "Initializing detector with relativePath: %s\n", detectorData.file.directory.relativePath.c_str());
cvac::localAndClientMsg(VLogger::INFO, NULL, "Initializing detector with filename: %s\n", detectorData.file.filename.c_str());
detector->initialize(5, detectorData);
cvac::localAndClientMsg(VLogger::DEBUG, NULL, "IceBox test client: initialized the detector\n");
}
catch (const Ice::Exception& ex)
{
cvac::localAndClientMsg(VLogger::WARN, NULL, "Ice- name(): %s\n", ex.ice_name().c_str());
cvac::localAndClientMsg(VLogger::WARN, NULL, "Ice- stackTrace(): \n%s\n", ex.ice_stackTrace().c_str());
cvac::localAndClientMsg(VLogger::WARN, NULL, "%s\n", ex.what());
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
开发者ID:sorflex,项目名称:CVAC_core,代码行数:55,代码来源:Client.cpp
示例15: QFile
QFile* QUHttpCollector::openLocalFile(const QString &filePath) {
QFile *file = new QFile(filePath, this);
if(!file->open(QIODevice::WriteOnly | QIODevice::Truncate)) {
communicator()->send(tr("Could not open local file: \"%1\"").arg(filePath));
return 0;
}
_localFiles.append(file);
return file;
}
开发者ID:escaped,项目名称:uman,代码行数:11,代码来源:QUHttpCollector.cpp
示例16: main
int main(int argc, char** argv) {
// Random seed
#ifdef _WIN32
srand(123456);
#else
srandom(123456);
#endif
// Client or server mode?
char* modeString = getOption(argc, argv, "-m");
CommunicatorMode mode = COMMUNICATOR_MODE_NONE;
if (!strcmp(modeString, "client"))
mode = COMMUNICATOR_MODE_CLIENT;
else if (!strcmp(modeString, "server"))
mode = COMMUNICATOR_MODE_SERVER;
else
printUsageAndExit(argv[0]);
// Declare our timeline. It will be initialized by the Communicator.
Timeline timeline;
// Declare our communicator
Communicator communicator(timeline, mode);
// If we're a client, who are we connecting to?
if (mode == COMMUNICATOR_MODE_CLIENT)
communicator.SetServer(getOption(argc, argv, "-s"));
// Otherwise, how many clients are we waiting for?
else {
int numClients = atoi(getOption(argc, argv, "-n"));
if (numClients < 0)
printUsageAndExit(argv[0]);
communicator.SetNumClientsExpected((unsigned) numClients);
}
// Start background music
sf::Music Music;
if (!Music.OpenFromFile("scenefiles/bgm.ogg"))
{
std::cout << "Error loading music file\n";
}
Music.SetLoop(true);
Music.Play();
Game growblesGame(timeline, communicator);
growblesGame.Setup();
return 0;
}
开发者ID:fanfreeman,项目名称:growbles,代码行数:51,代码来源:Main.cpp
示例17: PetscObjectGetComm
void PetscPreconditioner<T>::set_petsc_subpreconditioner_type(const PCType type, PC& pc)
#endif
{
// For catching PETSc error return codes
int ierr = 0;
// get the communicator from the PETSc object
Parallel::communicator comm;
PetscObjectGetComm((PetscObject)pc, &comm);
Parallel::Communicator communicator(comm);
// All docs say must call KSPSetUp or PCSetUp before calling PCBJacobiGetSubKSP.
// You must call PCSetUp after the preconditioner operators have been set, otherwise you get the:
//
// "Object is in wrong state!"
// "Matrix must be set first."
//
// error messages...
ierr = PCSetUp(pc);
CHKERRABORT(comm,ierr);
// To store array of local KSP contexts on this processor
KSP* subksps;
// the number of blocks on this processor
PetscInt n_local;
// The global number of the first block on this processor.
// This is not used, so we just pass PETSC_NULL instead.
// int first_local;
// Fill array of local KSP contexts
ierr = PCBJacobiGetSubKSP(pc, &n_local, PETSC_NULL, &subksps);
CHKERRABORT(comm,ierr);
// Loop over sub-ksp objects, set ILU preconditioner
for (PetscInt i=0; i<n_local; ++i)
{
// Get pointer to sub KSP object's PC
PC subpc;
ierr = KSPGetPC(subksps[i], &subpc);
CHKERRABORT(comm,ierr);
// Set requested type on the sub PC
ierr = PCSetType(subpc, type);
CHKERRABORT(comm,ierr);
}
}
开发者ID:ZJLi2013,项目名称:libmesh,代码行数:49,代码来源:petsc_preconditioner.C
示例18: configGetFloat
bool Application::configGetFloat( const std::string name, float &value, const float default_value, QList< int > *list )
{
QString tmp;
tmp = QString::fromStdString(communicator()->getProperties()->getProperty( name ));
if ( tmp.length() == 0)
{
std::cout << name << " property does not exist. Using default value." << std::endl;
value = default_value;
return false;
}
value = tmp.toFloat();
if(list != NULL)
{
if (list->contains(value) == false)
{
qFatal("Reading config file: '%s' is not a valid float", name.c_str());
}
}
std::cout << name << " " << value << std::endl;
return true;
}
开发者ID:BasilMVarghese,项目名称:robocomp,代码行数:22,代码来源:rapplication.cpp
示例19: all_reduce
template<typename T, typename Op> inline void all_reduce(const Op& op, const std::vector<T>& in_values, const std::vector<int>& in_map, std::vector<T>& out_values, const std::vector<int>& out_map, const int stride=1)
{
mpi::all_reduce(communicator(), op, in_values, in_map, out_values, out_map, stride);
}
开发者ID:andrealani,项目名称:coolfluid3,代码行数:4,代码来源:PE.hpp
示例20: communicator
void QUHttpCollector::processNetworkStateChange(int state) {
if(state == QHttp::Sending)
communicator()->send(tr("Sending..."));
else if(state == QHttp::Reading)
communicator()->send(tr("Reading..."));
}
开发者ID:escaped,项目名称:uman,代码行数:6,代码来源:QUHttpCollector.cpp
注:本文中的communicator函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论