Ice 3.7 C++98 API Reference
Loading...
Searching...
No Matches
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
11namespace IceInternal
12{
13
14class ICE_API FactoryTableInit
15{
16public:
17
18 FactoryTableInit();
19 ~FactoryTableInit();
20};
21
22static FactoryTableInit factoryTableInitializer; // Dummy variable to force initialization of factoryTable
23
24extern ICE_API FactoryTable* factoryTable ICE_GLOBAL_VAR_SUFFIX;
25
26class ICE_API CompactIdInit
27{
28public:
29
30 CompactIdInit(const char*, int);
31 ~CompactIdInit();
32
33private:
34
35 const int _compactId;
36};
37
38template<class E>
39class DefaultUserExceptionFactoryInit
40{
41public:
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
60template<class O>
61class DefaultValueFactoryInit
62{
63public:
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
#define ICE_API
Definition Config.h:197
#define ICE_GLOBAL_VAR_SUFFIX
Definition Config.h:185