RCFProto

- Main Page
- Classes
- Files

- File List

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 template<typename T, typename I1, typename I2>
61 class StubFactory_2 : public StubFactory
62 {
63 public:
64 RcfClientPtr makeServerStub()
65 {
66 boost::shared_ptr<T> tPtr( new T );
67
68 boost::shared_ptr< RCF::I_Deref<T> > derefPtr(
69 new RCF::DerefSharedPtr<T>(tPtr) );
70
71 RcfClientPtr rcfClientPtr =
72 createServerStub( (I1 *) NULL, (T *) NULL, derefPtr);
73
74 {
75 RcfClientPtr mergeePtr = createServerStub(
76 (I2 *) 0,
77 (T *) 0,
78 derefPtr);
79
80 rcfClientPtr->getServerStub().merge(mergeePtr);
81 }
82
83 return rcfClientPtr;
84 }
85 };
86
87 template<typename T, typename I1, typename I2, typename I3>
88 class StubFactory_3 : public StubFactory
89 {
90 public:
91 RcfClientPtr makeServerStub()
92 {
93 boost::shared_ptr<T> tPtr( new T );
94
95 boost::shared_ptr< RCF::I_Deref<T> > derefPtr(
96 new RCF::DerefSharedPtr<T>(tPtr) );
97
98 RcfClientPtr rcfClientPtr =
99 createServerStub( (I1 *) NULL, (T *) NULL, derefPtr);
100
101 {
102 RcfClientPtr mergeePtr = createServerStub(
103 (I2 *) 0,
104 (T *) 0,
105 derefPtr);
106
107 rcfClientPtr->getServerStub().merge(mergeePtr);
108 }
109
110 {
111 RcfClientPtr mergeePtr = createServerStub(
112 (I3 *) 0,
113 (T *) 0,
114 derefPtr);
115
116 rcfClientPtr->getServerStub().merge(mergeePtr);
117 }
118
119 return rcfClientPtr;
120 }
121 };
122
123 template<typename T, typename I1, typename I2, typename I3, typename I4>
124 class StubFactory_4 : public StubFactory
125 {
126 public:
127 RcfClientPtr makeServerStub()
128 {
129 boost::shared_ptr<T> tPtr( new T );
130
131 boost::shared_ptr< RCF::I_Deref<T> > derefPtr(
132 new RCF::DerefSharedPtr<T>(tPtr) );
133
134 RcfClientPtr rcfClientPtr =
135 createServerStub( (I1 *) NULL, (T *) NULL, derefPtr);
136
137 {
138 RcfClientPtr mergeePtr = createServerStub(
139 (I2 *) 0,
140 (T *) 0,
141 derefPtr);
142
143 rcfClientPtr->getServerStub().merge(mergeePtr);
144 }
145
146 {
147 RcfClientPtr mergeePtr = createServerStub(
148 (I3 *) 0,
149 (T *) 0,
150 derefPtr);
151
152 rcfClientPtr->getServerStub().merge(mergeePtr);
153 }
154
155 {
156 RcfClientPtr mergeePtr = createServerStub(
157 (I4 *) 0,
158 (T *) 0,
159 derefPtr);
160
161 rcfClientPtr->getServerStub().merge(mergeePtr);
162 }
163
164 return rcfClientPtr;
165 }
166 };
167
168 } // namespace RCF
169
170 #endif // ! INCLUDE_RCF_STUBFACTORY_HPP