Go to the documentation of this file.00001 #include <iostream>
00002 #include <coil/Properties.h>
00003 #include <doil/ice/IceManager.h>
00004 #include "IEcho.h"
00005 #include "EchoIceSkel.h"
00006
00007
00008
00009
00010 namespace EchoIce
00011 {
00012 class EchoServant
00013 : public virtual Demo::EchoSample,
00014 public virtual doil::Ice::IceServantBase
00015 {
00016 public:
00017 EchoServant(doil::ImplBase* impl)
00018 : doil::Ice::IceServantBase(impl)
00019 {
00020 std::cout << "EchoIceServant";
00021 m_impl = dynamic_cast<IEcho*>(impl);
00022 if (m_impl == NULL) throw std::bad_alloc();
00023 std::cout << " created." << std::endl;
00024 }
00025 virtual ~EchoServant()
00026 {
00027 std::cout << "EchoServant: " << name() << " deleted." << std::endl;
00028 }
00029 virtual void echo(const std::string& msg, const Ice::Current&)
00030 {
00031 std::cout << "servant" << name() << "::echo() was called" << std::endl;
00032 m_impl->echo(msg);
00033 }
00034 private:
00035 IEcho* m_impl;
00036 };
00037 };
00038 extern "C"
00039 {
00040 using namespace doil::Ice;
00041 void EchoIceInit(coil::Properties& prop)
00042 {
00043 std::cout << "EchoIceInit";
00044 IceManager::instance().registerFactory("EchoSample",
00045 doil::New<EchoIce::EchoServant>,
00046 doil::Delete<EchoIce::EchoServant>);
00047 std::cout << " done" << std::endl;
00048 }
00049 }