freProfileRequirement.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: freProfileRequirement.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 "freProfileRequirement.h"
00023 #include "freConvert.h"
00024 
00025 namespace FREE
00026 {
00027 namespace CtrlProfile
00028 {
00029 
00033 
00034 
00035 ProfileOption*
00036 ProfileRequirement::
00037 AddProfileOption()
00038 {
00039   ProfileOption::Pointer smpNew = ProfileOption::New();
00040   AddElement(smpNew);
00041   return smpNew;
00042 };
00043 
00044 void
00045 ProfileRequirement::
00046 ResetProfilOptions()
00047 {
00048   XMLCollectionBase<ProfileOption>::Reset();
00049 };
00050 
00051 bool
00052 ProfileRequirement::
00053 ProfileMatchesRequirement(const ControllerProfileBase& profile) const
00054 {
00055   bool result = false;
00056   for (ElementsCountType i = 0; i<Size(); i++)
00057   {
00058     ProfileOption* pOption = GetElement(i);
00059     if (pOption->ProfileMatchesOption(profile)) result = true;
00060   }
00061 
00062   if (m_bNegated) result = !result;
00063 
00064   return result;
00065 };
00066 
00067 ProfileRequirement::
00068 ProfileRequirement()
00069 {
00070   Reset();
00071         SetXMLTag(cXML_CP_Requirement);
00072 };
00073 
00074 ProfileRequirement&
00075 ProfileRequirement::
00076 operator = (const ProfileRequirement& rRequirement)
00077 {
00078         if ( this == &rRequirement) return *this;
00079 
00080         this->LoadFromString(rRequirement.SaveToString());
00081         return *this;
00082 };
00083 
00084 ProfileRequirement::
00085 ~ProfileRequirement()
00086 {
00087   Reset();
00088 };
00089 
00090 void
00091 ProfileRequirement::
00092 Reset()
00093 {
00094         ResetProfilOptions();
00095   m_bNegated = false;
00096   m_Destination = "";
00097   m_Source = cIDPSelf;
00098 };
00099 
00100 void
00101 ProfileRequirement::
00102 SubElementLoadProcessing(const std::string& rsXMLSubTag, const std::string& rsXMLSubElement, const std::string& rsXMLSubData)
00103 {
00104   if (rsXMLSubTag==cXML_CP_ProfileOption)
00105   {
00106     ProfileOption::Pointer smpNewComponent = ProfileOption::New();
00107 
00108     try
00109     {
00110       smpNewComponent->LoadFromString(rsXMLSubElement);
00111     }
00112     catchAllNPassMacro("Unknown error occured while loading subcomponent definition to a collection.");
00113 
00114     AddElement(smpNewComponent);
00115   }
00116   else if (rsXMLSubTag!=cXML_Text) throwExceptionMacro("Unknown xml tag, unable to load value. Incorrect Tag: " << rsXMLSubTag);
00117 };
00118 
00119 void
00120 ProfileRequirement::
00121 AttributesLoadProcessing(const AttributesType& rAttributes)
00122 {
00123   for (AttributesType::const_iterator pos = rAttributes.begin(); pos!= rAttributes.end(); pos++)
00124   {
00125     if (pos->first==cXML_CP_RequDestination) m_Destination = pos->second;
00126                 else if (pos->first==cXML_CP_RequNegated) m_bNegated = FREE::Convert::ToBool(pos->second);
00127   };
00128 };
00129 
00130 void
00131 ProfileRequirement::
00132 SaveAttributes(AttributesSaveListType& rAttributes) const
00133 {
00134   rAttributes.push_back(AttributesType::value_type(cXML_CP_RequDestination,m_Destination));
00135 
00136         if (m_bNegated) rAttributes.push_back(AttributesType::value_type(cXML_CP_RequNegated,"true"));
00137 }; 
00138 
00139 }//end of namespace FREE
00140 }//end of namespace CtrlProfile

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