[10050] | 1 | /* |
---|
| 2 | orxonox - the future of 3D-vertical-scrollers |
---|
| 3 | |
---|
| 4 | Copyright (C) 2004 orx |
---|
| 5 | |
---|
| 6 | This program is free software; you can redistribute it and/or modify |
---|
| 7 | it under the terms of the GNU General Public License as published by |
---|
| 8 | the Free Software Foundation; either version 2, or (at your option) |
---|
| 9 | any later version. |
---|
| 10 | |
---|
| 11 | ### File Specific: |
---|
| 12 | main-programmer: Patrick Boenzli patrick@orxonox.net |
---|
[10059] | 13 | co-programmer: |
---|
[10050] | 14 | */ |
---|
| 15 | |
---|
| 16 | //#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_ |
---|
| 17 | |
---|
| 18 | #include "object_information_file.h" |
---|
| 19 | |
---|
[10051] | 20 | #include "resource_oif.h" |
---|
[10050] | 21 | |
---|
[10060] | 22 | #include "util/loading/factory.h" |
---|
| 23 | #include "util/loading/load_param_xml.h" |
---|
[10050] | 24 | |
---|
[10052] | 25 | |
---|
[10239] | 26 | |
---|
[10050] | 27 | /** |
---|
[10060] | 28 | * constructor |
---|
[10239] | 29 | */ |
---|
| 30 | OIFData::OIFData() |
---|
[10240] | 31 | { |
---|
| 32 | this->_root = NULL; |
---|
| 33 | } |
---|
[10239] | 34 | |
---|
| 35 | |
---|
| 36 | /** |
---|
| 37 | * constructor |
---|
[10060] | 38 | * @param fileName name of the file |
---|
| 39 | */ |
---|
| 40 | OIFData::OIFData(const std::string& fileName) |
---|
| 41 | { |
---|
[10245] | 42 | this->_root = NULL; |
---|
[10060] | 43 | this->load(fileName); |
---|
| 44 | } |
---|
| 45 | |
---|
| 46 | |
---|
[10245] | 47 | OIFData::~OIFData() |
---|
| 48 | { |
---|
| 49 | if( this->_root) |
---|
| 50 | delete this->_root; |
---|
| 51 | } |
---|
| 52 | |
---|
| 53 | |
---|
[10060] | 54 | /** |
---|
| 55 | * loading the data |
---|
| 56 | * @param fileName file name where the data can be found |
---|
| 57 | */ |
---|
| 58 | void OIFData::load(const std::string& fileName) |
---|
| 59 | { |
---|
[10241] | 60 | if( fileName.empty()) |
---|
[10060] | 61 | { |
---|
[10313] | 62 | PRINTF(1)("No filename specified for object information loading"); |
---|
[10060] | 63 | return; |
---|
| 64 | } |
---|
| 65 | |
---|
[10245] | 66 | TiXmlDocument* XMLDoc = new TiXmlDocument(fileName); |
---|
[10060] | 67 | // load the campaign document |
---|
[10245] | 68 | if( !XMLDoc->LoadFile(fileName)) |
---|
[10060] | 69 | { |
---|
| 70 | // report an error |
---|
[10313] | 71 | PRINTF(1)("Could not load XML File %s: %s @ %d:%d\n", fileName.c_str(), XMLDoc->ErrorDesc(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol()); |
---|
[10060] | 72 | return; |
---|
| 73 | } |
---|
| 74 | |
---|
| 75 | // check basic validity |
---|
[10245] | 76 | this->_root = XMLDoc->RootElement(); |
---|
[10228] | 77 | assert( this->_root != NULL); |
---|
[10060] | 78 | |
---|
[10228] | 79 | if( strcmp( this->_root->Value(), "ObjectInformationFile")) |
---|
[10060] | 80 | { |
---|
| 81 | // report an error |
---|
[10313] | 82 | PRINTF(1)("Specified XML File is not an orxonox object information file (<ObjectInformationFile> element missing)\n"); |
---|
[10060] | 83 | return; |
---|
| 84 | } |
---|
[10245] | 85 | |
---|
| 86 | // this->initMountPoint( this->_root); |
---|
[10060] | 87 | } |
---|
| 88 | |
---|
| 89 | |
---|
| 90 | /** |
---|
[10239] | 91 | * constructor |
---|
| 92 | * @param fileName name of the file |
---|
[10052] | 93 | */ |
---|
| 94 | ObjectInformationFile::ObjectInformationFile() |
---|
[10245] | 95 | : data(new OIFData) |
---|
[10052] | 96 | { |
---|
[10053] | 97 | this->init(); |
---|
[10052] | 98 | } |
---|
| 99 | |
---|
| 100 | /** |
---|
[10054] | 101 | * constructor |
---|
| 102 | * @param fileName name of the file |
---|
| 103 | */ |
---|
[10052] | 104 | ObjectInformationFile::ObjectInformationFile(const std::string& fileName) |
---|
[10060] | 105 | : data(new OIFData(fileName)) |
---|
[10050] | 106 | { |
---|
[10052] | 107 | // load the oif file |
---|
| 108 | this->data = ResourceOIF(fileName).data; |
---|
[10051] | 109 | |
---|
[10054] | 110 | this->init(); |
---|
[10050] | 111 | } |
---|
| 112 | |
---|
| 113 | |
---|
| 114 | /** |
---|
[10054] | 115 | * copy constructor |
---|
| 116 | * @param oif instance to copy from |
---|
| 117 | */ |
---|
| 118 | ObjectInformationFile::ObjectInformationFile(const ObjectInformationFile& oif) |
---|
| 119 | :data(oif.data) |
---|
| 120 | { |
---|
| 121 | this->init(); |
---|
| 122 | } |
---|
| 123 | |
---|
| 124 | |
---|
| 125 | /** |
---|
[10239] | 126 | * the definition of the assignment operator |
---|
| 127 | * @param oif |
---|
| 128 | * @return |
---|
| 129 | */ |
---|
| 130 | ObjectInformationFile& ObjectInformationFile::operator=(const ObjectInformationFile& oif) |
---|
| 131 | { |
---|
| 132 | this->init(); |
---|
| 133 | this->data = oif.data; |
---|
| 134 | |
---|
| 135 | return *this; |
---|
| 136 | } |
---|
| 137 | |
---|
| 138 | /** |
---|
[10053] | 139 | * initizlizing function |
---|
| 140 | */ |
---|
| 141 | void ObjectInformationFile::init() |
---|
| 142 | { |
---|
| 143 | |
---|
| 144 | } |
---|
| 145 | |
---|
| 146 | |
---|
[10241] | 147 | void ObjectInformationFile::load(const std::string& fileName) |
---|
| 148 | { |
---|
[10242] | 149 | this->data = OIFData::Pointer(new OIFData(fileName)); |
---|
[10241] | 150 | } |
---|
| 151 | |
---|
| 152 | |
---|
[10053] | 153 | /** |
---|
[10050] | 154 | * standard deconstructor |
---|
| 155 | */ |
---|
| 156 | ObjectInformationFile::~ObjectInformationFile () |
---|
| 157 | { |
---|
| 158 | // delete what has to be deleted here |
---|
| 159 | } |
---|
[10054] | 160 | |
---|
| 161 | |
---|
[10228] | 162 | /** |
---|
| 163 | * this initializes the mount point |
---|
| 164 | * @param mountPoint to be initialized |
---|
| 165 | */ |
---|
| 166 | // void ObjectInformationFile::initMountPoint(MountPoint* mountPoint) |
---|
| 167 | // { |
---|
| 168 | // TiXmlElement* root = this->data->root(); |
---|
| 169 | // |
---|
| 170 | // } |
---|
[10054] | 171 | |
---|