RCFProto
 All Classes Functions Typedefs
StubFactory.hpp
1 
2 //******************************************************************************
3 // RCF - Remote Call Framework
4 //
5 // Copyright (c) 2005 - 2013, Delta V Software. All rights reserved.
6 // http://www.deltavsoft.com
7 //
8 // RCF is distributed under dual licenses - closed source or GPL.
9 // Consult your particular license for conditions of use.
10 //
11 // If you have not purchased a commercial license, you are using RCF
12 // under GPL terms.
13 //
14 // Version: 2.0
15 // Contact: support <at> deltavsoft.com
16 //
17 //******************************************************************************
18 
19 #ifndef INCLUDE_RCF_STUBFACTORY_HPP
20 #define INCLUDE_RCF_STUBFACTORY_HPP
21 
22 #include <boost/shared_ptr.hpp>
23 
24 #include <RCF/RcfClient.hpp>
25 #include <RCF/ServerStub.hpp>
26 #include <RCF/Tools.hpp>
27 
28 namespace RCF {
29 
30  class I_RcfClient;
31  typedef boost::shared_ptr<I_RcfClient> RcfClientPtr;
32 
33  class StubFactory
34  {
35  public:
36  virtual ~StubFactory()
37  {}
38 
39  virtual RcfClientPtr makeServerStub() = 0;
40  };
41 
42  template<typename T, typename I1>
43  class StubFactory_1 : public StubFactory
44  {
45  public:
46  RcfClientPtr makeServerStub()
47  {
48  boost::shared_ptr<T> tPtr( new T );
49 
50  boost::shared_ptr< RCF::I_Deref<T> > derefPtr(
51  new RCF::DerefSharedPtr<T>(tPtr) );
52 
53  RcfClientPtr rcfClientPtr =
54  createServerStub( (I1 *) NULL, (T *) NULL, derefPtr);
55 
56  return rcfClientPtr;
57  }
58  };
59 
60 } // namespace RCF
61 
62 #endif // ! INCLUDE_RCF_STUBFACTORY_HPP