freParameter.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   F.R.E.E. - flexible registration evaluation engine
00004   Version:   v.1.0.0
00005   Date:      $Date: 2006/09/01 12:00:00 $
00006   Module:    $RCSfile: freParameter.h,v $
00007   Language:  C++
00008 
00009 
00010 
00011   Copyright (c) 2007 Ralf o Floca (Department of Medical Informatics,
00012   Institute for Medical Biometry and Informatics, University of Heidelberg,
00013   Germany). All rights reserved.
00014   See FREECopyright.txt or http://www.mi.med.uni-hd.de/free/copyright.htm
00015   for details.
00016 
00017      This software is distributed WITHOUT ANY WARRANTY; without even 
00018      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00019      PURPOSE.  See the above copyright notices for more information.
00020 
00021 =========================================================================*/
00022 #ifndef __freParameter_h
00023 #define __freParameter_h
00024 
00025 #include "freParameterLayer.h"
00026 #include "freExceptions.h"
00027 
00028 namespace FREE
00029 {
00037   class Parameter: public XMLStreamObject, public itk::LightObject
00038 {
00039 public:
00040   typedef Parameter  Self;
00041   typedef itk::LightObject Superclass;
00042   typedef itk::SmartPointer<Self>        Pointer;
00043   typedef itk::SmartPointer<const Self>  ConstPointer;
00044   
00045 
00048   enum ParameterValueType 
00049   {
00050           PVTBool, 
00052           PVTDouble, 
00053           PVTInteger, 
00054           PVTLong, 
00055           PVTULong, 
00056           PVTString, 
00057           PVTURI, 
00059           PVTIDPath 
00061   };
00062 
00063   typedef ParameterLayer::ValueCountType ValueCountType;
00064   typedef unsigned long LayerCountType;
00065 
00067   itkTypeMacro( Parameter, XMLStreamObject );
00068 
00069   itkNewMacro(Parameter);
00072   static Pointer New(const std::string& sParameterName, const ValueCountType iLayerSize = 1, const LayerCountType iLayerCount = 1, const std::string& sDefaultValue = "");
00073 
00074   void SetParameterName(const std::string& sName) {m_sParameterName = sName; };
00075   const std::string& GetParameterName() const { return m_sParameterName; };
00076 
00079   void SetTemplateID(const std::string& sTemplateID) {m_sTemplateID = sTemplateID; };
00081   const std::string& GetTemplateID() const { return m_sTemplateID; };
00084   bool IsTemplateBased() const {return m_sTemplateID.size()>0;};
00085 
00092   LayerCountType AddParameterLayer(bool bCopyValue = true, const std::string& sNewValue = "");
00093 
00096   void DeleteParameterLayer(const LayerCountType iLayer);
00097 
00099   virtual void Reset();
00100 
00105   void Resize(const ValueCountType iNewSize, const std::string& sNewValue = "");
00106 
00112   void Resize(const ValueCountType iNewSize, const LayerCountType iNewLayerCount, const std::string& sNewValue = "");
00113 
00116   ValueCountType ParameterSize() const;
00117 
00120   LayerCountType LayerCount() const;
00121 
00126   ParameterLayer* GetParameterLayer(const LayerCountType iLayer) const;
00127 
00135   bool GetParameterValue(bool& value, const  ValueCountType iItemPos = 0, const LayerCountType iLayer = 0) const;
00136 
00139   bool GetParameterValue(double& value, const  ValueCountType iItemPos = 0, const LayerCountType iLayer = 0) const;
00140   
00143   bool GetParameterValue(int& value, const  ValueCountType iItemPos = 0, const LayerCountType iLayer = 0) const;
00144 
00147   bool GetParameterValue(long& value, const  ValueCountType iItemPos = 0, const LayerCountType iLayer = 0) const;
00148 
00151   bool GetParameterValue(unsigned long& value, const  ValueCountType iItemPos = 0, const LayerCountType iLayer = 0) const;
00152 
00155   bool GetParameterValue(std::string& value, const  ValueCountType iItemPos = 0, const LayerCountType iLayer = 0) const;
00156 
00163   bool SetParameterValue(const bool value, const  ValueCountType iItemPos = 0, const LayerCountType iLayer = 0);
00164 
00167   bool SetParameterValue(const double value, const  ValueCountType iItemPos = 0, const LayerCountType iLayer = 0);
00168   
00171   bool SetParameterValue(const int value, const  ValueCountType iItemPos = 0, const LayerCountType iLayer = 0);
00172 
00175   bool SetParameterValue(const long value, const  ValueCountType iItemPos = 0, const LayerCountType iLayer = 0);
00176 
00179   bool SetParameterValue(const unsigned long value, const  ValueCountType iItemPos = 0, const LayerCountType iLayer = 0);
00180 
00183   bool SetParameterValue(const std::string& value, const  ValueCountType iItemPos = 0, const LayerCountType iLayer = 0);
00184 
00191   bool SetParameterLayer(const LayerCountType iLayer, const ParameterLayer& rSourceLayer);
00192 
00194   virtual Parameter& operator = (const Parameter& rParameter);
00195 
00196 protected:
00197   Parameter(const std::string& sParameterName, const ValueCountType iLayerSize = 1, const LayerCountType iLayerCount = 1, const std::string& sDefaultValue = "");
00198   Parameter();
00199 
00200   virtual ~Parameter();
00201 
00203   virtual void SubElementLoadProcessing(const std::string& rsXMLSubTag, const std::string& rsXMLSubElement, const std::string& rsXMLSubData);
00204 
00206   virtual std::string SaveData(const unsigned int& iDepth, bool& bHasSubElements) const;
00207 
00209   virtual void AttributesLoadProcessing(const AttributesType& rAttributes);
00210 
00212   virtual void SaveAttributes(AttributesSaveListType& rAttributes) const;
00213 
00214   typedef std::vector<ParameterLayer::Pointer> LayersType; 
00215   
00217   LayersType m_Layers;
00218 
00220   std::string m_sParameterName;
00221 
00227   std::string m_sTemplateID;
00228 
00229   LayerCountType m_iLayerSize;
00230 };
00231 
00232 namespace Convert
00233 {
00234   std::string ToStr(const Parameter::ParameterValueType& pt);
00235   Parameter::ParameterValueType ToParameterValueType(const std::string& sValue);
00236 }
00237 
00238 }//end of namespace FREE
00239 
00240 #endif

Generated at Sat Oct 13 16:56:02 2007 for f.r.e.e. - Flexible Registration and Evaluation Engine by doxygen 1.5.3 written by Dimitri van Heesch, © 1997-2000