Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

not checkinf for invalid xml files. runs again

File size: 2.9 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(3)("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(1)("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(2)("Specified XML File is not an orxonox object information file (<ObjectInformationFile> element missing)\n");
78    return;
79  }
80
81}
82
83
84/**
85 * constructor
86 * @param fileName name of the file
87 */
88ObjectInformationFile::ObjectInformationFile()
89  : data(new OIFData())
90{
91  this->init();
92}
93
94/**
95 * constructor
96 * @param fileName name of the file
97 */
98ObjectInformationFile::ObjectInformationFile(const std::string& fileName)
99  : data(new OIFData(fileName))
100{
101  // load the oif file
102  this->data = ResourceOIF(fileName).data;
103
104  this->init();
105}
106
107
108/**
109 * copy constructor
110 * @param oif instance to copy from
111*/
112ObjectInformationFile::ObjectInformationFile(const ObjectInformationFile& oif)
113  :data(oif.data)
114{
115  this->init();
116}
117
118
119/**
120 * the definition of the assignment operator
121 * @param oif
122 * @return
123 */
124ObjectInformationFile& ObjectInformationFile::operator=(const ObjectInformationFile& oif)
125{
126  this->init();
127  this->data = oif.data;
128
129  return *this;
130}
131
132/**
133 * initizlizing function
134 */
135void ObjectInformationFile::init()
136{
137
138}
139
140
141/**
142 * standard deconstructor
143*/
144ObjectInformationFile::~ObjectInformationFile ()
145{
146  // delete what has to be deleted here
147}
148
149
150/**
151 * this initializes the mount point
152 * @param mountPoint to be initialized
153 */
154// void ObjectInformationFile::initMountPoint(MountPoint* mountPoint)
155// {
156//   TiXmlElement* root = this->data->root();
157//
158// }
159
Note: See TracBrowser for help on using the repository browser.