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 | * 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 | this->_root = XMLDoc.RootElement(); |
---|
60 | assert( this->_root != NULL); |
---|
61 | |
---|
62 | if( strcmp( this->_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 | } |
---|
70 | |
---|
71 | |
---|
72 | |
---|
73 | /** |
---|
74 | * standard constructor |
---|
75 | */ |
---|
76 | ObjectInformationFile::ObjectInformationFile() |
---|
77 | { |
---|
78 | this->init(); |
---|
79 | } |
---|
80 | |
---|
81 | /** |
---|
82 | * constructor |
---|
83 | * @param fileName name of the file |
---|
84 | */ |
---|
85 | ObjectInformationFile::ObjectInformationFile(const std::string& fileName) |
---|
86 | : data(new OIFData(fileName)) |
---|
87 | { |
---|
88 | // load the oif file |
---|
89 | this->data = ResourceOIF(fileName).data; |
---|
90 | |
---|
91 | this->init(); |
---|
92 | } |
---|
93 | |
---|
94 | |
---|
95 | /** |
---|
96 | * copy constructor |
---|
97 | * @param oif instance to copy from |
---|
98 | */ |
---|
99 | ObjectInformationFile::ObjectInformationFile(const ObjectInformationFile& oif) |
---|
100 | :data(oif.data) |
---|
101 | { |
---|
102 | this->init(); |
---|
103 | } |
---|
104 | |
---|
105 | |
---|
106 | /** |
---|
107 | * initizlizing function |
---|
108 | */ |
---|
109 | void ObjectInformationFile::init() |
---|
110 | { |
---|
111 | |
---|
112 | } |
---|
113 | |
---|
114 | |
---|
115 | /** |
---|
116 | * standard deconstructor |
---|
117 | */ |
---|
118 | ObjectInformationFile::~ObjectInformationFile () |
---|
119 | { |
---|
120 | // delete what has to be deleted here |
---|
121 | } |
---|
122 | |
---|
123 | |
---|
124 | |
---|
125 | ObjectInformationFile& ObjectInformationFile::operator=(const ObjectInformationFile& oif) |
---|
126 | { |
---|
127 | this->data = oif.data; |
---|
128 | return *this; |
---|
129 | } |
---|
130 | |
---|
131 | |
---|
132 | /** |
---|
133 | * this initializes the mount point |
---|
134 | * @param mountPoint to be initialized |
---|
135 | */ |
---|
136 | // void ObjectInformationFile::initMountPoint(MountPoint* mountPoint) |
---|
137 | // { |
---|
138 | // TiXmlElement* root = this->data->root(); |
---|
139 | // |
---|
140 | // } |
---|
141 | |
---|