00001 #ifndef PSEVT_PROXYDICT_H 00002 #define PSEVT_PROXYDICT_H 00003 00004 //-------------------------------------------------------------------------- 00005 // File and Version Information: 00006 // $Id: ProxyDict.h 7525 2014-01-13 19:52:29Z salnikov@SLAC.STANFORD.EDU $ 00007 // 00008 // Description: 00009 // Class ProxyDict. 00010 // 00011 //------------------------------------------------------------------------ 00012 00013 //----------------- 00014 // C/C++ Headers -- 00015 //----------------- 00016 #include <string> 00017 #include <map> 00018 #include <typeinfo> 00019 #include <boost/shared_ptr.hpp> 00020 00021 //---------------------- 00022 // Base Class Headers -- 00023 //---------------------- 00024 #include "PSEvt/ProxyDictI.h" 00025 00026 //------------------------------- 00027 // Collaborating Class Headers -- 00028 //------------------------------- 00029 #include "PSEvt/EventKey.h" 00030 #include "pdsdata/xtc/Src.hh" 00031 00032 //------------------------------------ 00033 // Collaborating Class Declarations -- 00034 //------------------------------------ 00035 00036 // --------------------- 00037 // -- Class Interface -- 00038 // --------------------- 00039 00040 namespace PSEvt { 00041 00042 /** 00043 * @ingroup PSEvt 00044 * 00045 * @brief Implementation of the proxy dictionary interface. 00046 * 00047 * This implementation is based on std::map which matches event keys 00048 * (EventKey class) with the corresponding proxy object. 00049 * 00050 * This software was developed for the LCLS project. If you use all or 00051 * part of it, please give an appropriate acknowledgment. 00052 * 00053 * @version \$Id: ProxyDict.h 7525 2014-01-13 19:52:29Z salnikov@SLAC.STANFORD.EDU $ 00054 * 00055 * @author Andrei Salnikov 00056 */ 00057 00058 class ProxyDict : public ProxyDictI { 00059 public: 00060 00061 // Constructor 00062 ProxyDict(const boost::shared_ptr<AliasMap>& amap); 00063 00064 // Destructor 00065 virtual ~ProxyDict () ; 00066 00067 protected: 00068 00069 /** 00070 * @brief Add one more proxy object to the dictionary. 00071 * 00072 * @param[in] proxy Proxy object for type T. 00073 * @param[in] key Event key for the data object. 00074 */ 00075 virtual void putImpl( const boost::shared_ptr<ProxyI>& proxy, const EventKey& key ); 00076 00077 /** 00078 * @brief Get an object from event 00079 * 00080 * @param[in] typeinfo Dynamic type info object 00081 * @param[in] source Source detector address. 00082 * @param[in] key Optional key to distinguish different objects of the same type. 00083 * @param[out] foundSrc If pointer is non-zero then pointed object will be assigned 00084 * with the exact source address of the returned object. 00085 * @return Shared pointer of void type. 00086 */ 00087 virtual boost::shared_ptr<void> getImpl( const std::type_info* typeinfo, 00088 const Source& source, 00089 const std::string& key, 00090 Pds::Src* foundSrc ); 00091 00092 /** 00093 * @brief Check if proxy of given type exists in the event 00094 * 00095 * @param[in] key Event key for the data object. 00096 * @return true if proxy exists 00097 */ 00098 virtual bool existsImpl(const EventKey& key); 00099 00100 /** 00101 * @brief Remove object of given type from the event 00102 * 00103 * @param[in] key Event key for the data object. 00104 * @return false if object did not exist before this call 00105 */ 00106 virtual bool removeImpl(const EventKey& key); 00107 00108 /** 00109 * @brief Get the list of event keys defined in event 00110 * 00111 * @param[in] source matching source address 00112 * @param[out] keys list of the EventKey objects 00113 */ 00114 virtual void keysImpl(std::list<EventKey>& keys, const Source& source) const; 00115 00116 /** 00117 * @brief Return pointer to alias map 00118 * 00119 * Can return 0 pointer if alias map is not present. 00120 */ 00121 virtual const AliasMap* aliasMap() const { return m_amap.get(); } 00122 00123 private: 00124 00125 typedef boost::shared_ptr<ProxyI> proxy_ptr; 00126 typedef std::map<EventKey,proxy_ptr> Dict; 00127 00128 // Data members 00129 Dict m_dict; 00130 boost::shared_ptr<AliasMap> m_amap; 00131 00132 }; 00133 00134 } // namespace PSEvt 00135 00136 #endif // PSEVT_PROXYDICT_H