freStatisticDictionary.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: freStatisticDictionary.cxx,v $
00007   Language:  C++
00008 
00009 
00010   Copyright (c) 2007 Ralf o Floca (Department of Medical Informatics,
00011   Institute for Medical Biometry and Informatics, University of Heidelberg,
00012   Germany). All rights reserved.
00013   See FREECopyright.txt or http://www.mi.med.uni-hd.de/free/copyright.htm
00014   for details.
00015 
00016      This software is distributed WITHOUT ANY WARRANTY; without even 
00017      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00018      PURPOSE.  See the above copyright notices for more information.
00019 
00020 =========================================================================*/
00021 
00022 #include "freStatisticDictionary.h"
00023 #include "freConvert.h"
00024 
00025 namespace FREE
00026 {
00027 
00031 
00032 StatisticValueDefinition*
00033 StatisticDictionary::
00034 AddValueDefinition()
00035 {
00036   StatisticValueDefinition::Pointer smpNewEntry = StatisticValueDefinition::New();
00037 
00038   if (this->m_ValueDefs.Size()>0) smpNewEntry->SetRefID(m_ValueDefs.GetElement(m_ValueDefs.Size()-1)->GetRefID()+1);
00039   else smpNewEntry->SetRefID(1);
00040   this->m_ValueDefs.AddElement(smpNewEntry);
00041 
00042   return smpNewEntry;
00043 };
00044 
00045 StatisticValueDefinition*
00046 StatisticDictionary::
00047 AddValueDefinition(const std::string& sIDPath, const std::string& sName, const std::string& sDescription)
00048 {
00049   StatisticValueDefinition::Pointer smpNewEntry = AddValueDefinition();
00050   smpNewEntry->SetIDPath(sIDPath);
00051   smpNewEntry->SetName(sName);
00052   smpNewEntry->SetDescription(sDescription);
00053   return smpNewEntry;
00054 };
00055 
00056 StatisticValueDefinition*
00057 StatisticDictionary::
00058 GetValueDefinitionByName(const std::string& sIDPath, const std::string& sName)
00059 {
00060   for (ValueDefinitionsType::ElementsCountType index = 0; index< this->m_ValueDefs.Size(); index++)
00061   {
00062     StatisticValueDefinition::Pointer smpEntry = m_ValueDefs.GetElement(index);
00063     if ((smpEntry->GetName() == sName)&&(smpEntry->GetIDPath() == sIDPath)) return smpEntry;
00064   }
00065   return NULL;
00066 };
00067 
00068 StatisticValueDefinition*
00069 StatisticDictionary::
00070 GetValueDefinitionByIndex(const IndexType& index)
00071 {
00072   return m_ValueDefs.GetElement(index);
00073 };
00074 
00075 StatisticValueDefinition*
00076 StatisticDictionary::
00077 GetValueDefinitionByID(const ValueIDType& id)
00078 {
00079   for (ValueDefinitionsType::ElementsCountType index = 0; index< this->m_ValueDefs.Size(); index++)
00080   {
00081     StatisticValueDefinition::Pointer smpEntry = m_ValueDefs.GetElement(index);
00082     if (smpEntry->GetRefID() == id) return smpEntry;
00083   }
00084   return NULL;
00085 };
00086 
00087 StatisticDictionary::ValueIDType
00088 StatisticDictionary::
00089 GetValueDefinitionIDByName(const std::string& sIDPath, const std::string& sName)
00090 {
00091   StatisticValueDefinition* pEntry = GetValueDefinitionByName(sIDPath,sName);
00092   if (pEntry) return pEntry->GetRefID();
00093 
00094   return 0;
00095 };
00096 
00097 StatisticEntryDefinition*
00098 StatisticDictionary::
00099 AddEntryDefinition()
00100 {
00101   StatisticEntryDefinition::Pointer smpNewEntry = StatisticEntryDefinition::New();
00102 
00103   if (this->m_EntryDefs.Size()>0) smpNewEntry->SetRefID(m_EntryDefs.GetElement(m_EntryDefs.Size()-1)->GetRefID()+1);
00104   else smpNewEntry->SetRefID(1);
00105   this->m_EntryDefs.AddElement(smpNewEntry);
00106 
00107   return smpNewEntry;
00108 };
00109 
00110 StatisticEntryDefinition*
00111 StatisticDictionary::
00112 AddEntryDefinition(const std::string& sIDPath, const std::string& sName, const std::string& sControllerID, const std::string& sDescription)
00113 {
00114   StatisticEntryDefinition::Pointer smpNewEntry = AddEntryDefinition();
00115   smpNewEntry->SetIDPath(sIDPath);
00116   smpNewEntry->SetName(sName);
00117   smpNewEntry->SetDescription(sDescription);
00118   smpNewEntry->SetControllerID(sControllerID);
00119   return smpNewEntry;
00120 };
00121 
00122 StatisticEntryDefinition*
00123 StatisticDictionary::
00124 GetEntryDefinitionByName(const std::string& sIDPath, const std::string& sName)
00125 {
00126   for (EntryDefinitionsType::ElementsCountType index = 0; index< this->m_EntryDefs.Size(); index++)
00127   {
00128     StatisticEntryDefinition::Pointer smpEntry = m_EntryDefs.GetElement(index);
00129     if ((smpEntry->GetName() == sName)&&(smpEntry->GetIDPath() == sIDPath)) return smpEntry;
00130   }
00131   return NULL;
00132 };
00133 
00134 StatisticEntryDefinition*
00135 StatisticDictionary::
00136 GetEntryDefinitionByIndex(const IndexType& index)
00137 {
00138   return m_EntryDefs.GetElement(index);
00139 };
00140 
00141 StatisticEntryDefinition*
00142 StatisticDictionary::
00143 GetEntryDefinitionByID(const EntryIDType& id)
00144 {
00145   for (EntryDefinitionsType::ElementsCountType index = 0; index< this->m_EntryDefs.Size(); index++)
00146   {
00147     StatisticEntryDefinition::Pointer smpEntry = m_EntryDefs.GetElement(index);
00148     if (smpEntry->GetRefID() == id) return smpEntry;
00149   }
00150   return NULL;
00151 };
00152 
00153 StatisticDictionary::EntryIDType
00154 StatisticDictionary::
00155 GetEntryDefinitionIDByName(const std::string& sIDPath, const std::string& sName)
00156 {
00157   StatisticEntryDefinition* pEntry = GetEntryDefinitionByName(sIDPath,sName);
00158   if (pEntry) return pEntry->GetRefID();
00159 
00160   return 0;
00161 };
00162 
00163 StatisticDictionary::
00164 StatisticDictionary():XMLStreamObject(XMLTags::StatisticDictionary),
00165                       m_EntryDefs(XMLTags::StatisticEntryDefinitions),
00166                       m_ValueDefs(XMLTags::StatisticValueDefinitions)
00167 {
00168   Reset();
00169 };
00170 
00171 StatisticDictionary::
00172 ~StatisticDictionary()
00173 {
00174   Reset();
00175 };
00176 
00177 void
00178 StatisticDictionary::
00179 Reset()
00180 {
00181   m_EntryDefs.Reset();
00182   m_ValueDefs.Reset();
00183 };
00184 
00185 void
00186 StatisticDictionary::
00187 SubElementLoadProcessing(const std::string& rsXMLSubTag, const std::string& rsXMLSubElement, const std::string& rsXMLSubData)
00188 {
00189   if (rsXMLSubTag == XMLTags::StatisticValueDefinitions)
00190   {
00191     m_ValueDefs.LoadFromString(rsXMLSubElement);
00192   }
00193   else if (rsXMLSubTag == XMLTags::StatisticEntryDefinitions)
00194   {
00195     m_EntryDefs.LoadFromString(rsXMLSubElement);
00196   }
00197 };
00198 
00199 std::string
00200 StatisticDictionary::
00201 SaveData(const unsigned int& iDepth, bool& bHasSubElements) const
00202 {
00203   std::string result;
00204 
00205   bHasSubElements = true;
00206         AddSubElement(result,&m_ValueDefs,iDepth);
00207         AddSubElement(result,&m_EntryDefs,iDepth);
00208 
00209   return result;
00210 }
00211 
00212 } //end of namespace FREE

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