Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   Related Pages  

dependency.cxx

Go to the documentation of this file.
00001 /******************************************************************************
00002 
00003                            Copyright Notice.
00004 
00005                Licensed material - Property of Steve Lhomme
00006 
00007 This source file is part of Steve Lhomme's libSVX.
00008 (C) Copyright Steve Lhomme, France, 2001-2002.
00009 All rights reserved. Modifications (C) copyrighted by their respective
00010 contributors, all rights reserved.
00011 
00012 The contents of this file are subject to the Bixoft Public License
00013 Version 1.0 (the "License"); you may not use this file in any way except
00014 in compliance with the License. You should have received a copy of the
00015 License with this source; see <file or member name>. You may also obtain
00016 a copy of the License at http://www.bixoft.nl/english/license.htm
00017 or http://mukoli.free.fr/BXAPL/
00018 
00019 ANY USE OF THE SOFTWARE CONSTITUTES ACCEPTANCE OF THE LICENSE.
00020 
00021 Anything distributed under the License is distributed on an "AS IS" basis,
00022 WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
00023 the specific language governing rights and limitations under the License.
00024 
00025 Definitions required by the License:
00026 Copyright Holder: Steve Lhomme, France
00027           e-mail: steve.lhomme@free.fr
00028 Country: France, i.e. the laws of France apply.
00029 Court  : ????
00030 Programming Tool status: This source is not a Programming Tool.
00031 
00032 Contributor(s):                      Contribution:
00033 
00034 ******************************************************************************/
00035 
00044 #include "../tinyxml/tinyxml.h"
00045 
00046 #include "dversion.h"
00047 #include "attribute.h"
00048 
00049 #include "dependency.h"
00050 
00051 using namespace libsvx;
00052 
00055 Dependency::Dependency(TiXmlElement & Element)
00056  :ElementUid(Element,"dependency")
00057  ,m_A_link(NULL)
00058  ,m_A_priority(NULL)
00059  ,m_A_href(NULL)
00060 {
00061   assert(Element.Value().compare("dependency") == 0);
00062 
00063   // attributes
00064   if (Element.Attribute("link") != NULL)
00065   {
00066     m_A_link = new Attribute(*Element.Attribute("link"),"link");
00067   }
00068 
00069   if (Element.Attribute("priority") != NULL)
00070   {
00071     m_A_priority = new Attribute(*Element.Attribute("priority"),"priority");
00072   }
00073 
00074   if (Element.Attribute("href") != NULL)
00075   {
00076     m_A_href = new Attribute(*Element.Attribute("href"),"href");
00077   }
00078 
00079   // elements
00080   TiXmlElement * txIterator;
00081   
00082   m_List_DVersion.clear();
00083   txIterator = Element.FirstChildElement("dversion");
00084   while (txIterator != NULL)
00085   {
00086     DVersion * tmpText = new DVersion(*txIterator);
00087     m_List_DVersion.push_back(tmpText);
00088     txIterator = txIterator->NextSiblingElement("dversion");
00089   }
00090 }
00091 
00095 Dependency::Dependency(const Dependency & a_item)
00096  :ElementUid(a_item)
00097 {
00098   if (a_item.m_A_href != NULL)
00099     m_A_href = new Attribute(*a_item.m_A_href);
00100   else
00101     m_A_href = a_item.m_A_href;
00102 
00103   if (a_item.m_A_link != NULL)
00104     m_A_link = new Attribute(*a_item.m_A_link);
00105   else
00106     m_A_link = a_item.m_A_link;
00107 
00108   if (a_item.m_A_priority != NULL)
00109     m_A_priority = new Attribute(*a_item.m_A_priority);
00110   else
00111     m_A_priority = a_item.m_A_priority;
00112 
00113   for (size_t i = 0; i < a_item.m_List_DVersion.size();i++)
00114   {
00115     DVersion * tmpText = new DVersion(a_item.m_List_DVersion[i]);
00116     m_List_DVersion.push_back(tmpText);
00117   }
00118 }
00119 
00123 Dependency::~Dependency()
00124 {
00125   if (m_A_link != NULL)
00126     delete m_A_link;
00127   if (m_A_priority != NULL)
00128     delete m_A_priority;
00129   if (m_A_href != NULL)
00130     delete m_A_href;
00131 /* done automatically
00132   while (m_List_DVersion.size() != 0)
00133   {
00134     DVersion * tmp = m_List_DVersion.front();
00135     m_List_DVersion.pop_front();
00136     delete tmp;
00137   }
00138 */
00139 }
00140 
00144 bool Dependency::IsValid() const
00145 {
00146   return (m_List_DVersion.size() > 0 && m_A_uid != NULL && m_A_link != NULL &&
00147     (m_A_link->String().compare("optional") == 0 ||
00148      m_A_link->String().compare("mandatory") == 0 ||
00149      m_A_link->String().compare("exclusive") == 0));
00150 }
00151 
00152 TiXmlElement & Dependency::XmlElement()
00153 {
00154   ElementUid::XmlElement(*m_Node);
00155 
00156   if (m_A_link != NULL)
00157     m_A_link->XmlElement(*m_Node);
00158 
00159   if (m_A_priority != NULL)
00160     m_A_priority->XmlElement(*m_Node);
00161 
00162   if (m_A_href != NULL)
00163     m_A_href->XmlElement(*m_Node);
00164 
00165   for (size_t i = 0; i < m_List_DVersion.size();i++)
00166   {
00167     m_Node->InsertEndChild(m_List_DVersion[i].XmlElement());
00168   }
00169   
00170   return *m_Node;
00171 }
00172 
00176 bool Dependency::operator!=(const Dependency & the_object_to_compare) const
00177 {
00178   bool result = !(IsValid() && the_object_to_compare.IsValid());
00179 
00180   if (!result)
00181   {
00182     result = result || (static_cast<const ElementUid&>(*this) != the_object_to_compare);
00183 
00184     if (m_A_link != NULL && the_object_to_compare.m_A_link != NULL)
00185       result = result || (*m_A_link != *the_object_to_compare.m_A_link);
00186 
00187     if (m_A_priority != NULL && the_object_to_compare.m_A_priority != NULL)
00188       result = result || (*m_A_priority != *the_object_to_compare.m_A_priority);
00189 
00190     if (m_A_href != NULL && the_object_to_compare.m_A_href != NULL)
00191       result = result || (*m_A_href != *the_object_to_compare.m_A_href);
00192     }
00193 
00194   return result;
00195 }

Generated on Sat Apr 13 22:56:49 2002 for libsvx by doxygen1.2.15