// ********************************************************************** // // Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved. // // This copy of Ice is licensed to you under the terms described in the // ICE_LICENSE file included in this distribution. // // ********************************************************************** #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* typeId) : _typeId(typeId) { factoryTable->addExceptionFactory(_typeId, new DefaultUserExceptionFactory(_typeId)); } ~DefaultUserExceptionFactoryInit() { factoryTable->removeExceptionFactory(_typeId); } private: const ::std::string _typeId; }; template class DefaultObjectFactoryInit { public: DefaultObjectFactoryInit(const char* typeId) : _typeId(typeId) { factoryTable->addObjectFactory(_typeId, new DefaultObjectFactory(_typeId)); } ~DefaultObjectFactoryInit() { factoryTable->removeObjectFactory(_typeId); } private: const ::std::string _typeId; }; } #endif