MyServiceSVC_impl.cpp
Go to the documentation of this file.
00001 // -*-C++-*-
00008 #include "MyServiceSVC_impl.h"
00009 #include <rtm/CORBA_SeqUtil.h>
00010 #include <coil/Time.h>
00011 #include <iostream>
00012 
00013 template <class T>
00014 struct seq_print
00015 {
00016   seq_print() : m_cnt(0) {};
00017   void operator()(T val)
00018   {
00019     std::cout << m_cnt << ": " << val << std::endl;
00020     ++m_cnt;
00021   }
00022   int m_cnt;
00023 };
00024 
00025 /*
00026  * Example implementational code for IDL interface MyService
00027  */
00028 MyServiceSVC_impl::MyServiceSVC_impl()
00029 {
00030   // Please add extra constructor code here.
00031 }
00032 
00033 
00034 MyServiceSVC_impl::~MyServiceSVC_impl()
00035 {
00036   // Please add extra destructor code here.
00037 }
00038 
00039 
00040 /*
00041  * Methods corresponding to IDL attributes and operations
00042  */
00043 char* MyServiceSVC_impl::echo(const char* msg)
00044   throw (CORBA::SystemException)
00045 {
00046   CORBA_SeqUtil::push_back(m_echoList, CORBA::string_dup(msg));
00047   std::cout << "MyService::echo() was called." << std::endl;
00048 
00049   for (int i(0); i < 10; ++i)
00050     {
00051       std::cout << "Message: " << msg << std::endl;
00052       coil::sleep(1);
00053     }
00054   std::cout << "MyService::echo() was finished" << std::endl;
00055 
00056   return CORBA::string_dup(msg);
00057 }
00058 
00059 SimpleService::EchoList* MyServiceSVC_impl::get_echo_history()
00060   throw (CORBA::SystemException)
00061 {
00062   std::cout << "MyService::get_echo_history() was called." << std::endl;
00063   CORBA_SeqUtil::for_each(m_echoList, seq_print<const char*>());
00064   
00065   SimpleService::EchoList_var el;
00066   el = new SimpleService::EchoList(m_echoList);
00067   return el._retn();
00068 }
00069 
00070 void MyServiceSVC_impl::set_value(CORBA::Float value)
00071   throw (CORBA::SystemException)
00072 {
00073   CORBA_SeqUtil::push_back(m_valueList, value);
00074   m_value = value;
00075 
00076   std::cout << "MyService::set_value() was called." << std::endl;
00077 
00078   for (int i(0); i < 10; ++i)
00079     {
00080       std::cout << "Input value: " << value;
00081       std::cout << ", Current value: " << m_value << std::endl;
00082       coil::sleep(1);
00083     }
00084   std::cout << "MyService::set_value() was finished" << std::endl;
00085 
00086   return;
00087 }
00088 
00089 CORBA::Float MyServiceSVC_impl::get_value()
00090   throw (CORBA::SystemException)
00091 {
00092   std::cout << "MyService::get_value() was called." << std::endl;
00093   std::cout << "Current value: " << m_value << std::endl;
00094 
00095   return m_value;
00096 }
00097 
00098 SimpleService::ValueList* MyServiceSVC_impl::get_value_history()
00099   throw (CORBA::SystemException)
00100 {
00101   std::cout << "MyService::get_value_history() was called." << std::endl;
00102   CORBA_SeqUtil::for_each(m_valueList, seq_print<CORBA::Float>());
00103 
00104   SimpleService::ValueList_var vl;
00105   vl = new SimpleService::ValueList(m_valueList);
00106   return vl._retn();
00107 }
00108 
00109 
00110 
00111 // End of example implementational code
00112 
00113 
00114 


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Sat Jun 8 2019 18:49:05