00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00044 #include "../tinyxml/tinyxml.h"
00045
00046 #include "mirrors.h"
00047 #include "url.h"
00048
00049 #include "element_downloadable.h"
00050
00051 using namespace libsvx;
00052
00055 ElementDownloadable::ElementDownloadable(TiXmlElement & Element, const std::string the_name)
00056 :ElementGeneric(Element,the_name)
00057 {
00058
00059 m_List_Mirrors.clear();
00060 TiXmlElement * txIterator = Element.FirstChildElement("mirrors");
00061
00062 while (txIterator != NULL)
00063 {
00064 Mirrors * tmpText = new Mirrors(*txIterator);
00065 m_List_Mirrors.push_back(tmpText);
00066 txIterator = txIterator->NextSiblingElement("mirrors");
00067 }
00068 }
00069
00070 ElementDownloadable::ElementDownloadable(const ElementDownloadable & a_element)
00071 :ElementGeneric(a_element)
00072 {
00073 for (size_t i = 0; i < a_element.m_List_Mirrors.size();i++)
00074 {
00075 Mirrors * tmpText = new Mirrors(a_element.m_List_Mirrors[i]);
00076 m_List_Mirrors.push_back(tmpText);
00077 }
00078 }
00079
00083 ElementDownloadable::~ElementDownloadable()
00084 {
00085
00086
00087
00088
00089
00090
00091
00092
00093 }
00094
00098 bool ElementDownloadable::IsValid() const
00099 {
00100 return true;
00101 }
00102
00103
00104 void ElementDownloadable::XmlElement(TiXmlElement & the_element_to_fill)
00105 {
00106 for (size_t i = 0; i < m_List_Mirrors.size();i++)
00107 {
00108 the_element_to_fill.InsertEndChild(m_List_Mirrors[i].XmlElement());
00109 }
00110 }
00111
00115 Mirrors * ElementDownloadable::FindMirrors(const Mirrors & the_item) const
00116 {
00117 size_t current_version = 0;
00118
00119 while (current_version < m_List_Mirrors.size() &&
00120 m_List_Mirrors[current_version] != the_item)
00121 {
00122 current_version++;
00123 }
00124
00125 if (current_version < m_List_Mirrors.size())
00126 return &m_List_Mirrors[current_version];
00127 else
00128 return NULL;
00129 }
00130
00131 ElementDownloadable & ElementDownloadable::operator+=(const ElementDownloadable & the_object_to_add)
00132 {
00133 assert(IsValid());
00134
00135 if (the_object_to_add.IsValid())
00136 {
00137
00138 *static_cast<ElementGeneric*>(this) += the_object_to_add;
00139
00140
00141 size_t i = 0;
00142 Mirrors * tmpFoundMirrors;
00143 while (i < the_object_to_add.m_List_Mirrors.size())
00144 {
00145 tmpFoundMirrors = FindMirrors(the_object_to_add.m_List_Mirrors[i]);
00146 if (tmpFoundMirrors == NULL)
00147 {
00148
00149 Mirrors * tmpMirrors = new Mirrors(the_object_to_add.m_List_Mirrors[i]);
00150 m_List_Mirrors.push_back(tmpMirrors);
00151 }
00152 else
00153 {
00154
00155 *tmpFoundMirrors += the_object_to_add.m_List_Mirrors[i];
00156 }
00157
00158 i++;
00159 }
00160 }
00161
00162 return *this;
00163 }
00164
00168 bool ElementDownloadable::operator!=(const ElementDownloadable & the_object_to_compare) const
00169 {
00170 bool result = !(IsValid() && the_object_to_compare.IsValid());
00171
00172 result = result || (static_cast<const ElementGeneric &>(*this) != the_object_to_compare);
00173
00174 return result;
00175 }