SimpleIO/ConsoleInComp.cpp
Go to the documentation of this file.
1 // -*- C++ -*-
10 #include <rtm/Manager.h>
11 #include <iostream>
12 #include <string>
13 #include "ConsoleIn.h"
14 #include <rtm/NVUtil.h>
15 
16 
18 {
19  ConsoleInInit(manager);
20  RTC::RtcBase* comp;
21 
22  // Create a component
23  std::cout << "Creating a component: \"ConsoleIn\"....";
24  comp = manager->createComponent("ConsoleIn");
25  std::cout << "succeed." << std::endl;
26 
27  RTC::ComponentProfile_var prof;
28  prof = comp->get_component_profile();
29  std::cout << "=================================================" << std::endl;
30  std::cout << " Component Profile" << std::endl;
31  std::cout << "-------------------------------------------------" << std::endl;
32  std::cout << "InstanceID: " << prof->instance_name << std::endl;
33  std::cout << "Implementation: " << prof->type_name << std::endl;
34  std::cout << "Description: " << prof->description << std::endl;
35  std::cout << "Version: " << prof->version << std::endl;
36  std::cout << "Maker: " << prof->vendor << std::endl;
37  std::cout << "Category: " << prof->category << std::endl;
38  std::cout << " Other properties " << std::endl;
39  NVUtil::dump(prof->properties);
40  std::cout << "=================================================" << std::endl;
41 
42  PortServiceList* portlist;
43  portlist = comp->get_ports();
44 
45  for (CORBA::ULong i(0), n(portlist->length()); i < n; ++i)
46  {
47  PortService_ptr port;
48  port = (*portlist)[i];
49  std::cout << "================================================="
50  << std::endl;
51  std::cout << "Port" << i << " (name): ";
52  std::cout << port->get_port_profile()->name << std::endl;
53  std::cout << "-------------------------------------------------"
54  << std::endl;
56  iflist = port->get_port_profile()->interfaces;
57 
58  for (CORBA::ULong i(0), n(iflist.length()); i < n; ++i)
59  {
60  std::cout << "I/F name: ";
61  std::cout << iflist[i].instance_name << std::endl;
62  std::cout << "I/F type: ";
63  std::cout << iflist[i].type_name << std::endl;
64  const char* pol;
65  pol = iflist[i].polarity == 0 ? "PROVIDED" : "REQUIRED";
66  std::cout << "Polarity: " << pol << std::endl;
67  }
68  std::cout << "- properties -" << std::endl;
69  NVUtil::dump(port->get_port_profile()->properties);
70  std::cout << "-------------------------------------------------" << std::endl;
71  }
72  return;
73 }
74 
75 
76 
77 int main (int argc, char** argv)
78 {
80  manager = RTC::Manager::init(argc, argv);
81 
82  // Set module initialization proceduer
83  // This procedure will be invoked in activateManager() function.
85 
86  // Activate manager and register to naming service
87  manager->activateManager();
88 
89  // run the manager in blocking mode
90  // runManager(false) is the default.
91  manager->runManager();
92 
93  // If you want to run the manager in non-blocking mode, do like this
94  // manager->runManager(true);
95 
96  return 0;
97 }
RTObject_impl * createComponent(const char *comp_args)
Create RT-Components.
Definition: Manager.cpp:520
virtual ComponentProfile * get_component_profile()
[RTObject CORBA interface] Get RTC&#39;s profile
Definition: RTObject.cpp:698
int main(int argc, char **argv)
void runManager(bool no_block=false)
Run the Manager.
Definition: Manager.cpp:318
RT-Component class.
Definition: RTObject.h:89
Manager class.
Definition: Manager.h:80
virtual PortServiceList * get_ports()
[RTObject CORBA interface] Get Ports
Definition: RTObject.cpp:748
RTComponent manager class.
std::vector< PortInterfaceProfile * > PortInterfaceProfileList
Definition: IPortService.h:38
void ConsoleInInit(RTC::Manager *manager)
static Manager * init(int argc, char **argv)
Initialize manager.
Definition: Manager.cpp:110
NameValue and NVList utility functions.
void dump(const SDOPackage::NVList &nv)
Print information configured in NVList as a string type to Standard Outport.
Definition: NVUtil.cpp:394
bool activateManager()
Activate the Manager.
Definition: Manager.cpp:244
std::vector< IPortService * > PortServiceList
Definition: IPortService.h:39
void setModuleInitProc(ModuleInitProc proc)
Set initial procedure.
Definition: Manager.cpp:232
void MyModuleInit(RTC::Manager *manager)


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Thu Jun 6 2019 19:25:58