SheafSystem  0.0.0.0
factory_2.h
Go to the documentation of this file.
1 
2 //
3 // Copyright (c) 2014 Limit Point Systems, Inc.
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 
20 
21 #ifndef FACTORY_2_H
22 #define FACTORY_2_H
23 
24 #ifndef SHEAF_DLL_SPEC_H
25 #include "SheafSystem/sheaf_dll_spec.h"
26 #endif
27 
28 #ifndef STD_IOSTREAM_H
29 #include "SheafSystem/std_iostream.h"
30 #endif
31 
32 #ifndef STD_MAP_H
33 #include "SheafSystem/std_map.h"
34 #endif
35 
36 #ifndef STD_STRING_H
37 #include "SheafSystem/std_string.h"
38 #endif
39 
40 namespace sheaf
41 {
42 
43 class namespace_poset;
44 class arg_list;
45 
46 template <typename T>
47 class rc_ptr;
48 
49 // Forward declarations to enable friend declaration.
50 
51 template <typename T, typename R>
52 class factory_2;
53 
54 template <typename T, typename R>
55 ostream& operator << (ostream &os, const factory_2<T, R>& xf);
56 
57 
69 template <typename T, typename R = T*>
70 class factory_2
71 {
72  friend ostream& operator << <T, R> (ostream& xos, const factory_2<T, R>& xf);
73 
74  // ===========================================================
76  // ===========================================================
78 
79 public:
80 
84  factory_2();
85 
89  virtual ~factory_2();
90 
91 // ///
92 // /// Creates an instance of type xclient_class_name.
93 // ///
94 // R new_instance(const string& xclient_class_name);
95 
99  R new_instance(const string& xclient_class_name, const arg_list& xargs);
100 
104  void insert_prototype(T* xprototype);
105 
109  void delete_prototype(const string& xclass_name);
110 
115  bool contains_prototype(const string& xclass_name) const;
116 
117 protected:
118 
119 private:
120 
125  factory_2(const factory_2& xother);
126 
130  typedef map<string, T*> prototypes_map_type;
131 
135  prototypes_map_type _prototypes_map;
136 
138 };
139 
140 // ===========================================================
141 // NON-MEMBER FUNCTIONS
142 // ===========================================================
143 
147 template <typename T, typename R>
148 ostream& operator << (ostream& xos, const factory_2<T, R>& xf);
149 
150 } // namespace sheaf
151 
152 #endif // ifndef FACTORY_2_H
R new_instance(const string &xclient_class_name, const arg_list &xargs)
Creates an instance of type xclient_class_name with arguments xargs.
A whitespace separated list of arguments. Insertion operaters are used to insert arguments into the l...
Definition: arg_list.h:63
factory_2()
Default constructor.
void insert_prototype(T *xprototype)
Sets xprototype as the prototype for its client class.
A factory for instanting descendants of an abstract type T, given the class name of the descendant...
Definition: factory_2.h:52
bool contains_prototype(const string &xclass_name) const
True if the set of prototypes contains a prototype for handles of type xclass_name.
void delete_prototype(const string &xclass_name)
Removes the prototype for handles of type xclass_name.
Namespace for the sheaves component of the sheaf system.
Reference-counted pointer to object of type T. T must be an implementation of concept class rc_any...
Definition: factory_2.h:47
virtual ~factory_2()
Destructor.