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 | 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 | /** |
---|
76 | * standard constructor |
---|
77 | */ |
---|
78 | ObjectInformationFile::ObjectInformationFile() |
---|
79 | { |
---|
80 | this->init(); |
---|
81 | } |
---|
82 | |
---|
83 | /** |
---|
84 | * constructor |
---|
85 | * @param fileName name of the file |
---|
86 | */ |
---|
87 | ObjectInformationFile::ObjectInformationFile(const std::string& fileName) |
---|
88 | : data(new OIFData(fileName)) |
---|
89 | { |
---|
90 | // load the oif file |
---|
91 | this->data = ResourceOIF(fileName).data; |
---|
92 | |
---|
93 | this->init(); |
---|
94 | } |
---|
95 | |
---|
96 | |
---|
97 | /** |
---|
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 | /** |
---|
109 | * initizlizing function |
---|
110 | */ |
---|
111 | void ObjectInformationFile::init() |
---|
112 | { |
---|
113 | |
---|
114 | } |
---|
115 | |
---|
116 | |
---|
117 | /** |
---|
118 | * standard deconstructor |
---|
119 | */ |
---|
120 | ObjectInformationFile::~ObjectInformationFile () |
---|
121 | { |
---|
122 | // delete what has to be deleted here |
---|
123 | } |
---|
124 | |
---|
125 | |
---|
126 | |
---|
127 | ObjectInformationFile& ObjectInformationFile::operator=(const ObjectInformationFile& oif) |
---|
128 | { |
---|
129 | this->data = oif.data; |
---|
130 | return *this; |
---|
131 | } |
---|
132 | |
---|
133 | |
---|
134 | |
---|