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