Scarab  3.2.2
Project 8 C++ Utility Library
factory.hh
Go to the documentation of this file.
1 /*
2  * factory.hh
3  *
4  * created on: Jul 31, 2012
5  * Author: N.S. Oblath
6  *
7  * The factory is a special kind of indexed_factory with a string index.
8  *
9  * Why is factory based on indexed_factory? Because factory existed first with the string index,
10  * and then factories with non-string indices were desired,
11  * so indexed_factory was created as a generalization of factory.
12  *
13  * Note on registrar lifespan: when a registrar is deleted, it un-registers itself from the factory.
14  * This is because the registrar itself is used to create objects, and the act of registering
15  * stores a pointer in the factory. The factory does _not_ assume ownership of the registrar.
16  * Therefore the registrar needs to exist for as long as it might be needed.
17  */
18 
19 #ifndef SCARAB_FACTORY_HH_
20 #define SCARAB_FACTORY_HH_
21 
22 #include "indexed_factory.hh"
23 
24 #include <string>
25 
26 namespace scarab
27 {
28 
29  template< class XBaseType, class... XArgs >
30  using factory = indexed_factory< std::string, XBaseType, XArgs... >;
31 
32  template< class XBaseType, class... XArgs >
33  using registrar = indexed_registrar< std::string, XBaseType, XArgs... >;
34 
35 } /* namespace scarab */
36 #endif /* SCARAB_FACTORY_HH_ */