EchoCORBA.cpp
Go to the documentation of this file.
00001 #include <iostream>
00002 #include <coil/Properties.h>
00003 #include <doil/corba/CORBAManager.h>
00004 #include "IEcho.h"
00005 #include "EchoCORBASkel.h"
00006 
00007 //------------------------------------------------------------
00008 // Echo servant for CORBA
00009 //------------------------------------------------------------
00010 class EchoServant
00011   : public virtual doil::CORBA::CORBAServantBase,
00012     public virtual POA_EchoCORBA::EchoSample
00013 {
00014 public:
00015   EchoServant(doil::ImplBase* impl)
00016     : doil::CORBA::CORBAServantBase(impl)
00017   {
00018     std::cout << "EchoCORBAServant" << std::endl;
00019     std::cout << "id  : " << impl->id() << std::endl;
00020     std::cout << "name: " << impl->name() << std::endl;
00021     m_impl = dynamic_cast<IEcho*>(impl);
00022     //    std::cout << "id  : " << m_impl->id() << std::endl;
00023     //    std::cout << "name: " << m_impl->name() << std::endl;
00024     if (m_impl == NULL) 
00025       {
00026         std::cout << "Error!!!!!: cast failed in EchoCORBAServant" << std::endl;
00027         throw std::bad_alloc();
00028       }
00029     std::cout << " was created" << std::endl;
00030   }
00031   virtual ~EchoServant()
00032   {
00033     std::cout << "EchoServant: " << name() << " deleted." << std::endl;
00034   }
00035   void echo(const char* msg)
00036   {
00037     m_impl->echo(msg);
00038   }
00039 private:
00040   IEcho* m_impl;
00041 };
00042 
00043 extern "C"
00044 {
00045   using namespace doil::CORBA;
00046   void EchoCORBAInit(coil::Properties& prop)
00047   {
00048     std::cout << "EchoCORBAInit";
00049     CORBAManager::instance().registerFactory("EchoSample",
00050                                              doil::New<EchoServant>,
00051                                              doil::Delete<EchoServant>);
00052     std::cout << " done" << std::endl;
00053   }
00054 }


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Thu Aug 27 2015 14:16:37