ProxyFactory.h
Go to the documentation of this file.
1 // -*- C++ -*-
19 #ifndef DOIL_PROXYFACTORY_H
20 #define DOIL_PROXYFACTORY_H
21 
22 #include <doil/ProxyBase.h>
23 #include <doil/corba/CORBA.h>
24 
25 namespace doil
26 {
27  // Servant 生成・削除関数のtypedef
28 // typedef ImplBase* (*ProxyNewFunc)(::CORBA::Object_ptr obj);
29 // typedef void (*ProxyDeleteFunc)(ImplBase*);
30  typedef ProxyBase* (*ProxyNewFunc)(::CORBA::Object_ptr obj);
31  typedef void (*ProxyDeleteFunc)(ProxyBase*);
32 
33  // Servant 生成のためのテンプレート関数 template <class Proxy> ProxyBase* New(::CORBA::Object_ptr obj) { return new Proxy(obj); } // Servant 削除のためのテンプレート関数 template <class Proxy> // void Delete(ImplBase* impl) void Delete(ProxyBase* impl) { if (impl != NULL) { delete impl; impl = NULL; } } class ProxyFactoryBase { public: virtual ~ProxyFactoryBase(){} virtual const char* name() = 0; virtual ProxyBase* create() = 0; // virtual void destroy(ImplBase* impl) = 0; virtual void destroy(ProxyBase* impl) = 0; }; class ProxyFactory // : public ServantFactoryBase { public: ProxyFactory(const char* id, ProxyNewFunc new_func, ProxyDeleteFunc delete_func) : m_id(id), m_new(new_func), m_delete(delete_func) { } /* ServantFactory(const ServantFactory& sf) { m_name = sf.m_name; m_new = sf.m_new; m_delete = sf.m_delete; } ServantFactory& operator=(ServantFactory& sf) { ServantFactory tmp(sf); std::swap(*this, tmp); return *this; } */ virtual ~ProxyFactory(){}; virtual const char* id() { return m_id.c_str(); } virtual ProxyBase* create(::CORBA::Object_ptr obj) { return m_new(obj); } // virtual void destroy(ImplBase* impl) virtual void destroy(ProxyBase* impl) { m_delete(impl); } private: std::string m_id; ProxyNewFunc m_new; ProxyDeleteFunc m_delete; }; }; #endif // DOIL_SERVANTFACTORY_H
34  template <class Proxy>
35  ProxyBase* New(::CORBA::Object_ptr obj)
36  {
37  return new Proxy(obj);
38  }
39 
40  // Servant 削除のためのテンプレート関数 template <class Proxy> // void Delete(ImplBase* impl) void Delete(ProxyBase* impl) { if (impl != NULL) { delete impl; impl = NULL; } } class ProxyFactoryBase { public: virtual ~ProxyFactoryBase(){} virtual const char* name() = 0; virtual ProxyBase* create() = 0; // virtual void destroy(ImplBase* impl) = 0; virtual void destroy(ProxyBase* impl) = 0; }; class ProxyFactory // : public ServantFactoryBase { public: ProxyFactory(const char* id, ProxyNewFunc new_func, ProxyDeleteFunc delete_func) : m_id(id), m_new(new_func), m_delete(delete_func) { } /* ServantFactory(const ServantFactory& sf) { m_name = sf.m_name; m_new = sf.m_new; m_delete = sf.m_delete; } ServantFactory& operator=(ServantFactory& sf) { ServantFactory tmp(sf); std::swap(*this, tmp); return *this; } */ virtual ~ProxyFactory(){}; virtual const char* id() { return m_id.c_str(); } virtual ProxyBase* create(::CORBA::Object_ptr obj) { return m_new(obj); } // virtual void destroy(ImplBase* impl) virtual void destroy(ProxyBase* impl) { m_delete(impl); } private: std::string m_id; ProxyNewFunc m_new; ProxyDeleteFunc m_delete; }; }; #endif // DOIL_SERVANTFACTORY_H
41  template <class Proxy>
42 // void Delete(ImplBase* impl)
43  void Delete(ProxyBase* impl)
44  {
45  if (impl != NULL)
46  {
47  delete impl;
48  impl = NULL;
49  }
50  }
51 
53  {
54  public:
55  virtual ~ProxyFactoryBase(){}
56  virtual const char* name() = 0;
57  virtual ProxyBase* create() = 0;
58 // virtual void destroy(ImplBase* impl) = 0;
59  virtual void destroy(ProxyBase* impl) = 0;
60  };
61 
62 
64  // : public ServantFactoryBase
65  {
66  public:
67  ProxyFactory(const char* id,
68  ProxyNewFunc new_func,
69  ProxyDeleteFunc delete_func)
70  : m_id(id), m_new(new_func), m_delete(delete_func)
71  {
72  }
73 
74  /*
75  ServantFactory(const ServantFactory& sf)
76  {
77  m_name = sf.m_name;
78  m_new = sf.m_new;
79  m_delete = sf.m_delete;
80  }
81 
82  ServantFactory& operator=(ServantFactory& sf)
83  {
84  ServantFactory tmp(sf);
85  std::swap(*this, tmp);
86  return *this;
87  }
88  */
89  virtual ~ProxyFactory(){};
90 
91  virtual const char* id()
92  {
93  return m_id.c_str();
94  }
95  virtual ProxyBase* create(::CORBA::Object_ptr obj)
96  {
97  return m_new(obj);
98  }
99 // virtual void destroy(ImplBase* impl)
100  virtual void destroy(ProxyBase* impl)
101  {
102  m_delete(impl);
103  }
104  private:
105  std::string m_id;
108  };
109 
110 
111 };
112 #endif // DOIL_SERVANTFACTORY_H
113 
void(* ProxyDeleteFunc)(ProxyBase *)
Definition: ProxyFactory.h:31
ProxyBase * New(::CORBA::Object_ptr obj)
Definition: ProxyFactory.h:35
virtual ~ProxyFactoryBase()
Definition: ProxyFactory.h:55
doil implementation base class
virtual ~ProxyFactory()
Definition: ProxyFactory.h:89
virtual const char * id()
Definition: ProxyFactory.h:91
virtual const char * name()=0
virtual void destroy(ProxyBase *impl)=0
ProxyBase *(* ProxyNewFunc)(::CORBA::Object_ptr obj)
Definition: ProxyFactory.h:30
virtual ProxyBase * create(::CORBA::Object_ptr obj)
Definition: ProxyFactory.h:95
virtual void destroy(ProxyBase *impl)
Definition: ProxyFactory.h:100
ProxyFactory(const char *id, ProxyNewFunc new_func, ProxyDeleteFunc delete_func)
Definition: ProxyFactory.h:67
doil CORBA header
ProxyDeleteFunc m_delete
Definition: ProxyFactory.h:107
ProxyNewFunc m_new
Definition: ProxyFactory.h:106
virtual ProxyBase * create()=0
void Delete(ProxyBase *impl)
Definition: ProxyFactory.h:43
std::string m_id
Definition: ProxyFactory.h:105


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