[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 | { |
---|
[10240] | 42 | this->_root = NULL; |
---|
| 43 | |
---|
[10060] | 44 | this->load(fileName); |
---|
| 45 | } |
---|
| 46 | |
---|
| 47 | |
---|
| 48 | /** |
---|
| 49 | * loading the data |
---|
| 50 | * @param fileName file name where the data can be found |
---|
| 51 | */ |
---|
| 52 | void OIFData::load(const std::string& fileName) |
---|
| 53 | { |
---|
[10241] | 54 | PRINTF(0)("loading |%s| as oif data\n", fileName.c_str()); |
---|
| 55 | if( fileName.empty()) |
---|
[10060] | 56 | { |
---|
[10241] | 57 | PRINTF(0)("No filename specified for object information loading"); |
---|
[10060] | 58 | return; |
---|
| 59 | } |
---|
| 60 | |
---|
| 61 | TiXmlDocument XMLDoc(fileName); |
---|
| 62 | // load the campaign document |
---|
| 63 | if( !XMLDoc.LoadFile(fileName)) |
---|
| 64 | { |
---|
| 65 | // report an error |
---|
[10241] | 66 | PRINTF(0)("Could not load XML File %s: %s @ %d:%d\n", fileName.c_str(), XMLDoc.ErrorDesc(), XMLDoc.ErrorRow(), XMLDoc.ErrorCol()); |
---|
[10060] | 67 | return; |
---|
| 68 | } |
---|
| 69 | |
---|
| 70 | // check basic validity |
---|
[10228] | 71 | this->_root = XMLDoc.RootElement(); |
---|
| 72 | assert( this->_root != NULL); |
---|
[10060] | 73 | |
---|
[10228] | 74 | if( strcmp( this->_root->Value(), "ObjectInformationFile")) |
---|
[10060] | 75 | { |
---|
| 76 | // report an error |
---|
[10241] | 77 | PRINTF(0)("Specified XML File is not an orxonox object information file (<ObjectInformationFile> element missing)\n"); |
---|
[10060] | 78 | return; |
---|
| 79 | } |
---|
[10241] | 80 | PRINTF(0)("OIF loaded\n"); |
---|
[10060] | 81 | |
---|
| 82 | } |
---|
| 83 | |
---|
| 84 | |
---|
| 85 | /** |
---|
[10239] | 86 | * constructor |
---|
| 87 | * @param fileName name of the file |
---|
[10052] | 88 | */ |
---|
| 89 | ObjectInformationFile::ObjectInformationFile() |
---|
[10239] | 90 | : data(new OIFData()) |
---|
[10052] | 91 | { |
---|
[10053] | 92 | this->init(); |
---|
[10052] | 93 | } |
---|
| 94 | |
---|
| 95 | /** |
---|
[10054] | 96 | * constructor |
---|
| 97 | * @param fileName name of the file |
---|
| 98 | */ |
---|
[10052] | 99 | ObjectInformationFile::ObjectInformationFile(const std::string& fileName) |
---|
[10060] | 100 | : data(new OIFData(fileName)) |
---|
[10050] | 101 | { |
---|
[10052] | 102 | // load the oif file |
---|
| 103 | this->data = ResourceOIF(fileName).data; |
---|
[10051] | 104 | |
---|
[10054] | 105 | this->init(); |
---|
[10050] | 106 | } |
---|
| 107 | |
---|
| 108 | |
---|
| 109 | /** |
---|
[10054] | 110 | * copy constructor |
---|
| 111 | * @param oif instance to copy from |
---|
| 112 | */ |
---|
| 113 | ObjectInformationFile::ObjectInformationFile(const ObjectInformationFile& oif) |
---|
| 114 | :data(oif.data) |
---|
| 115 | { |
---|
| 116 | this->init(); |
---|
| 117 | } |
---|
| 118 | |
---|
| 119 | |
---|
| 120 | /** |
---|
[10239] | 121 | * the definition of the assignment operator |
---|
| 122 | * @param oif |
---|
| 123 | * @return |
---|
| 124 | */ |
---|
| 125 | ObjectInformationFile& ObjectInformationFile::operator=(const ObjectInformationFile& oif) |
---|
| 126 | { |
---|
| 127 | this->init(); |
---|
| 128 | this->data = oif.data; |
---|
| 129 | |
---|
| 130 | return *this; |
---|
| 131 | } |
---|
| 132 | |
---|
| 133 | /** |
---|
[10053] | 134 | * initizlizing function |
---|
| 135 | */ |
---|
| 136 | void ObjectInformationFile::init() |
---|
| 137 | { |
---|
| 138 | |
---|
| 139 | } |
---|
| 140 | |
---|
| 141 | |
---|
[10241] | 142 | void ObjectInformationFile::load(const std::string& fileName) |
---|
| 143 | { |
---|
[10242] | 144 | this->data = OIFData::Pointer(new OIFData(fileName)); |
---|
[10241] | 145 | } |
---|
| 146 | |
---|
| 147 | |
---|
[10053] | 148 | /** |
---|
[10050] | 149 | * standard deconstructor |
---|
| 150 | */ |
---|
| 151 | ObjectInformationFile::~ObjectInformationFile () |
---|
| 152 | { |
---|
| 153 | // delete what has to be deleted here |
---|
| 154 | } |
---|
[10054] | 155 | |
---|
| 156 | |
---|
[10228] | 157 | /** |
---|
| 158 | * this initializes the mount point |
---|
| 159 | * @param mountPoint to be initialized |
---|
| 160 | */ |
---|
| 161 | // void ObjectInformationFile::initMountPoint(MountPoint* mountPoint) |
---|
| 162 | // { |
---|
| 163 | // TiXmlElement* root = this->data->root(); |
---|
| 164 | // |
---|
| 165 | // } |
---|
[10054] | 166 | |
---|