Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/mount_points/src/lib/graphics/importer/oif/object_information_file.cc @ 10242

Last change on this file since 10242 was 10242, checked in by patrick, 17 years ago

now the resource is loaded correctly

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