MyServiceConsumer.h
Go to the documentation of this file.
1 // -*- C++ -*-
10 #ifndef MYSERVICECONSUMER_H
11 #define MYSERVICECONSUMER_H
12 
13 #include <rtm/idl/BasicDataTypeSkel.h>
14 #include <rtm/Manager.h>
16 #include <rtm/CorbaPort.h>
17 #include <rtm/DataInPort.h>
18 #include <rtm/DataOutPort.h>
19 #include <iostream>
20 #include <coil/Async.h>
21 
22 // Service implementation headers
23 // <rtc-template block="service_impl_h">
24 
25 // </rtc-template>
26 
27 // Service Consumer stub headers
28 // <rtc-template block="consumer_stub_h">
29 #include "MyServiceStub.h"
30 
31 // </rtc-template>
32 
33 using namespace RTC;
34 
37 {
38  public:
41 
42  // The initialize action (on CREATED->ALIVE transition)
43  // formaer rtc_init_entry()
44  virtual RTC::ReturnCode_t onInitialize();
45 
46  // The finalize action (on ALIVE->END transition)
47  // formaer rtc_exiting_entry()
48  // virtual RTC::ReturnCode_t onFinalize();
49 
50  // The startup action when ExecutionContext startup
51  // former rtc_starting_entry()
52  // virtual RTC::ReturnCode_t onStartup(RTC::UniqueId ec_id);
53 
54  // The shutdown action when ExecutionContext stop
55  // former rtc_stopping_entry()
56  // virtual RTC::ReturnCode_t onShutdown(RTC::UniqueId ec_id);
57 
58  // The activated action (Active state entry action)
59  // former rtc_active_entry()
60  // virtual RTC::ReturnCode_t onActivated(RTC::UniqueId ec_id);
61 
62  // The deactivated action (Active state exit action)
63  // former rtc_active_exit()
64  // virtual RTC::ReturnCode_t onDeactivated(RTC::UniqueId ec_id);
65 
66  // The execution action that is invoked periodically
67  // former rtc_active_do()
68  virtual RTC::ReturnCode_t onExecute(RTC::UniqueId ec_id);
69 
70  // The aborting action when main logic error occurred.
71  // former rtc_aborting_entry()
72  // virtual RTC::ReturnCode_t onAborting(RTC::UniqueId ec_id);
73 
74  // The error action in ERROR state
75  // former rtc_error_do()
76  // virtual RTC::ReturnCode_t onError(RTC::UniqueId ec_id);
77 
78  // The reset action that is invoked resetting
79  // This is same but different the former rtc_init_entry()
80  // virtual RTC::ReturnCode_t onReset(RTC::UniqueId ec_id);
81 
82  // The state update action that is invoked after onExecute() action
83  // no corresponding operation exists in OpenRTm-aist-0.2.0
84  // virtual RTC::ReturnCode_t onStateUpdate(RTC::UniqueId ec_id);
85 
86  // The action that is invoked when execution context's rate is changed
87  // no corresponding operation exists in OpenRTm-aist-0.2.0
88  // virtual RTC::ReturnCode_t onRateChanged(RTC::UniqueId ec_id);
89 
90 
91  protected:
92  // DataInPort declaration
93  // <rtc-template block="inport_declare">
94 
95  // </rtc-template>
96 
97 
98  // DataOutPort declaration
99  // <rtc-template block="outport_declare">
100 
101  // </rtc-template>
102 
103  // CORBA Port declaration
104  // <rtc-template block="corbaport_declare">
106 
107  // </rtc-template>
108 
109  // Service declaration
110  // <rtc-template block="service_declare">
111 
112  // </rtc-template>
113 
114  // Consumer declaration
115  // <rtc-template block="consumer_declare">
117 
118  // </rtc-template>
119 
121  {
122  public:
123  set_value_functor(CORBA::Float val) : m_val(val) {}
124 
126  {
127  try
128  {
129  if( CORBA::is_nil((*obj).operator->()) )
130  {
131  std::cout << "No service connected." << std::endl;
132  }
133  else
134  {
135  (*obj)->set_value(m_val);
136  }
137  }
138  catch (const CORBA::INV_OBJREF &)
139  {
140  }
141  catch (const CORBA::OBJECT_NOT_EXIST &)
142  {
143  }
144  catch (const CORBA::OBJ_ADAPTER &)
145  {
146  }
147  catch (...)
148  {
149  }
150  }
151  CORBA::Float m_val;
152  };
153 
155  {
156  public:
157  echo_functor(std::string msg, std::string& result)
158  : m_msg(msg), m_result(result) {}
160  {
161  try
162  {
163  if( CORBA::is_nil((*obj).operator->()) )
164  {
165  std::cout << "No service connected." << std::endl;
166  }
167  else
168  {
169  m_result = (*obj)->echo(m_msg.c_str());
170  }
171  }
172  catch (const CORBA::INV_OBJREF &)
173  {
174  }
175  catch (const CORBA::OBJECT_NOT_EXIST &)
176  {
177  }
178  catch (const CORBA::OBJ_ADAPTER &)
179  {
180  }
181  catch (...)
182  {
183  }
184  }
185  std::string m_msg;
186  std::string& m_result;
187  };
188  private:
191  std::string m_result;
192 
193  template <class T>
194  struct seq_print
195  {
196  seq_print() : m_cnt(0) {};
197  void operator()(T val)
198  {
199  std::cout << m_cnt << ": " << val << std::endl;
200  ++m_cnt;
201  }
202  int m_cnt;
203  };
204 
205 };
206 
207 
208 extern "C"
209 {
211 };
212 
213 #endif // MYSERVICECONSUMER_H
coil::Async * async_set_value
void operator()(RTC::CorbaConsumer< SimpleService::MyService > *obj)
RT-Component.
RT Conponent CORBA service/consumer Port.
Definition: CorbaPort.h:620
DataFlowComponentBase class.
ReturnCode_t
Definition: doil.h:53
coil::Async * async_echo
Manager class.
Definition: Manager.h:80
RTC::CorbaPort m_MyServicePort
Base class of OutPort.
echo_functor(std::string msg, std::string &result)
CorbaPort class.
RTComponent manager class.
ExecutionContextHandle_t UniqueId
Base class of InPort.
#define DLL_EXPORT
Definition: PluginC.cpp:8
RTC::CorbaConsumer< SimpleService::MyService > m_myservice0
Async class.
Definition: Async.h:41
void operator()(RTC::CorbaConsumer< SimpleService::MyService > *obj)
DLL_EXPORT void MyServiceConsumerInit(RTC::Manager *manager)


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Mon Feb 28 2022 23:00:43