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 |
---|
13 | co-programmer: |
---|
14 | */ |
---|
15 | |
---|
16 | //#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_ |
---|
17 | |
---|
18 | #include "object_information_file.h" |
---|
19 | |
---|
20 | #include "resource_oif.h" |
---|
21 | |
---|
22 | #include "util/loading/factory.h" |
---|
23 | #include "util/loading/load_param_xml.h" |
---|
24 | |
---|
25 | |
---|
26 | |
---|
27 | /** |
---|
28 | * constructor |
---|
29 | */ |
---|
30 | OIFData::OIFData() |
---|
31 | { |
---|
32 | this->_root = NULL; |
---|
33 | } |
---|
34 | |
---|
35 | |
---|
36 | /** |
---|
37 | * constructor |
---|
38 | * @param fileName name of the file |
---|
39 | */ |
---|
40 | OIFData::OIFData(const std::string& fileName) |
---|
41 | { |
---|
42 | this->_root = NULL; |
---|
43 | this->load(fileName); |
---|
44 | } |
---|
45 | |
---|
46 | |
---|
47 | OIFData::~OIFData() |
---|
48 | { |
---|
49 | if( this->_root) |
---|
50 | delete this->_root; |
---|
51 | } |
---|
52 | |
---|
53 | |
---|
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 | { |
---|
60 | if( fileName.empty()) |
---|
61 | { |
---|
62 | PRINTF(1)("No filename specified for object information loading"); |
---|
63 | return; |
---|
64 | } |
---|
65 | |
---|
66 | TiXmlDocument* XMLDoc = new TiXmlDocument(fileName); |
---|
67 | // load the campaign document |
---|
68 | if( !XMLDoc->LoadFile(fileName)) |
---|
69 | { |
---|
70 | // report an error |
---|
71 | PRINTF(1)("Could not load XML File %s: %s @ %d:%d\n", fileName.c_str(), XMLDoc->ErrorDesc(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol()); |
---|
72 | return; |
---|
73 | } |
---|
74 | |
---|
75 | // check basic validity |
---|
76 | this->_root = XMLDoc->RootElement(); |
---|
77 | assert( this->_root != NULL); |
---|
78 | |
---|
79 | if( strcmp( this->_root->Value(), "ObjectInformationFile")) |
---|
80 | { |
---|
81 | // report an error |
---|
82 | PRINTF(1)("Specified XML File is not an orxonox object information file (<ObjectInformationFile> element missing)\n"); |
---|
83 | return; |
---|
84 | } |
---|
85 | |
---|
86 | // this->initMountPoint( this->_root); |
---|
87 | } |
---|
88 | |
---|
89 | |
---|
90 | /** |
---|
91 | * constructor |
---|
92 | * @param fileName name of the file |
---|
93 | */ |
---|
94 | ObjectInformationFile::ObjectInformationFile() |
---|
95 | : data(new OIFData) |
---|
96 | { |
---|
97 | this->init(); |
---|
98 | } |
---|
99 | |
---|
100 | /** |
---|
101 | * constructor |
---|
102 | * @param fileName name of the file |
---|
103 | */ |
---|
104 | ObjectInformationFile::ObjectInformationFile(const std::string& fileName) |
---|
105 | : data(new OIFData(fileName)) |
---|
106 | { |
---|
107 | // load the oif file |
---|
108 | this->data = ResourceOIF(fileName).data; |
---|
109 | |
---|
110 | this->init(); |
---|
111 | } |
---|
112 | |
---|
113 | |
---|
114 | /** |
---|
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 | /** |
---|
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 | /** |
---|
139 | * initizlizing function |
---|
140 | */ |
---|
141 | void ObjectInformationFile::init() |
---|
142 | { |
---|
143 | |
---|
144 | } |
---|
145 | |
---|
146 | |
---|
147 | void ObjectInformationFile::load(const std::string& fileName) |
---|
148 | { |
---|
149 | this->data = OIFData::Pointer(new OIFData(fileName)); |
---|
150 | } |
---|
151 | |
---|
152 | |
---|
153 | /** |
---|
154 | * standard deconstructor |
---|
155 | */ |
---|
156 | ObjectInformationFile::~ObjectInformationFile () |
---|
157 | { |
---|
158 | // delete what has to be deleted here |
---|
159 | } |
---|
160 | |
---|
161 | |
---|
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 | // } |
---|
171 | |
---|