00001 #ifndef PSEVT_PROXY_H 00002 #define PSEVT_PROXY_H 00003 00004 //-------------------------------------------------------------------------- 00005 // File and Version Information: 00006 // $Id: Proxy.h 1840 2011-05-07 01:48:35Z salnikov $ 00007 // 00008 // Description: 00009 // Class Proxy. 00010 // 00011 //------------------------------------------------------------------------ 00012 00013 //----------------- 00014 // C/C++ Headers -- 00015 //----------------- 00016 #include <string> 00017 #include <boost/shared_ptr.hpp> 00018 00019 //---------------------- 00020 // Base Class Headers -- 00021 //---------------------- 00022 #include "PSEvt/ProxyI.h" 00023 00024 //------------------------------- 00025 // Collaborating Class Headers -- 00026 //------------------------------- 00027 #include "pdsdata/xtc/Src.hh" 00028 00029 //------------------------------------ 00030 // Collaborating Class Declarations -- 00031 //------------------------------------ 00032 namespace PSEvt { 00033 class ProxyDictI; 00034 } 00035 00036 // --------------------- 00037 // -- Class Interface -- 00038 // --------------------- 00039 00040 namespace PSEvt { 00041 00042 /** 00043 * @ingroup PSEvt 00044 * 00045 * @brief Interface class for type-safe proxy classes. 00046 * 00047 * Proxy dictionary stores proxies of type ProxyI which are not 00048 * type-safe (they work with void pointers). To make code safer 00049 * this class implements ProxyI interface and introduces type-safe 00050 * method to generate typed data. User-level interface should use this 00051 * type instead of ProxyI. 00052 * 00053 * This software was developed for the LCLS project. If you use all or 00054 * part of it, please give an appropriate acknowledgment. 00055 * 00056 * @see ProxyI 00057 * 00058 * @version \$Id: Proxy.h 1840 2011-05-07 01:48:35Z salnikov $ 00059 * 00060 * @author Andrei Salnikov 00061 */ 00062 00063 template <typename T> 00064 class Proxy : public ProxyI { 00065 public: 00066 00067 // Destructor 00068 virtual ~Proxy () {} 00069 00070 protected: 00071 00072 // Default constructor 00073 Proxy () {} 00074 00075 /** 00076 * @brief Get untyped object from the proxy. 00077 * 00078 * The parameters passed to the proxy can be used by the proxy 00079 * to find additional information from the same (or different) 00080 * detector. 00081 * 00082 * This is implementation of ProxyI interface which forwards 00083 * call to the type-safe method getTypedImpl(). 00084 * 00085 * @param[in] dict Proxy dictionary containing this proxy. 00086 * @param[in] source Detector address information 00087 * @param[in] key String key, additional key supplied by user. 00088 * @return Shared pointer of void type. 00089 */ 00090 virtual boost::shared_ptr<void> getImpl(ProxyDictI* dict, 00091 const Pds::Src& source, 00092 const std::string& key) 00093 { 00094 return boost::static_pointer_cast<void>(getTypedImpl(dict, source, key)); 00095 } 00096 00097 /** 00098 * @brief Get the correctly-typed object from the proxy. 00099 * 00100 * @param[in] dict Proxy dictionary containing this proxy. 00101 * @param[in] source Detector address information 00102 * @param[in] key String key, additional key supplied by user. 00103 * @return Shared pointer of the correct type. 00104 */ 00105 virtual boost::shared_ptr<T> getTypedImpl(ProxyDictI* dict, 00106 const Pds::Src& source, 00107 const std::string& key) = 0; 00108 00109 private: 00110 00111 // Data members 00112 }; 00113 00114 } // namespace PSEvt 00115 00116 #endif // PSEVT_PROXY_H