Ice 3.7 C++11 API Reference
FactoryTableInit.h
Go to the documentation of this file.
1 //
2 // Copyright (c) ZeroC, Inc. All rights reserved.
3 //
4 
5 #ifndef ICE_FACTORYTABLEINIT_H
6 #define ICE_FACTORYTABLEINIT_H
7 
8 #include <Ice/FactoryTable.h>
10 
11 namespace IceInternal
12 {
13 
14 class ICE_API FactoryTableInit
15 {
16 public:
17 
18  FactoryTableInit();
19  ~FactoryTableInit();
20 };
21 
22 static FactoryTableInit factoryTableInitializer; // Dummy variable to force initialization of factoryTable
23 
24 extern ICE_API FactoryTable* factoryTable ICE_GLOBAL_VAR_SUFFIX;
25 
26 class ICE_API CompactIdInit
27 {
28 public:
29 
30  CompactIdInit(const char*, int);
31  ~CompactIdInit();
32 
33 private:
34 
35  const int _compactId;
36 };
37 
38 template<class E>
39 class DefaultUserExceptionFactoryInit
40 {
41 public:
42 
43  DefaultUserExceptionFactoryInit(const char* tId) : typeId(tId)
44  {
45 #ifdef ICE_CPP11_MAPPING
46  factoryTable->addExceptionFactory(typeId, defaultUserExceptionFactory<E>);
47 #else
48  factoryTable->addExceptionFactory(typeId, new DefaultUserExceptionFactory<E>(typeId));
49 #endif
50  }
51 
52  ~DefaultUserExceptionFactoryInit()
53  {
54  factoryTable->removeExceptionFactory(typeId);
55  }
56 
57  const ::std::string typeId;
58 };
59 
60 template<class O>
61 class DefaultValueFactoryInit
62 {
63 public:
64 
65  DefaultValueFactoryInit(const char* tId) : typeId(tId)
66  {
67 #ifdef ICE_CPP11_MAPPING
68  factoryTable->addValueFactory(typeId, defaultValueFactory<O>);
69 #else
70  factoryTable->addValueFactory(typeId, new DefaultValueFactory<O>(typeId));
71 #endif
72  }
73 
74  ~DefaultValueFactoryInit()
75  {
76  factoryTable->removeValueFactory(typeId);
77  }
78 
79  const ::std::string typeId;
80 };
81 
82 }
83 
84 #endif
ICE_GLOBAL_VAR_SUFFIX
#define ICE_GLOBAL_VAR_SUFFIX
Definition: Config.h:185
DefaultValueFactory.h
ICE_API
#define ICE_API
Definition: Config.h:197
FactoryTable.h