Rosetta
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Registrant.hh
Go to the documentation of this file.
1 // -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
2 // vi: set ts=2 noet:
3 //
4 // (c) Copyright Rosetta Commons Member Institutions.
5 // (c) This file is part of the Rosetta software suite and is made available under license.
6 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
7 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
8 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
9 
10 /// @file utility/factory/Registrant.hh
11 /// @brief Factory registrant
12 /// @author Stuart G. Mentzer (Stuart_Mentzer@objexx.com)
13 ///
14 /// @remarks
15 /// @li Registers a concrete product class with its factory when constructed
16 /// @li Use Key pointers when keys are globals that may not be constructed yet
17 
18 
19 #ifndef INCLUDED_utility_factory_Registrant_hh
20 #define INCLUDED_utility_factory_Registrant_hh
21 
22 
23 // Unit headers
25 
26 // Package headers
28 
29 
30 namespace utility {
31 namespace factory {
32 
33 
34 /// @brief Factory registrant
35 template< typename P >
36 class Registrant
37 {
38 
39 
40 public: // Types
41 
42 
43  typedef P Product; // Product
44  typedef Factory< Product > ProductFactory; // Factory
45  typedef typename ProductFactory::Key Key; // Product lookup key
46  typedef typename ProductFactory::KeyP KeyP; // Product lookup key pointer
47  typedef typename ProductFactory::KeyFxn KeyFxn; // Product lookup key function
48  typedef typename ProductFactory::Create Create; // Product creation function
49 
50 
51 private: // Creation
52 
53 
54  /// @brief Copy constructor
55  Registrant( Registrant const & ); // Undefined
56 
57 
58 public: // Creation
59 
60 
61  /// @brief 1 Key constructor
62  inline
64  Key const & key,
65  Create create
66  )
67  {
68  ProductFactory::add( key, create );
69  }
70 
71 
72  /// @brief 1 Key pointer constructor
73  inline
75  KeyP const & key_p,
76  Create create
77  )
78  {
79  ProductFactory::add( key_p, create );
80  }
81 
82 
83  /// @brief 1 Key function constructor
84  inline
86  KeyFxn key_fxn,
87  Create create
88  )
89  {
90  ProductFactory::add( key_fxn, create );
91  }
92 
93 
94  /// @brief 2 Key constructor
95  inline
97  Key const & key1,
98  Key const & key2,
99  Create create
100  )
101  {
102  ProductFactory::add( key1, create );
103  ProductFactory::add( key2, create );
104  }
105 
106 
107  /// @brief 2 Key pointer constructor
108  inline
110  KeyP const & key1_p,
111  KeyP const & key2_p,
112  Create create
113  )
114  {
115  ProductFactory::add( key1_p, create );
116  ProductFactory::add( key2_p, create );
117  }
118 
119 
120  /// @brief 2 Key function constructor
121  inline
123  KeyFxn key1_fxn,
124  KeyFxn key2_fxn,
125  Create create
126  )
127  {
128  ProductFactory::add( key1_fxn, create );
129  ProductFactory::add( key2_fxn, create );
130  }
131 
132 
133  /// @brief 3 Key constructor
134  inline
136  Key const & key1,
137  Key const & key2,
138  Key const & key3,
139  Create create
140  )
141  {
142  ProductFactory::add( key1, create );
143  ProductFactory::add( key2, create );
144  ProductFactory::add( key3, create );
145  }
146 
147 
148  /// @brief 3 Key pointer constructor
149  inline
151  KeyP const & key1_p,
152  KeyP const & key2_p,
153  KeyP const & key3_p,
154  Create create
155  )
156  {
157  ProductFactory::add( key1_p, create );
158  ProductFactory::add( key2_p, create );
159  ProductFactory::add( key3_p, create );
160  }
161 
162 
163  /// @brief 3 Key function constructor
164  inline
166  KeyFxn key1_fxn,
167  KeyFxn key2_fxn,
168  KeyFxn key3_fxn,
169  Create create
170  )
171  {
172  ProductFactory::add( key1_fxn, create );
173  ProductFactory::add( key2_fxn, create );
174  ProductFactory::add( key3_fxn, create );
175  }
176 
177 
178 private: // Assignment
179 
180 
181  /// @brief Copy assignment
182  Registrant &
183  operator =( Registrant const & ); // Undefined
184 
185 
186 }; // Registrant
187 
188 
189 } // namespace factory
190 } // namespace utility
191 
192 
193 #endif // INCLUDED_utility_factory_Registrant_HH
Registrant(Registrant const &)
Copy constructor.
Pluggable factory.
Definition: Factory.fwd.hh:24
Registrant(KeyFxn key1_fxn, KeyFxn key2_fxn, Create create)
2 Key function constructor
Definition: Registrant.hh:122
Registrant(Key const &key, Create create)
1 Key constructor
Definition: Registrant.hh:63
Product::FactoryKeyP KeyP
Definition: Factory.hh:51
Product::FactoryKeyFxn KeyFxn
Definition: Factory.hh:52
static void add(Key const &key, Create create)
Add a Product to the registry.
Definition: Factory.hh:82
Factory registrant.
Product::FactoryKey Key
Definition: Factory.hh:50
Product::FactoryCreate Create
Definition: Factory.hh:55
utility::keys::lookup::key< KeyType > const key
Registrant(KeyFxn key_fxn, Create create)
1 Key function constructor
Definition: Registrant.hh:85
ProductFactory::KeyP KeyP
Definition: Registrant.hh:46
utility::factory::Registrant forward declarations
Registrant(Key const &key1, Key const &key2, Create create)
2 Key constructor
Definition: Registrant.hh:96
ProductFactory::KeyFxn KeyFxn
Definition: Registrant.hh:47
Registrant(Key const &key1, Key const &key2, Key const &key3, Create create)
3 Key constructor
Definition: Registrant.hh:135
Registrant(KeyP const &key_p, Create create)
1 Key pointer constructor
Definition: Registrant.hh:74
Registrant & operator=(Registrant const &)
Copy assignment.
Factory< Product > ProductFactory
Definition: Registrant.hh:44
Registrant(KeyP const &key1_p, KeyP const &key2_p, Create create)
2 Key pointer constructor
Definition: Registrant.hh:109
ProductFactory::Create Create
Definition: Registrant.hh:48
Registrant(KeyP const &key1_p, KeyP const &key2_p, KeyP const &key3_p, Create create)
3 Key pointer constructor
Definition: Registrant.hh:150
Registrant(KeyFxn key1_fxn, KeyFxn key2_fxn, KeyFxn key3_fxn, Create create)
3 Key function constructor
Definition: Registrant.hh:165
ProductFactory::Key Key
Definition: Registrant.hh:45
Pluggable factory.