/** * Copyright - See the COPYRIGHT that is included with this distribution. * pvAccessCPP is distributed subject to a Software License Agreement found * in file LICENSE that is included with this distribution. */ #ifndef INTROSPECTIONREGISTRY_H #define INTROSPECTIONREGISTRY_H #include #include #ifdef epicsExportSharedSymbols # define introspectionRegistryEpicsExportSharedSymbols # undef epicsExportSharedSymbols #endif #include #include #include #include #include #include #include #include #ifdef introspectionRegistryEpicsExportSharedSymbols # define epicsExportSharedSymbols # undef introspectionRegistryEpicsExportSharedSymbols #endif // TODO check for memory leaks namespace epics { namespace pvAccess { typedef std::map registryMap_t; /** * PVData Structure registry. * Registry is used to cache introspection interfaces to minimize network traffic. * @author gjansa */ class IntrospectionRegistry : public epics::pvData::NoDefaultMethods { public: IntrospectionRegistry(); virtual ~IntrospectionRegistry(); /** * Resets registry, i.e. must be done when transport is changed (server restarted). */ void reset(); /** * Get introspection interface for given ID. * * @param id id of the introspection interface to get * * @return Field instance for given ID. */ epics::pvData::FieldConstPtr getIntrospectionInterface(const epics::pvData::int16 id); /** * Registers introspection interface with given ID. Always INCOMING. * * @param id id of the introspection interface to register * @param field introspection interface to register */ void registerIntrospectionInterface(const epics::pvData::int16 id, epics::pvData::FieldConstPtr const & field); /** * Registers introspection interface and get it's ID. Always OUTGOING. * If it is already registered only preassigned ID is returned. * * TODO !!!!!!this can get very slow in large maps. We need to change this !!!!!! * * @param field introspection interface to register * * @return id of given introspection interface */ epics::pvData::int16 registerIntrospectionInterface(epics::pvData::FieldConstPtr const & field, bool& existing); /** * Serializes introspection interface * * @param field * @param buffer * @param control */ void serialize(epics::pvData::FieldConstPtr const & field, epics::pvData::ByteBuffer* buffer, epics::pvData::SerializableControl* control); /** * Deserializes introspection interface * * TODO * * @param buffer * @param control * * @return Field deserialized from the buffer. */ epics::pvData::FieldConstPtr deserialize(epics::pvData::ByteBuffer* buffer, epics::pvData::DeserializableControl* control); /** * Null type. */ const static epics::pvData::int8 NULL_TYPE_CODE; /** * Serialization contains only an ID (that was assigned by one of the previous FULL_WITH_ID descriptions). */ const static epics::pvData::int8 ONLY_ID_TYPE_CODE; /** * Serialization contains an ID (that can be used later, if cached) and full interface description. */ const static epics::pvData::int8 FULL_WITH_ID_TYPE_CODE; private: registryMap_t _registry; epics::pvData::int16 _pointer; /** * Field factory. */ static epics::pvData::FieldCreatePtr _fieldCreate; bool registryContainsValue(epics::pvData::FieldConstPtr const & field, epics::pvData::int16& key); }; }} #endif /* INTROSPECTIONREGISTRY_H */