ServantFactory.cpp
Go to the documentation of this file.
1 // -*- C++ -*-
19 #ifndef DOIL_SERVANTFACTORY_H
20 #define DOIL_SERVANTFACTORY_H
21 
22 #include <doil/ServantBase.h>
23 
24 namespace doil
25 {
26 
27  // Servant 生成・削除関数のtypedef
28  typedef ServantBase* (*ServantNewFunc)();
29  typedef void (*ServantDeleteFunc)(ServantBase*);
30 
31  // Servant 生成のためのテンプレート関数 template <class Servant> ServantBase* New() { return new Servant(); } // Servant 削除のためのテンプレート関数 template <class Servant> void Delete(ServantBase* servant) { if (servant != NULL) { delete servant; servant == NULL; } } class ServantFactoryBase { public: virtual ~ServantFactoryBase(){} virtual const char* name() = 0; virtual ServantBase* create() = 0; virtual void destroy(ServantBase* servant) = 0; }; class ServantFactory : public ServantFactoryBase { public: ServantFactory(const char* name, ServantNewFunc new_func, ServantDeleteFunc delete_func); virtual ~ServantFactory(); virtual const char* name(); virtual ServantBase* create(); virtual void destroy(ServantBase* servant); }; }; #endif // DOIL_SERVANTFACTORY_H
32  template <class Servant>
34  {
35  return new Servant();
36  }
37 
38  // Servant 削除のためのテンプレート関数 template <class Servant> void Delete(ServantBase* servant) { if (servant != NULL) { delete servant; servant == NULL; } } class ServantFactoryBase { public: virtual ~ServantFactoryBase(){} virtual const char* name() = 0; virtual ServantBase* create() = 0; virtual void destroy(ServantBase* servant) = 0; }; class ServantFactory : public ServantFactoryBase { public: ServantFactory(const char* name, ServantNewFunc new_func, ServantDeleteFunc delete_func); virtual ~ServantFactory(); virtual const char* name(); virtual ServantBase* create(); virtual void destroy(ServantBase* servant); }; }; #endif // DOIL_SERVANTFACTORY_H
39  template <class Servant>
40  void Delete(ServantBase* servant)
41  {
42  if (servant != NULL)
43  {
44  delete servant;
45  servant == NULL;
46  }
47  }
48 
50  {
51  public:
52  virtual ~ServantFactoryBase(){}
53  virtual const char* name() = 0;
54  virtual ServantBase* create() = 0;
55  virtual void destroy(ServantBase* servant) = 0;
56  };
57 
58 
60  : public ServantFactoryBase
61  {
62  public:
63  ServantFactory(const char* name,
64  ServantNewFunc new_func,
65  ServantDeleteFunc delete_func);
66 
67  virtual ~ServantFactory();
68 
69  virtual const char* name();
70  virtual ServantBase* create();
71  virtual void destroy(ServantBase* servant);
72  };
73 
74 
75 };
76 #endif // DOIL_SERVANTFACTORY_H
ServantBase *(* ServantNewFunc)()
ProxyBase * New(::CORBA::Object_ptr obj)
Definition: ProxyFactory.h:35
virtual ServantBase * create()=0
virtual void destroy(ServantBase *servant)=0
void(* ServantDeleteFunc)(ServantBase *)
doil implementation base class
virtual const char * name()=0
void Delete(ProxyBase *impl)
Definition: ProxyFactory.h:43


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Thu Jun 6 2019 19:26:00