commore  1.0.6-SNAPSHOT
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Interface.h
Go to the documentation of this file.
1 //
2 // Copyright (c) 2006-2014 Raphael David / CANTOR
3 //
4 
5 #ifndef CMR_INTERFACE_INCLUDED
6 #define CMR_INTERFACE_INCLUDED
7 
8 #include "Commore.h"
9 #include "AutoRef.h"
10 #include "AString.h"
11 
12 namespace commore
13 {
14  class Interface;
17 
18  class Service;
19  typedef AutoRef<Service> PService;
20  typedef Service* PPService;
21 
22  struct Internals_;
23 
31  class CMREXD Interface : public RefObject
32  {
33  friend class Service;
34 
35  public:
39  Interface(const AChar* name);
40  virtual ~Interface();
41 
42  public:
46  virtual bool is_proxy() const
47  {
48  return false;
49  }
56  virtual long call(const Tuple& in_args, Tuple& out_args);
57  virtual long call(const Tuple& in_args, Tuple& out_args, const Tuple* param);
58 
62  const AString& get_name() const;
66  virtual PService get_service() const;
70  CriticalSection* get_cs() const;
71 
72  virtual bool get_session_context(Tuple& t);
73  virtual void set_session_context(const Tuple& session_context);
80  virtual bool get_self_session_context(Tuple& t) const;
81  virtual void set_self_session_context();
82 
83  protected:
85 
86  protected:
87  bool set_service(const PService& service);
88 
89  private:
90  PInterface find(const AChar* name);
91 
92  protected:
93  Interface(const Interface&) {}
94  };
95 
100  {
101  public:
102  ProxyInterface(const AChar* name);
103  ~ProxyInterface();
104  bool is_proxy() const
105  {
106  return true;
107  }
108  virtual long call(const Tuple& inArgs, Tuple& outArgs);
109  virtual long call(const Tuple& inArgs, Tuple& outArgs, const Tuple* param);
110  };
112 
113 
118  {
119  public:
120  InterfaceFactory(const AChar* name);
121  virtual ~InterfaceFactory();
122 
123  public:
124  const AString& get_class_name() const
125  {
126  return class_name_;
127  }
128  virtual PInterface create(const AChar* name, PService& service) = 0;
129 
130  public:
131  static int get(const AChar* className, List<InterfaceFactory*>& factoryList);
132 
133  private:
134  AString class_name_;
135 
136  };
137 
142  template <class I> class DummyInterfaceFactory : public InterfaceFactory
143  {
144  public:
146  : InterfaceFactory(I::get_factory_class_name())
147  {
148  }
149  PInterface create(const AChar* name, PService& service)
150  {
151  PInterface inter = new I();
152  return inter;
153  }
154  };
155 };
156 
157 
158 #endif
AutoRef< ProxyInterface > PProxyInterface
Definition: Interface.h:111
Definition: Interface.h:117
Definition: Tuple.h:29
Definition: AString.h:39
AutoRef< Interface > PInterface
Definition: Interface.h:14
const AString & get_class_name() const
Definition: Interface.h:124
Interface(const Interface &)
Definition: Interface.h:93
A commore::Service is an object that mimics an object in an object oriented system : it has a class n...
Definition: Service.h:122
Definition: Interface.h:31
Definition: List.h:23
Internals_ * internals_
Definition: Interface.h:84
Service * PPService
Definition: Interface.h:20
Interface * PPInterface
Definition: Interface.h:16
AutoRef< Service > PService
Definition: Interface.h:18
char AChar
Definition: Type.h:65
#define CMREXD
Definition: Compiler.h:22
bool is_proxy() const
Definition: Interface.h:104
Definition: CriticalSection.h:15
Definition: RefObject.h:89
DummyInterfaceFactory()
Definition: Interface.h:145
virtual bool is_proxy() const
Definition: Interface.h:46
Definition: ServiceManager.h:65
PInterface create(const AChar *name, PService &service)
Definition: Interface.h:149
Definition: Interface.h:99
Definition: Interface.h:142