// // Copyright (c) ZeroC, Inc. All rights reserved. // #ifndef ICE_FACTORYTABLEINIT_H #define ICE_FACTORYTABLEINIT_H #include #include namespace IceInternal { class ICE_API FactoryTableInit { public: FactoryTableInit(); ~FactoryTableInit(); }; static FactoryTableInit factoryTableInitializer; // Dummy variable to force initialization of factoryTable extern ICE_API FactoryTable* factoryTable; class ICE_API CompactIdInit { public: CompactIdInit(const char*, int); ~CompactIdInit(); private: const int _compactId; }; template class DefaultUserExceptionFactoryInit { public: DefaultUserExceptionFactoryInit(const char* tId) : typeId(tId) { #ifdef ICE_CPP11_MAPPING factoryTable->addExceptionFactory(typeId, defaultUserExceptionFactory); #else factoryTable->addExceptionFactory(typeId, new DefaultUserExceptionFactory(typeId)); #endif } ~DefaultUserExceptionFactoryInit() { factoryTable->removeExceptionFactory(typeId); } const ::std::string typeId; }; template class DefaultValueFactoryInit { public: DefaultValueFactoryInit(const char* tId) : typeId(tId) { #ifdef ICE_CPP11_MAPPING factoryTable->addValueFactory(typeId, defaultValueFactory); #else factoryTable->addValueFactory(typeId, new DefaultValueFactory(typeId)); #endif } ~DefaultValueFactoryInit() { factoryTable->removeValueFactory(typeId); } const ::std::string typeId; }; } #endif