1 // 2 // Copyright (c) ZeroC, Inc. All rights reserved. 3 // 4 5 #ifndef ICE_FACTORYTABLE_H 6 #define ICE_FACTORYTABLE_H 7 8 #include <IceUtil/Mutex.h> 9 #include <Ice/UserExceptionFactory.h> 10 #include <Ice/ValueFactory.h> 11 12 namespace Ice 13 { 14 15 /** 16 * The base class for a compact ID resolver. Subclasses must implement resolve. 17 * The resolver can be installed via InitializationData. 18 * \headerfile Ice/Ice.h 19 */ 20 class ICE_API CompactIdResolver : public IceUtil::Shared 21 { 22 public: 23 24 /** 25 * Called by the Ice run time when a compact ID must be translated into a type ID. 26 * @param id The compact ID. 27 * @return The fully-scoped Slice type ID, or an empty string if the compact ID is unknown. 28 */ 29 virtual ::std::string resolve(Ice::Int id) const = 0; 30 }; 31 typedef IceUtil::Handle<CompactIdResolver> CompactIdResolverPtr; 32 33 } 34 35 namespace IceInternal 36 { 37 38 class ICE_API FactoryTable : private IceUtil::noncopyable 39 { 40 public: 41 42 void addExceptionFactory(const ::std::string&, ICE_IN(ICE_DELEGATE(::Ice::UserExceptionFactory))); 43 ICE_DELEGATE(::Ice::UserExceptionFactory) getExceptionFactory(const ::std::string&) const; 44 void removeExceptionFactory(const ::std::string&); 45 46 void addValueFactory(const ::std::string&, ICE_IN(ICE_DELEGATE(::Ice::ValueFactory))); 47 ICE_DELEGATE(::Ice::ValueFactory) getValueFactory(const ::std::string&) const; 48 void removeValueFactory(const ::std::string&); 49 50 void addTypeId(int, const ::std::string&); 51 std::string getTypeId(int) const; 52 void removeTypeId(int); 53 54 private: 55 56 IceUtil::Mutex _m; 57 58 typedef ::std::pair< ICE_DELEGATE(::Ice::UserExceptionFactory), int> EFPair; 59 typedef ::std::map< ::std::string, EFPair> EFTable; 60 EFTable _eft; 61 62 typedef ::std::pair< ICE_DELEGATE(::Ice::ValueFactory), int> VFPair; 63 typedef ::std::map< ::std::string, VFPair> VFTable; 64 VFTable _vft; 65 66 typedef ::std::pair< ::std::string, int> TypeIdPair; 67 typedef ::std::map<int, TypeIdPair> TypeIdTable; 68 TypeIdTable _typeIdTable; 69 }; 70 71 } 72 73 #endif 74