freProfileParameters.cxx

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: freProfileParameter.cxx,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 #include "freProfileParameters.h"
00023 
00024 namespace FREE
00025 {
00026 namespace CtrlProfile
00027 {
00028 
00032 
00033 
00034 Parameter*
00035 ProfileParameters::
00036 AddParameter(const std::string& sParameterName, const Parameter::ParameterValueType& valueType,
00037                                                  const std::string& sHint, const unsigned int& iSize, const std::string& sDefaultValue,
00038              const int& iLayerCount, const bool& bDynamic, const unsigned int& iGroup,
00039              const DataAccessType& accessType)
00040 {
00041   Parameter::Pointer smpParameter = GetElement(sParameterName);
00042 
00043   if (smpParameter.IsNull())
00044         {
00045     smpParameter = Parameter::New();
00046         AddElement(smpParameter);
00047         }
00048   else
00049   {
00050     smpParameter->Reset();
00051   };
00052 
00053         smpParameter->SetParameterName(sParameterName);
00054         smpParameter->SetValueType(valueType);
00055         smpParameter->SetHint(sHint);
00056   smpParameter->SetParameterSize(iSize);
00057         smpParameter->SetLayerCount(iLayerCount);
00058         smpParameter->SetIsMultiResDynamic(bDynamic);
00059         smpParameter->SetGroup(iGroup);
00060   smpParameter->SetAccess(accessType);
00061 
00062         if (!smpParameter->GetIsArbitrarilyLayered())
00063         { //If there is a fixed number of layers, default layers will be created anyway
00064     for (int iIndex = 0; iIndex<iLayerCount; iIndex++)
00065     {
00066       smpParameter->AddParameterLayer(false,sDefaultValue);
00067     }
00068         }
00069         else if (sDefaultValue!="")
00070         { //If there is no fixed number of layers, but a default vaule != "" one layer will be created as default
00071       smpParameter->AddParameterLayer(false,sDefaultValue);
00072   }
00073 
00074   return smpParameter.GetPointer();
00075 };
00076 
00077 bool
00078 ProfileParameters::
00079 ParameterExists(const std::string& sParameterName) const
00080 {
00081   return this->GetElementIndex(sParameterName) != ProfileParameters::NULL_Index;
00082 };
00083 
00084 ProfileParameters::
00085 ProfileParameters()
00086 {
00087   Reset();
00088         SetXMLTag(cXML_CP_Parameters);
00089 };
00090 
00091 ProfileParameters::
00092 ProfileParameters( const ProfileParameters& rParameters)
00093 {
00094         SetXMLTag(cXML_CP_Parameters);
00095   *this = rParameters;
00096 };
00097 
00098 ProfileParameters::
00099 ~ProfileParameters()
00100 {
00101   Reset();
00102 };
00103 
00104 void
00105 ProfileParameters::
00106 SubElementLoadProcessing(const std::string& rsXMLSubTag, const std::string& rsXMLSubElement, const std::string& rsXMLSubData)
00107 {
00108   if (rsXMLSubTag==cXML_CP_Parameter)
00109   {
00110     Parameter::Pointer smpNewParameter = Parameter::New();
00111 
00112     try
00113     {
00114       smpNewParameter->LoadFromString(rsXMLSubElement);
00115     }
00116     catchAllNPassMacro("Unknown error occured while loading parameter definition to a  collection.");
00117 
00118     AddElement(smpNewParameter);
00119   }
00120   else if (rsXMLSubTag!=cXML_Text) throwExceptionMacro("Unknown xml tag, unable to load value. Incorrect Tag: " << rsXMLSubTag);
00121 };
00122 
00123 }//end of namespace FREE
00124 }//end of namespace CtrlProfile

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