ProxyInterface.h

Go to the documentation of this file.
00001 // Copyright CERN 2012 - Developed in collaboration with GSI
00002 
00003 #ifndef PROXY_INTERFACE_H_
00004 #define PROXY_INTERFACE_H_
00005 
00006 #include <fesa-core/Proxy/ProxyReplyHandler.h>
00007 #include <fesa-core/Exception/FesaException.h>
00008 
00009 #include <cmw-rda/DeviceHandle.h>
00010 
00011 #include <string>
00012 #include <map>
00013 
00014 class rdaRDAService;
00015 
00016 namespace fesa
00017 {
00018 
00026 class ProxyInterface
00027 {
00028   public:
00029 
00033     ProxyInterface();
00034 
00038     ~ProxyInterface();
00039 
00049     //template<typename DataType> void setProperty(const std::string& deviceName,
00050     //               DataType& property) throw(FesaException);
00051 
00063     //template<typename DataType, typename FilterType> void setProperty(const std::string& deviceName,
00064     //                DataType& property,
00065     //                FilterType& filter) throw(FesaException);
00066 
00078     template<typename DataType> void setProperty(const std::string& deviceName,
00079                                                  const std::string& cycleSelector, DataType& property);
00080 
00093     template<typename DataType, typename FilterType> void setProperty(const std::string& deviceName,
00094                                                                       std::string& cycleSelector, DataType& property, FilterType& filter);
00095 
00105     //template<typename DataType> void getProperty(const std::string& deviceName,
00106     //                DataType& property) throw(FesaException);
00107 
00118     template<typename DataType> void getProperty(const std::string& deviceName,
00119                                                  const std::string& cycleSelector, DataType& property);
00120 
00131     //template<typename DataType, typename FilterType> void getProperty(const std::string& deviceName,
00132     //                DataType& property,
00133     //                FilterType& filter) throw(FesaException);
00134 
00146     template<typename DataType, typename FilterType> void getProperty(const std::string& deviceName,
00147                                                                       const std::string& cycleSelector, DataType& property, FilterType& filter);
00148 
00156     void subscribe(const std::string& deviceName, const std::string& propertyName);
00157 
00166     void subscribe(const std::string& deviceName, const std::string& propertyName,
00167                    const std::string& cycleSelector);
00168 
00176     void unsubscribe(const std::string& deviceName, const std::string& propertyName);
00177 
00186     void unsubscribe(const std::string& deviceName, const std::string& propertyName,
00187                      const std::string& cycleSelector);
00188 
00198     void waitNotification(std::string& deviceName, std::string& propertyName, std::string& cycleSelectorName,
00199                           rdaData& value);
00200 
00201   private:
00202 
00211     rdaDeviceHandle* getDeviceHandle(const std::string& deviceName);
00212 
00216     rdaRDAService* rda_;
00217 
00222     std::map<std::string, rdaDeviceHandle*> rdaDeviceHandleCollection_;
00223 
00228     std::map<const std::string, rdaRequest*> subscriptionCollection_;
00229 
00236     void registerDevice(const std::string& deviceName);
00237 
00241     ProxyReplyHandler replyHandler_;
00242 
00243     friend class OnSubscriptionEventSource;
00244 
00245 };
00246 
00247 /*
00248   template<typename DataType> void ProxyInterface::setProperty(const std::string& deviceName,
00249   DataType& property) throw(FesaException)
00250   {
00251   try
00252   {
00253   rdaDeviceHandle* device = ProxyInterface::getDeviceHandle(deviceName);
00254   device->set(property.getPropertyName().c_str(), *(property.getRdaData()));
00255   }
00256   catch(const rdaException& ex)
00257   {
00258   throw FesaException(FesaErrorSettingRdaData.c_str(), ex.getMessage(), __FILE__, __LINE__);
00259   }
00260   }
00261 */
00262 
00263 /*
00264   template<typename DataType, typename FilterType> void ProxyInterface::setProperty(const std::string& deviceName,
00265   DataType& property,
00266   FilterType& filter) throw(FesaException)
00267   {
00268   try
00269   {
00270   rdaDeviceHandle* device = ProxyInterface::getDeviceHandle(deviceName);
00271   device->set(property.getPropertyName().c_str(), *(property.getRdaData()), *(filter.getRdaData()));
00272   }
00273   catch(const rdaException& ex)
00274   {
00275   throw FesaException(FesaErrorSettingRdaData.c_str(), ex.getMessage(), __FILE__, __LINE__);
00276   }
00277   }
00278 */
00279 
00280 template<typename DataType> void ProxyInterface::setProperty(const std::string& deviceName,
00281                                                              const std::string& cycleSelector, DataType& property)
00282 {
00283     try
00284     {
00285         rdaDeviceHandle* device = ProxyInterface::getDeviceHandle(deviceName);
00286         device->set(property.getPropertyName().c_str(), cycleSelector.c_str(), *(property.getRdaData()));
00287     }
00288     catch (const rdaException& ex)
00289     {
00290         throw FesaException(__FILE__, __LINE__, FesaErrorSettingRdaData.c_str(), ex.getMessage());
00291     }
00292 }
00293 
00294 template<typename DataType, typename FilterType> void ProxyInterface::setProperty(const std::string& deviceName,
00295                                                                                   std::string& cycleSelector, DataType& property, FilterType& filter)
00296 {
00297     try
00298     {
00299         rdaDeviceHandle* device = ProxyInterface::getDeviceHandle(deviceName);
00300         device->set(property.getPropertyName().c_str(), cycleSelector.c_str(), *(property.getRdaData()),
00301                     *(filter.getRdaData()));
00302     }
00303     catch (const rdaException& ex)
00304     {
00305         throw FesaException(__FILE__, __LINE__, FesaErrorSettingRdaData.c_str(), ex.getMessage());
00306     }
00307 }
00308 
00309 /*
00310   template<typename DataType> void ProxyInterface::getProperty(const std::string& deviceName,
00311   DataType& property) throw(FesaException)
00312   {
00313   try
00314   {
00315   rdaDeviceHandle* device = ProxyInterface::getDeviceHandle(deviceName);
00316   property.setData(*(device->get(property.getPropertyName().c_str())), false, false, true);
00317   }
00318   catch(const rdaException& ex)
00319   {
00320   throw FesaException(FesaErrorGettingRdaData.c_str(), ex.getMessage(), __FILE__, __LINE__);
00321   }
00322   }
00323 */
00324 
00325 /*
00326   template<typename DataType, typename FilterType> void ProxyInterface::getProperty(const std::string& deviceName,
00327   DataType& property,
00328   FilterType& filter) throw(FesaException)
00329   {
00330   try
00331   {
00332   rdaDeviceHandle* device = ProxyInterface::getDeviceHandle(deviceName);
00333   property.setData((*device->get(property.getPropertyName().c_str(), filter.getRdaData())), false, false, true);
00334   }
00335   catch(const rdaException& ex)
00336   {
00337   throw FesaException(FesaErrorGettingRdaData.c_str(), ex.getMessage(), __FILE__, __LINE__);
00338   }
00339   }
00340 */
00341 
00342 template<typename DataType> void ProxyInterface::getProperty(const std::string& deviceName,
00343                                                              const std::string& cycleSelector, DataType& property)
00344 {
00345     try
00346     {
00347         rdaDeviceHandle* device = ProxyInterface::getDeviceHandle(deviceName);
00348         property.setData((*device->get(property.getPropertyName().c_str(), cycleSelector.c_str())), false, false,
00349                          true);
00350     }
00351     catch (const rdaException& ex)
00352     {
00353         throw FesaException(__FILE__, __LINE__, FesaErrorGettingRdaData.c_str(), ex.getMessage());
00354     }
00355 }
00356 
00357 template<typename DataType, typename FilterType> void ProxyInterface::getProperty(const std::string& deviceName,
00358                                                                                   const std::string& cycleSelector, DataType& property, FilterType& filter)
00359 {
00360     try
00361     {
00362         rdaDeviceHandle* device = ProxyInterface::getDeviceHandle(deviceName);
00363         property.setData((*device->get(property.getPropertyName().c_str(), cycleSelector.c_str(),
00364                                        filter.getRdaData())), false, false, true);
00365     }
00366     catch (const rdaException& ex)
00367     {
00368         throw FesaException(__FILE__, __LINE__, FesaErrorGettingRdaData.c_str(), ex.getMessage());
00369     }
00370 }
00371 
00372 } // fesa
00373 
00374 #endif // PROXY_INTERFACE_H_

Generated on 18 Jan 2013 for Fesa by  doxygen 1.6.1