Image Component Library (ICL)
|
00001 /******************************************************************** 00002 ** Image Component Library (ICL) ** 00003 ** ** 00004 ** Copyright (C) 2006-2013 CITEC, University of Bielefeld ** 00005 ** Neuroinformatics Group ** 00006 ** Website: www.iclcv.org and ** 00007 ** http://opensource.cit-ec.de/projects/icl ** 00008 ** ** 00009 ** File : ICLUtils/src/ICLUtils/ConfigurableProxy.h ** 00010 ** Module : ICLUtils ** 00011 ** Authors: Viktor Richter ** 00012 ** ** 00013 ** ** 00014 ** GNU LESSER GENERAL PUBLIC LICENSE ** 00015 ** This file may be used under the terms of the GNU Lesser General ** 00016 ** Public License version 3.0 as published by the ** 00017 ** ** 00018 ** Free Software Foundation and appearing in the file LICENSE.LGPL ** 00019 ** included in the packaging of this file. Please review the ** 00020 ** following information to ensure the license requirements will ** 00021 ** be met: http://www.gnu.org/licenses/lgpl-3.0.txt ** 00022 ** ** 00023 ** The development of this software was supported by the ** 00024 ** Excellence Cluster EXC 277 Cognitive Interaction Technology. ** 00025 ** The Excellence Cluster EXC 277 is a grant of the Deutsche ** 00026 ** Forschungsgemeinschaft (DFG) in the context of the German ** 00027 ** Excellence Initiative. ** 00028 ** ** 00029 ********************************************************************/ 00030 00031 #pragma once 00032 00033 #include <ICLUtils/CompatMacros.h> 00034 #include <ICLUtils/Configurable.h> 00035 00036 namespace icl{ 00037 namespace utils{ 00038 00040 class ConfigurableProxy{ 00041 private: 00042 mutable Mutex m_configurableLock; 00043 Configurable* m_intConfigurable; 00044 00045 public: 00046 00048 virtual ~ConfigurableProxy(){} 00049 00051 ConfigurableProxy(Configurable* c=NULL) : m_intConfigurable(c){} 00052 00054 void setInternalConfigurable(Configurable* c=NULL){ 00055 Mutex::Locker l(m_configurableLock); 00056 m_intConfigurable = c; 00057 } 00058 00060 Configurable* getInternalConfigurable() const{ 00061 Mutex::Locker l(m_configurableLock); 00062 ICLASSERT_THROW(m_intConfigurable,ICLException("ConfigurableProxy: internal Configurable is null")); 00063 return m_intConfigurable; 00064 } 00065 00067 void setPropertyValue(const std::string &propertyName, const Any &value) throw (ICLException){ 00068 getInternalConfigurable() -> setPropertyValue(propertyName, value); 00069 } 00070 00072 std::vector<std::string> getPropertyList() const{ 00073 return getInternalConfigurable() -> getPropertyList(); 00074 } 00075 00077 bool supportsProperty(const std::string &propertyName) const{ 00078 return getInternalConfigurable() -> supportsProperty(propertyName); 00079 } 00080 00082 void saveProperties(const std::string &filename, const std::vector<std::string> &propertiesToSkip=Configurable::EMPTY_VEC) const{ 00083 getInternalConfigurable() -> saveProperties(filename, propertiesToSkip); 00084 } 00085 00087 void loadProperties(const std::string &filename,const std::vector<std::string> &propertiesToSkip=Configurable::EMPTY_VEC){ 00088 getInternalConfigurable() -> loadProperties(filename, propertiesToSkip); 00089 } 00090 00092 std::string getPropertyType(const std::string &propertyName) const{ 00093 return getInternalConfigurable() -> getPropertyType(propertyName); 00094 } 00095 00097 std::string getPropertyInfo(const std::string &propertyName) const{ 00098 return getInternalConfigurable() -> getPropertyInfo(propertyName); 00099 00100 } 00101 00103 Any getPropertyValue(const std::string &propertyName) const{ 00104 return getInternalConfigurable() -> getPropertyValue(propertyName); 00105 } 00106 00108 std::string getPropertyToolTip(const std::string &propertyName) const{ 00109 return getInternalConfigurable() -> getPropertyToolTip(propertyName); 00110 } 00111 00113 int getPropertyVolatileness(const std::string &propertyName) const{ 00114 return getInternalConfigurable() -> getPropertyVolatileness(propertyName); 00115 } 00116 00118 void syncChangesTo(Configurable *configurables, int num=1) { 00119 getInternalConfigurable()->syncChangesTo(configurables,num); 00120 } 00121 00123 void syncChangesTo(ConfigurableProxy *configurable){ 00124 getInternalConfigurable()->syncChangesTo(configurable->getInternalConfigurable()); 00125 } 00126 }; 00127 } // namespace utils 00128 } 00129