MyServiceSVC_impl.cpp
Go to the documentation of this file.
1 // -*-C++-*-
8 #include "MyServiceSVC_impl.h"
9 #include <rtm/CORBA_SeqUtil.h>
10 #include <coil/Time.h>
11 #include <iostream>
12 
13 template <class T>
14 struct seq_print
15 {
16  seq_print() : m_cnt(0) {};
17  void operator()(T val)
18  {
19  std::cout << m_cnt << ": " << val << std::endl;
20  ++m_cnt;
21  }
22  int m_cnt;
23 };
24 
25 /*
26  * Example implementational code for IDL interface MyService
27  */
29 {
30  // Please add extra constructor code here.
31 }
32 
33 
35 {
36  // Please add extra destructor code here.
37 }
38 
39 
40 /*
41  * Methods corresponding to IDL attributes and operations
42  */
43 char* MyServiceSVC_impl::echo(const char* msg)
44  throw (CORBA::SystemException)
45 {
46  CORBA_SeqUtil::push_back(m_echoList, CORBA::string_dup(msg));
47  std::cout << "MyService::echo() was called." << std::endl;
48 
49  for (int i(0); i < 10; ++i)
50  {
51  std::cout << "Message: " << msg << std::endl;
52  coil::sleep(1);
53  }
54  std::cout << "MyService::echo() was finished" << std::endl;
55 
56  return CORBA::string_dup(msg);
57 }
58 
59 SimpleService::EchoList* MyServiceSVC_impl::get_echo_history()
60  throw (CORBA::SystemException)
61 {
62  std::cout << "MyService::get_echo_history() was called." << std::endl;
64 
65  SimpleService::EchoList_var el;
66  el = new SimpleService::EchoList(m_echoList);
67  return el._retn();
68 }
69 
70 void MyServiceSVC_impl::set_value(CORBA::Float value)
71  throw (CORBA::SystemException)
72 {
73  CORBA_SeqUtil::push_back(m_valueList, value);
74  m_value = value;
75 
76  std::cout << "MyService::set_value() was called." << std::endl;
77 
78  for (int i(0); i < 10; ++i)
79  {
80  std::cout << "Input value: " << value;
81  std::cout << ", Current value: " << m_value << std::endl;
82  coil::sleep(1);
83  }
84  std::cout << "MyService::set_value() was finished" << std::endl;
85 
86  return;
87 }
88 
89 CORBA::Float MyServiceSVC_impl::get_value()
90  throw (CORBA::SystemException)
91 {
92  std::cout << "MyService::get_value() was called." << std::endl;
93  std::cout << "Current value: " << m_value << std::endl;
94 
95  return m_value;
96 }
97 
98 SimpleService::ValueList* MyServiceSVC_impl::get_value_history()
99  throw (CORBA::SystemException)
100 {
101  std::cout << "MyService::get_value_history() was called." << std::endl;
103 
104  SimpleService::ValueList_var vl;
105  vl = new SimpleService::ValueList(m_valueList);
106  return vl._retn();
107 }
108 
109 
110 
111 // End of example implementational code
112 
113 
114 
Service implementation header of MyService.idl.
AutoTest::ValueList * get_value_history()
unsigned int sleep(unsigned int seconds)
Stop a processing at specified second time.
Definition: ace/coil/Time.h:40
char * echo(const char *msg)
virtual ~MyServiceSVC_impl()
destructor
CORBA sequence utility template functions.
void operator()(T val)
void set_value(CORBA::Float value)
void push_back(CorbaSequence &seq, SequenceElement elem)
Push the new element back to the CORBA sequence.
AutoTest::EchoList * get_echo_history()
MyServiceSVC_impl()
standard constructor
Functor for_each(CorbaSequence &seq, Functor f)
Apply the functor to all CORBA sequence elements.
Definition: CORBA_SeqUtil.h:98


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