Gaudi Framework, version v25r2

Home   Generated: Wed Jun 4 2014
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
PluginService.h
Go to the documentation of this file.
1 #ifndef _GAUDI_PLUGIN_SERVICE_H_
2 #define _GAUDI_PLUGIN_SERVICE_H_
3 /*****************************************************************************\
4 * (c) Copyright 2013 CERN *
5 * *
6 * This software is distributed under the terms of the GNU General Public *
7 * Licence version 3 (GPL Version 3), copied verbatim in the file "LICENCE". *
8 * *
9 * In applying this licence, CERN does not waive the privileges and immunities *
10 * granted to it by virtue of its status as an Intergovernmental Organization *
11 * or submit itself to any jurisdiction. *
12 \*****************************************************************************/
13 
15 
16 #include <string>
17 #include <typeinfo>
19 
20 #define DECLARE_FACTORY_WITH_ID(type, id, factory) \
21  _INTERNAL_DECLARE_FACTORY(type, id, factory, __LINE__)
22 
23 #define DECLARE_FACTORY(type, factory) \
24  DECLARE_FACTORY_WITH_ID(type, \
25  ::Gaudi::PluginService::Details::demangle<type>(), factory)
26 
27 #define DECLARE_FACTORY_WITH_CREATOR_AND_ID(type, typecreator, id, factory) \
28  _INTERNAL_DECLARE_FACTORY_WITH_CREATOR(type, typecreator, id, factory, __LINE__)
29 
30 #define DECLARE_FACTORY_WITH_CREATOR(type, typecreator, factory) \
31  DECLARE_FACTORY_WITH_CREATOR_AND_ID(type, typecreator, \
32  ::Gaudi::PluginService::Details::demangle<type>(), factory)
33 
34 #define DECLARE_COMPONENT(type) \
35  DECLARE_FACTORY(type, type::Factory)
36 
37 #define DECLARE_COMPONENT_WITH_ID(type, id) \
38  DECLARE_FACTORY_WITH_ID(type, id, type::Factory)
39 
40 namespace Gaudi { namespace PluginService {
41 
43  template <typename R>
44  class Factory0 {
45  public:
46  typedef R ReturnType;
47  typedef R (*FuncType)();
48 
49  static ReturnType create(const std::string& id) {
50  const FuncType c = Details::getCreator<FuncType>(id);
51  return c ? (*c)() : 0;
52  }
53 
54  template <typename T>
55  static ReturnType create(const T& id) {
56  std::ostringstream o; o << id;
57  return create(o.str());
58  }
59  };
60 
62  template <typename R, typename A1>
63  class Factory1 {
64  public:
65  typedef R ReturnType;
66  typedef A1 Arg1Type;
67  typedef R (*FuncType)(Arg1Type);
68 
69  static ReturnType create(const std::string& id,
70  Arg1Type a1) {
71  const FuncType c = Details::getCreator<FuncType>(id);
72  return c ? (*c)(a1) : 0;
73  }
74 
75  template <typename T>
76  static ReturnType create(const T& id,
77  Arg1Type a1) {
78  std::ostringstream o; o << id;
79  return create(o.str(), a1);
80  }
81  };
82 
84  template <typename R, typename A1, typename A2>
85  class Factory2 {
86  public:
87  typedef R ReturnType;
88  typedef A1 Arg1Type;
89  typedef A2 Arg2Type;
90  typedef R (*FuncType)(Arg1Type, Arg2Type);
91 
92  static ReturnType create(const std::string& id,
93  Arg1Type a1,
94  Arg2Type a2) {
95  const FuncType c = Details::getCreator<FuncType>(id);
96  return c ? (*c)(a1, a2) : 0;
97  }
98 
99  template <typename T>
100  static ReturnType create(const T& id,
101  Arg1Type a1,
102  Arg2Type a2) {
103  std::ostringstream o; o << id;
104  return create(o.str(), a1, a2);
105  }
106  };
107 
109  template <typename R, typename A1, typename A2, typename A3>
110  class Factory3 {
111  public:
112  typedef R ReturnType;
113  typedef A1 Arg1Type;
114  typedef A2 Arg2Type;
115  typedef A3 Arg3Type;
116  typedef R (*FuncType)(Arg1Type, Arg2Type, Arg3Type);
117 
118  static ReturnType create(const std::string& id,
119  Arg1Type a1,
120  Arg2Type a2,
121  Arg3Type a3) {
122  const FuncType c = Details::getCreator<FuncType>(id);
123  return c ? (*c)(a1, a2, a3) : 0;
124  }
125 
126  template <typename T>
127  static ReturnType create(const T& id,
128  Arg1Type a1,
129  Arg2Type a2,
130  Arg3Type a3) {
131  std::ostringstream o; o << id;
132  return create(o.str(), a1, a2, a3);
133  }
134  };
135 
136  class GAUDIPS_EXPORT Exception: public std::exception {
137  public:
138  Exception(const std::string& msg);
139  virtual ~Exception() throw();
140  virtual const char* what() const throw();
141  private:
142  std::string m_msg;
143  };
144 }}
145 
146 #endif //_GAUDI_PLUGIN_SERVICE_H_

Generated at Wed Jun 4 2014 14:48:57 for Gaudi Framework, version v25r2 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004