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: freProfileInheritance.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 "freProfileInheritance.h" 00023 00024 namespace FREE 00025 { 00026 namespace CtrlProfile 00027 { 00031 00032 00033 00034 void 00035 ProfileInheritance:: 00036 AddAncestor(const std::string& sControllerID) 00037 { 00038 ElementIndexType pos = IndexOfAncestor(sControllerID); 00039 00040 if (pos==-1) 00041 { 00042 AddElement(cXML_CP_ControllerID,sControllerID); 00043 } 00044 else 00045 { 00046 SetElementData(pos,sControllerID); 00047 } 00048 }; 00049 00050 bool 00051 ProfileInheritance:: 00052 IsChildOf(const std::string& sControllerID) const 00053 { 00054 ElementIndexType pos = IndexOfAncestor(sControllerID); 00055 00056 return !(pos==-1); 00057 }; 00058 00059 std::string 00060 ProfileInheritance:: 00061 GetParent() const 00062 { 00063 if (Size()>0) 00064 { 00065 std::string sParent; 00066 if (GetElementData(Size()-1, sParent)) return sParent; 00067 } 00068 return ""; 00069 }; 00070 00071 std::string 00072 ProfileInheritance:: 00073 GetAncestor(ElementIndexType index) const 00074 { 00075 std::string sAncestor; 00076 if (GetElementData(index, sAncestor)) return sAncestor; 00077 return ""; 00078 }; 00079 00080 ProfileInheritance:: 00081 ~ProfileInheritance() 00082 {}; 00083 00084 ProfileInheritance::ElementIndexType 00085 ProfileInheritance:: 00086 IndexOfAncestor(const std::string& sComponentID) const 00087 { 00088 for (ElementIndexType i = 0; i<Size(); i++) 00089 { 00090 std::string sAncestor; 00091 GetElementData(i, sAncestor); 00092 if (sAncestor==sComponentID) return i; 00093 } 00094 return -1; 00095 }; 00096 00097 ProfileInheritance& 00098 ProfileInheritance:: 00099 operator = (const ProfileInheritance& rProfileInheritance) 00100 { 00101 if (this!=&rProfileInheritance) 00102 { 00103 XMLStringMultiMap::operator =(rProfileInheritance); 00104 } 00105 00106 return *this; 00107 }; 00108 00109 ProfileInheritance:: 00110 ProfileInheritance(const ProfileInheritance& rProfileInheritance):XMLStringMultiMap(cXML_CP_Inheritance) 00111 { 00112 *this = rProfileInheritance; 00113 }; 00114 00115 00116 }//end of namespace FREE 00117 }//end of namespace CtrlProfile
1.5.3 written by Dimitri van Heesch,
© 1997-2000