Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/graphics/importer/oif/object_information_file.cc @ 10772

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

merged branche mount_point to trunk. this will add mount point abilities, bsp transparency fix and some other smaller stuff to this trunk

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