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