Line data Source code
1 : /*
2 : * Copyright (c) 2017 Juniper Networks, Inc. All rights reserved.
3 : * Copyright Contributors to the OpenSDN project
4 : */
5 : #ifndef __CONFIG__CONFIG_FACTORY_H__
6 : #define __CONFIG__CONFIG_FACTORY_H__
7 :
8 : #include <string>
9 : #include <vector>
10 :
11 : #include <boost/function.hpp>
12 : #include "base/factory.h"
13 :
14 : namespace cass { namespace cql { class CqlIf; } }
15 : using cass::cql::CqlIf;
16 :
17 : namespace etcd { namespace etcdql { class EtcdIf; } }
18 : using etcd::etcdql::EtcdIf;
19 :
20 : class ConfigAmqpChannel;
21 : class ConfigCassandraClient;
22 : class ConfigCassandraPartition;
23 : class ConfigEtcdClient;
24 : class ConfigEtcdPartition;
25 : class ConfigClientManager;
26 : class ConfigJsonParserBase;
27 : struct ConfigClientOptions;
28 : class EventManager;
29 :
30 : struct ConfigStaticObjectFactory : public StaticObjectFactory {
31 :
32 : // The overload for ConfigCassandraClient (because of references)
33 : template <class Base, class T1, class T2, class T3, class T4>
34 : static typename FactoryTypes<Base, T1*, T2*, const T3&, T4>::BasePointer
35 3677 : CreateRef(T1* arg1, T2* arg2, const T3& arg3, T4 arg4) {
36 : return FactoryRecord<Base, T1*, T2*, const T3&, T4>::
37 3677 : create_func_(arg1, arg2, arg3, arg4);
38 : }
39 :
40 : // The overload for CqlIf (because of references)
41 : template <class Base, class T1, class T2, class T3>
42 : static typename FactoryTypes<Base, T1*, const T2&, int, const T3&, const T3&, bool, const T3&, bool>::BasePointer
43 : CreateRef(T1 *arg1, const T2& arg2, int arg3, const T3& arg4, const T3& arg5, bool arg6, const T3&arg7, bool arg8) {
44 : return FactoryRecord<Base, T1*, const T2&, int, const T3&, const T3&, bool, const T3&, bool>::
45 : create_func_(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
46 : }
47 :
48 : // The overload for CqlIf (because of references)
49 : template <class Base, class T1, class T2, class T3>
50 : static typename FactoryTypes<Base, T1*, const T2&, int, const T3&, const T3&, bool, const T3&>::BasePointer
51 3677 : CreateRef(T1 *arg1, const T2& arg2, int arg3, const T3& arg4, const T3& arg5, bool arg6, const T3&arg7) {
52 : return FactoryRecord<Base, T1*, const T2&, int, const T3&, const T3&, bool, const T3&>::
53 3677 : create_func_(arg1, arg2, arg3, arg4, arg5, arg6, arg7);
54 : }
55 :
56 : };
57 :
58 : using ConfigJsonParserRec =
59 : ConfigStaticObjectFactory::FactoryRecord<ConfigJsonParserBase>;
60 :
61 : using ConfigAmqpChannelRec =
62 : ConfigStaticObjectFactory::FactoryRecord<ConfigAmqpChannel>;
63 :
64 : using ConfigCassandraClientRec =
65 : ConfigStaticObjectFactory::FactoryRecord<ConfigCassandraClient,
66 : ConfigClientManager *,
67 : EventManager *,
68 : const ConfigClientOptions &,
69 : int>;
70 :
71 : using ConfigCassandraPartitionRec =
72 : ConfigStaticObjectFactory::FactoryRecord<ConfigCassandraPartition,
73 : ConfigCassandraClient *,
74 : size_t>;
75 :
76 : using CqlIfRec1 =
77 : ConfigStaticObjectFactory::FactoryRecord<CqlIf,
78 : EventManager *,
79 : const std::vector<std::string, std::allocator<std::string>>&,
80 : int,
81 : const std::string &,
82 : const std::string &,
83 : bool,
84 : const std::string &,
85 : bool>;
86 :
87 : using CqlIfRec2 =
88 : ConfigStaticObjectFactory::FactoryRecord<CqlIf,
89 : EventManager *,
90 : const std::vector<std::string, std::allocator<std::string>>&,
91 : int,
92 : const std::string &,
93 : const std::string &,
94 : bool,
95 : const std::string &>;
96 :
97 : //template<> struct ConfigStaticObjectFactory::CastTo<ConfigAmqpChannel> {using BaseType = ConfigAmqpChannel;};
98 :
99 : //To be defined in a corresponding module
100 : //template<> struct ConfigStaticObjectFactory::CastTo<ConfigJsonParser> {using BaseType = ConfigJsonParserBase;};
101 :
102 : //template<> struct ConfigStaticObjectFactory::CastTo<ConfigCassandraClient> {using BaseType = ConfigCassandraClient;};
103 :
104 : //template<> struct ConfigStaticObjectFactory::CastTo<ConfigCassandraPartition> {using BaseType = ConfigCassandraPartition;};
105 :
106 : //template<> struct ConfigStaticObjectFactory::CastTo<CqlIf> {using BaseType = CqlIf;};
107 :
108 : /*
109 : Etcd client was disabled in SConscript
110 : template<> struct ConfigStaticObjectFactory::CastTo<ConfigEtcdClient> {using BaseType = ConfigEtcdClient;};
111 :
112 : template<> struct ConfigStaticObjectFactory::CastTo<ConfigEtcdPartition> {using BaseType = ConfigEtcdPartition;};
113 :
114 : template<> struct ConfigStaticObjectFactory::CastTo<EtcdIf> {using BaseType = EtcdIf;};
115 : */
116 :
117 : #endif // __CONFIG__CONFIG_FACTORY_H__
|