本文整理汇总了C++中ice::CommunicatorPtr::createObjectAdapterWithEndpoints方法的典型用法代码示例。如果您正苦于以下问题:C++ CommunicatorPtr::createObjectAdapterWithEndpoints方法的具体用法?C++ CommunicatorPtr::createObjectAdapterWithEndpoints怎么用?C++ CommunicatorPtr::createObjectAdapterWithEndpoints使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ice::CommunicatorPtr
的用法示例。
在下文中一共展示了CommunicatorPtr::createObjectAdapterWithEndpoints方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: uncheckedCast
RemoteObjectAdapterPrx
RemoteCommunicatorI::createObjectAdapter(int timeout, int close, int heartbeat, const Current& current)
{
Ice::CommunicatorPtr com = current.adapter->getCommunicator();
Ice::PropertiesPtr properties = com->getProperties();
string protocol = properties->getPropertyWithDefault("Ice.Default.Protocol", "tcp");
string host = properties->getPropertyWithDefault("Ice.Default.Host", "127.0.0.1");
string name = IceUtil::generateUUID();
if(timeout >= 0)
{
properties->setProperty(name + ".ACM.Timeout", toString(timeout));
}
if(close >= 0)
{
properties->setProperty(name + ".ACM.Close", toString(close));
}
if(heartbeat >= 0)
{
properties->setProperty(name + ".ACM.Heartbeat", toString(heartbeat));
}
properties->setProperty(name + ".ThreadPool.Size", "2");
ObjectAdapterPtr adapter = com->createObjectAdapterWithEndpoints(name, protocol + " -h \"" + host + "\"");
return RemoteObjectAdapterPrx::uncheckedCast(current.adapter->addWithUUID(new RemoteObjectAdapterI(adapter)));
}
示例2: main
int main(int argc, char* argv[])
{
int status = 0;
Ice::CommunicatorPtr ic;
try {
ic = Ice::initialize(argc, argv);
Ice::ObjectAdapterPtr adapter
= ic->createObjectAdapterWithEndpoints("lcdshow", "default -p 10000");
ram::tortuga::SensorBoardI* board = new ram::tortuga::SensorBoardI();
// Check if the board initialized correctly
if (board->isInitialized()) {
Ice::ObjectPtr object = board;
adapter->add(object, ic->stringToIdentity("SensorBoard"));
adapter->activate();
ic->waitForShutdown();
}
delete board;
} catch (const Ice::Exception& e) {
std::cerr << e << std::endl;
status = 1;
} catch (const char* msg) {
std::cerr << msg << std::endl;
status = 1;
}
if (ic) {
try {
ic->destroy();
} catch (const Ice::Exception& e) {
std::cerr << e << std::endl;
status = 1;
}
}
return status;
}
示例3: ICE_UNCHECKED_CAST
RemoteObjectAdapterPrx
RemoteCommunicatorI::createObjectAdapter(const string& name, const string& endpts, const Current& current)
#endif
{
Ice::CommunicatorPtr com = current.adapter->getCommunicator();
const string defaultProtocol = com->getProperties()->getProperty("Ice.Default.Protocol");
string endpoints = endpts;
if(defaultProtocol != "bt")
{
if(endpoints.find("-p") == string::npos)
{
// Use a fixed port if none is specified (bug 2896)
ostringstream os;
os << endpoints << " -h \""
<< (com->getProperties()->getPropertyWithDefault("Ice.Default.Host", "127.0.0.1"))
<< "\" -p " << _nextPort++;
endpoints = os.str();
}
}
com->getProperties()->setProperty(name + ".ThreadPool.Size", "1");
ObjectAdapterPtr adapter = com->createObjectAdapterWithEndpoints(name, endpoints);
return ICE_UNCHECKED_CAST(RemoteObjectAdapterPrx, current.adapter->addWithUUID(ICE_MAKE_SHARED(RemoteObjectAdapterI, adapter)));
}
示例4: main
int main(int argc, char* argv[])
{
int status = 0;
Ice::CommunicatorPtr ic;
try
{
ic = Ice::initialize(argc, argv);
Ice::ObjectAdapterPtr adapter = ic->createObjectAdapterWithEndpoints(
"SimplePrinterAdapter", "default -p 10000");
Ice::ObjectPtr object = new PrinterI;
adapter->add(object, ic->stringToIdentity("SimplePrinter"));
adapter->activate();
ic->waitForShutdown();
}
catch (const Ice::Exception& e)
{
std::cerr << e << std::endl;
status = 1;
}
if (ic)
{
try
{
ic->destroy();
}
catch (const Ice::Exception& e)
{
std::cerr << e << std::endl;
status = 1;
}
}
return status;
}
示例5: catch
int
main(int argc, char* argv[])
{
int status = 0;
Ice::InitializationData id;
id.properties = Ice::createProperties(argc, argv);
id.properties->setProperty("Ice.ThreadPool.Server.Size", "50");
id.properties->setProperty("Ice.ThreadPool.Server.SizeMax", "5000");
// _communicator = Ice::initialize(id);
Ice::CommunicatorPtr ic;
try {
ic = Ice::initialize(id);
Ice::ObjectAdapterPtr adapter
= ic->createObjectAdapterWithEndpoints(
"SimplePrinterAdapter", "default -p 10000"); //默认建立的是tcp 连接
Ice::ObjectPtr object = new PrinterI;
PrinterPrx spPrx = PrinterPrx::uncheckedCast(adapter->add(object, ic->stringToIdentity("SimplePrinter")));
cout << "PrinterPrx:" <<spPrx <<endl;
adapter->activate();
ic->waitForShutdown();
} catch (const Ice::Exception & e) {
cerr << e << endl;
status = 1;
} catch (const char * msg) {
cerr << msg << endl;
status = 1;
}
if (ic)
ic->destroy();
return status;
}
示例6: ICE_UNCHECKED_CAST
RemoteObjectAdapterPrx
RemoteCommunicatorI::createObjectAdapter(const string& name, const string& endpts, const Current& current)
#endif
{
Ice::CommunicatorPtr com = current.adapter->getCommunicator();
const string defaultProtocol = com->getProperties()->getProperty("Ice.Default.Protocol");
int retry = 5;
while(true)
{
try
{
string endpoints = endpts;
if(defaultProtocol != "bt")
{
if(endpoints.find("-p") == string::npos)
{
endpoints = getTestEndpoint(com, _nextPort++, endpoints);
}
}
com->getProperties()->setProperty(name + ".ThreadPool.Size", "1");
ObjectAdapterPtr adapter = com->createObjectAdapterWithEndpoints(name, endpoints);
return ICE_UNCHECKED_CAST(RemoteObjectAdapterPrx,
current.adapter->addWithUUID(ICE_MAKE_SHARED(RemoteObjectAdapterI, adapter)));
}
catch(const Ice::SocketException&)
{
if(--retry == 0)
{
throw;
}
}
}
}
示例7: main
int main(int argc, char* argv[])
{
int status = 0;
Ice::CommunicatorPtr ic;
try {
ic = Ice::initialize(argc, argv);
if (argc != 4) {
cerr << "Usage: " << argv[0] << " servername NameService-host local-port\n";
goto clean_up;
}
// Look up the name service.
ostringstream ns_formatter;
ns_formatter << "NameService:tcp -h " << argv[2] << " -p 9010";
Ice::ObjectPrx base =
ic->stringToProxy(ns_formatter.str().c_str());
NameServicePrx ns = NameServicePrx::checkedCast(base);
if (!ns)
throw "Invalid NameService";
// Create local chat display object and support infrastructure.
ostringstream server_formatter;
server_formatter << "tcp -p " << argv[3];
Ice::ObjectAdapterPtr adapter = ic->createObjectAdapterWithEndpoints(
"ChatterAdapter", server_formatter.str().c_str());
Ice::ObjectPtr object = new RoomManager_impl(adapter);
Ice::ObjectPrx server =
adapter->add(object, ic->stringToIdentity("RoomManager"));
adapter->activate();
// Register object.
// ns->registerName(argv[1], server);
ic->waitForShutdown();
}
catch (const Ice::Exception& e) {
cerr << e << endl;
status = 1;
}
catch (const char* msg) {
cerr << msg << endl;
status = 1;
}
clean_up:
// We must call ic->destroy() even if an exception is throw above.
if (ic) {
try {
ic->destroy();
}
catch (const Ice::Exception& e) {
cerr << e << endl;
status = 1;
}
}
return status;
}
示例8: main
int main(int argc, char** argv){
killed=false;
struct sigaction sigIntHandler;
sigIntHandler.sa_handler = exitApplication;
sigemptyset(&sigIntHandler.sa_mask);
sigIntHandler.sa_flags = 0;
sigaction(SIGINT, &sigIntHandler, NULL);
Ice::PropertiesPtr prop;
std::string componentPrefix("myComponent");
try{
ic = Ice::initialize(argc,argv);
prop = ic->getProperties();
}
catch (const Ice::Exception& ex) {
std::cerr << ex << std::endl;
return 1;
}
catch (const char* msg) {
std::cerr <<"Error :" << msg << std::endl;
return 1;
}
std::string Endpoints = prop->getProperty(componentPrefix + ".Endpoints");
Ice::ObjectAdapterPtr adapter =ic->createObjectAdapterWithEndpoints(componentPrefix, Endpoints);
// for each interface:
std::string objPrefix="myInterface";
std::string Name = "pointcloud1";
std::cout << "Creating pointcloud1 " << Name << std::endl;
interface1 = new myClassI();
adapter->add(interface1, ic->stringToIdentity(Name));
//starting the adapter
adapter->activate();
ic->waitForShutdown();
if (!killed)
exitApplication(1);
return 0;
}
示例9: main
int main(int argc, char **argv)
{
Ice::CommunicatorPtr ic;
int status = 0;
std::string port("20000");
if (argc > 1) {
try {
std::stoul(argv[1]);
}
catch (const std::exception& e) {
std::cerr << "Invalid port number: " << argv[1] << '\n';
return 1;
}
port = argv[1];
}
try {
ic = Ice::initialize(argc, argv);
Ice::ObjectAdapterPtr adapter = ic->createObjectAdapterWithEndpoints("PocketSphinxServerAdapter", "default -p " + port);
PocketSphinxServer* srv = new PocketSphinxServer;
std::cout << "init done\n";
Ice::ObjectPtr object = srv;
adapter->add(object, ic->stringToIdentity("PocketSphinxServer"));
adapter->activate();
ic->waitForShutdown();
}
catch (const Ice::Exception& e) {
std::cerr << e << std::endl;
status = 1;
}
catch (const std::exception& e) {
std::cerr << e.what() << std::endl;
status = 1;
}
catch (...) {
status = 1;
}
if (ic) {
try {
ic->destroy();
}
catch (const Ice::Exception& e) {
std::cerr << e << std::endl;
status = 1;
}
}
return status;
}
示例10: main
int main(int argc, char** argv)
{
Ice::ObjectPtr viewerPtr;
//signal(SIGINT,signalHandler);
Ice::CommunicatorPtr ic;
try{
ic = EasyIce::initialize(argc, argv);
Ice::PropertiesPtr prop = ic->getProperties();
std::string Endpoints = prop->getProperty("Visualization.Endpoints");
// Naming Service
int nsActive = prop->getPropertyAsIntWithDefault("NamingService.Enabled", 0);
if (nsActive)
{
std::string ns_proxy = prop->getProperty("NamingService.Proxy");
try
{
namingService = new jderobot::ns(ic, ns_proxy);
}
catch (Ice::ConnectionRefusedException& ex)
{
jderobot::Logger::getInstance()->error("Impossible to connect with NameService!");
exit(-1);
}
}
Ice::ObjectAdapterPtr adapter =ic->createObjectAdapterWithEndpoints("Visualization", Endpoints);
std::string objPrefix("Visualization.");
std::string viewerName = prop->getProperty(objPrefix + "Name");
Ice::ObjectPtr object = new visualization::VisualizationI(objPrefix, ic);
adapter->add(object, ic->stringToIdentity(viewerName));
if (namingService)
namingService->bind(viewerName, Endpoints, object->ice_staticId());
adapter->activate();
ic->waitForShutdown();
}catch (const Ice::Exception& ex) {
std::cerr << ex<<" 1 " << std::endl;
exit(-1);
} catch (const char* msg) {
std::cerr << msg<< " 2 " << std::endl;
exit(-1);
}
}
示例11: main
int main(int argc, char* argv[]) {
int status = 0;
Ice::CommunicatorPtr ic;
try {
ic = Ice::initialize(argc, argv);
if (argc < 5 || 5 < argc)
throw "Incorrect arguments\n"
"Take a look at docs/html/index.html for more info.\n\n";
int model = atoi(argv[1]);
int server_id = atoi(argv[2]);
int num_clients = atoi(argv[3]);
string host_port(argv[4]);
cerr << "Attaching DM_Server_Adapter to endpoint "
<< LDAUtil::DM_Server_Names::get_server_endpoint(host_port)
<< endl;
Ice::ObjectAdapterPtr adapter = ic->createObjectAdapterWithEndpoints(
"DM_Server_Adapter",
LDAUtil::DM_Server_Names::get_server_endpoint(host_port));
Server_Helper* helper = NULL;
if (model == Model::UNIGRAM)
helper = new Unigram_Model_Server_Helper;
Ice::ObjectPtr object = new DM_Server(num_clients, *helper);
cerr << "Adding servant with name "
<< LDAUtil::DM_Server_Names::get_servant_name(server_id)
<< endl;
adapter->add(object, ic->stringToIdentity(
LDAUtil::DM_Server_Names::get_servant_name(server_id)));
adapter->activate();
ic->waitForShutdown();
delete helper;
} catch (const Ice::Exception& e) {
cerr << e << endl;
status = 1;
} catch (const char* msg) {
cerr << msg << endl;
status = 1;
}
if (ic) {
try {
ic->destroy();
} catch (const Ice::Exception& e) {
cerr << e << endl;
status = 1;
}
}
return status;
}
示例12: uncheckedCast
RemoteObjectAdapterPrx
RemoteCommunicatorI::createObjectAdapter(const string& name, const string& endpts, const Current& current)
{
string endpoints = endpts;
if(endpoints.find("-p") == string::npos)
{
// Use a fixed port if none is specified (bug 2896)
ostringstream os;
os << endpoints << " -h 127.0.0.1 -p " << _nextPort++;
}
Ice::CommunicatorPtr com = current.adapter->getCommunicator();
com->getProperties()->setProperty(name + ".ThreadPool.Size", "1");
ObjectAdapterPtr adapter = com->createObjectAdapterWithEndpoints(name, endpoints);
return RemoteObjectAdapterPrx::uncheckedCast(current.adapter->addWithUUID(new RemoteObjectAdapterI(adapter)));
}
示例13: main
int main(int argc, char** argv){
int status;
Ice::CommunicatorPtr ic;
try{
ic = Ice::initialize(argc,argv);
std::string topicName = ic->getProperties()->getProperty("Cameraview_icestorm.Camera.TopicName");
std::cout << "Trying to conect to: " << topicName << std::endl;
Ice::ObjectPrx obj=ic->propertyToProxy("Cameraview_icestorm.Camera.TopicManager");
IceStorm::TopicManagerPrx topicManager=IceStorm::TopicManagerPrx::checkedCast(obj);
std::string objAdapterEndpoint = ic->getProperties()->getProperty("Cameraview_icestorm.Camera.ObjectAdapter");
Ice::ObjectAdapterPtr adapter=ic->createObjectAdapterWithEndpoints("CameraAdapter",objAdapterEndpoint);
ImageConsumerI* imageConsumer = new ImageConsumerI;
Ice::ObjectPrx proxy = adapter->addWithUUID(imageConsumer)->ice_oneway();
IceStorm::TopicPrx topic;
try {
topic = topicManager->retrieve(topicName);
IceStorm::QoS qos;
topic->subscribeAndGetPublisher(qos, proxy);
}
catch (const IceStorm::NoSuchTopic& ex) {
std::cerr << ex << std::endl;
}
adapter->activate();
ic->waitForShutdown();
topic->unsubscribe(proxy);
if (ic)
ic->destroy();
return status;
}catch (const Ice::Exception& ex) {
std::cerr << ex << std::endl;
status = 1;
} catch (const char* msg) {
std::cerr << msg << std::endl;
status = 1;
}
}
示例14: main
int main(int argc, char* argv[])
{
int status = 0;
Ice::CommunicatorPtr ic;
//status变量含有程序的退出状态,而类型为 Ice::Communicator 的 ic 变量含有 Ice run time 的主句柄.
try {
ic = Ice::initialize(argc, argv);
//initialize 调用返回的是一个智能指针,指向一个 Ice::Communicator 对象,这个指针是 Ice run time 的主句柄
Ice::ObjectAdapterPtr adapter = ic->createObjectAdapterWithEndpoints("SimplePrinterAdapter", "default -p 10000");
//创建对象适配器.传入参数"SimplePrinterAdapter"(适配器名字)和"default -p 10000",适配器用缺省协议(TCP/IP)在端口 10000 处侦听到来的请求
Ice::ObjectPtr object = new PrinterI;
//服务器端 run time 已经初始化,我们实例化一个 PrinterI 对象,为 Printer 接口创建一个 servant
adapter->add(object,ic->stringToIdentity("SimplePrinter"));
//调用适配器的add,告诉它有了一个新的servant;传给 add 的参数是我们刚才实例化的 servant,再加上一个标识符.
//"SimplePrinter"串是servant的名字
adapter->activate();
//调用适配器的 activate 方法激活适配器.一旦适配器被激活,服务器就会开始处理来自客户的请求
/*
适配器开始是在扣留(holding)状态创建的;这种做法在下面这样的情况下很有用:我们有多个 servant,它们共享同一个适配器,
而在所有 servant实例化之前我们不想处理请求
*/
ic->waitForShutdown();
// waitForShutdown方法挂起发出调用的线程,直到服务器实现终止为止:或者是通过发出一个调用关闭 run time,或者是对某个信号作出响应
//第一个处理器捕捉 Ice run time 可能抛出的所有异常
} catch (const Ice::Exception & e) {
cerr << e << endl;
status = 1;
//第二个处理器捕捉串常量
} catch (const char * msg) {
cerr << msg << endl;
status = 1;
}
if (ic)//清理代码调用通信器的 destroy 方法,(前提是通信器进行过初始化)
ic->destroy();
//清理调用之所以在 try 块的外部,原因是:不管代码是正常终止,还是由于异常而终止,我们都必须确保 Ice run time 得以执行结束工作
return status;
}
示例15: serve_daemon
int serve_daemon( int argc, char** argv)
{
Ice::CommunicatorPtr ic;
ic = Ice::initialize(argc,argv);
Ice::ObjectAdapterPtr adapter = ic->createObjectAdapterWithEndpoints("Anspypher","default -p 5000");
Ice::ObjectPtr object = new TransporterI;
adapter->add(object,ic->stringToIdentity("Anspypherd"));
adapter->activate();
ic->waitForShutdown();
if (ic) {
try {
ic->destroy();
}
catch (const Ice::Exception& e) {
cerr << e << endl;
}
}
return 0;
}