Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/core2/src/orxonox/Orxonox.cc @ 955

Last change on this file since 955 was 955, checked in by landauf, 16 years ago
  • added input buffer: this class captures key-input (at the moment it's using OIS directly, later it will use the InputHandler) and writes it into a string - other classes can listen to changes and can read and modify the string.
  • fixed some bugs in CommandExecutor
  • fixed a small bug (or changed a questionable feature) in Functor
File size: 52.3 KB
Line 
1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *
4 *
5 *   License notice:
6 *
7 *   This program is free software; you can redistribute it and/or
8 *   modify it under the terms of the GNU General Public License
9 *   as published by the Free Software Foundation; either version 2
10 *   of the License, or (at your option) any later version.
11 *
12 *   This program is distributed in the hope that it will be useful,
13 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 *   GNU General Public License for more details.
16 *
17 *   You should have received a copy of the GNU General Public License
18 *   along with this program; if not, write to the Free Software
19 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20 *
21 *   Author:
22 *      Benjamin Knecht <beni_at_orxonox.net>, (C) 2007
23 *   Co-authors:
24 *      ...
25 *
26 */
27
28/**
29 @file  Orxonox.cc
30 @brief Orxonox Main Class
31 */
32
33// Precompiled Headers
34#include "OrxonoxStableHeaders.h"
35
36//****** OGRE ******
37#include <OgreException.h>
38#include <OgreRoot.h>
39#include <OgreFrameListener.h>
40#include <OgreRenderWindow.h>
41#include <OgreTextureManager.h>
42#include <OgreResourceGroupManager.h>
43#include <OgreConfigFile.h>
44#include <OgreOverlay.h>
45#include <OgreOverlayManager.h>
46
47//****** OIS *******
48#include <OIS/OIS.h>
49
50//****** STD *******
51#include <iostream>
52#include <exception>
53
54//***** ORXONOX ****
55//misc
56#include "util/Sleep.h"
57
58// loader and audio
59//#include "loader/LevelLoader.h"
60//#include "audio/AudioManager.h"
61
62// network
63//#include "network/Server.h"
64//#include "network/Client.h"
65//#include "network/NetworkFrameListener.h"
66
67// objects
68#include "objects/Tickable.h"
69#include "tools/Timer.h"
70//#include "objects/NPC.h"
71#include "core/ArgReader.h"
72#include "core/Factory.h"
73#include "core/Debug.h"
74#include "core/Loader.h"
75//#include "hud/HUD.h"
76//#include "objects/weapon/BulletManager.h"
77#include "GraphicsEngine.h"
78
79#include "core/ClassTreeMask.h"
80#include "objects/WorldEntity.h"
81#include "core/DebugLevel.h"
82#include "core/BaseObject.h"
83#include "objects/Test.h"
84#include "objects/test1.h"
85#include "objects/test2.h"
86#include "objects/test3.h"
87
88#include "core/CommandExecutor.h"
89#include "core/InputBuffer.h"
90
91#include "Orxonox.h"
92
93namespace orxonox
94{
95    class Testlistener : public InputBufferListener
96    {
97        public:
98            Testlistener(InputBuffer* ib) : ib_(ib) {}
99            void listen() const
100            {
101                std::cout << "> -->" << this->ib_->get() << "<--" << std::endl;
102            }
103            void execute() const
104            {
105std::cout << "### EXECUTE!" << std::endl;
106                CommandExecutor::execute(this->ib_->get());
107                this->ib_->clear();
108            }
109            void hintandcomplete() const
110            {
111std::cout << "### HINT!" << std::endl;
112                std::cout << CommandExecutor::hint(this->ib_->get()) << std::endl;
113                this->ib_->set(CommandExecutor::complete(this->ib_->get()));
114            }
115            void clear() const
116            {
117std::cout << "### CLEAR!" << std::endl;
118                this->ib_->clear();
119            }
120            void removeLast() const
121            {
122std::cout << "### REMOVELAST!" << std::endl;
123                this->ib_->removeLast();
124            }
125
126        private:
127            InputBuffer* ib_;
128    };
129
130   // put this in a seperate Class or solve the problem in another fashion
131  class OrxListener : public Ogre::FrameListener
132  {
133    public:
134      OrxListener(OIS::Keyboard *keyboard/*, audio::AudioManager*  auMan*/, gameMode mode)
135      {
136        mKeyboard = keyboard;
137        mode_=mode;
138//        auMan_ = auMan;
139      }
140
141      bool frameStarted(const Ogre::FrameEvent& evt)
142      {
143//        auMan_->update();
144//        updateAI();
145
146//        if(mode_ == PRESENTATION)
147//          server_g->tick(evt.timeSinceLastFrame);
148//        else if(mode_ == CLIENT)
149//          client_g->tick(evt.timeSinceLastFrame);
150
151        usleep(10);
152
153        mKeyboard->capture();
154        return !mKeyboard->isKeyDown(OIS::KC_ESCAPE);
155      }
156/*
157      void updateAI()
158      {
159        for(Iterator<NPC> it = ObjectList<NPC>::start(); it; ++it)
160        {
161          it->update();
162        }
163      }
164*/
165    private:
166      gameMode mode_;
167      OIS::Keyboard *mKeyboard;
168//      audio::AudioManager*  auMan_;
169  };
170
171  // init static singleton reference of Orxonox
172  Orxonox* Orxonox::singletonRef_ = NULL;
173
174  /**
175   * create a new instance of Orxonox
176   */
177  Orxonox::Orxonox()
178  {
179    this->ogre_ = new GraphicsEngine();
180    this->dataPath_ = "";
181//    this->loader_ = 0;
182//    this->auMan_ = 0;
183    this->singletonRef_ = 0;
184    this->keyboard_ = 0;
185    this->mouse_ = 0;
186    this->inputManager_ = 0;
187    this->frameListener_ = 0;
188    this->root_ = 0;
189  }
190
191  /**
192   * destruct Orxonox
193   */
194  Orxonox::~Orxonox()
195  {
196    // nothing to delete as for now
197  }
198
199  /**
200   * initialization of Orxonox object
201   * @param argc argument counter
202   * @param argv list of arguments
203   * @param path path to config (in home dir or something)
204   */
205  void Orxonox::init(int argc, char **argv, std::string path)
206  {
207    //TODO: find config file (assuming executable directory)
208    //TODO: read config file
209    //TODO: give config file to Ogre
210    std::string mode;
211//     if(argc>=2)
212//       mode = std::string(argv[1]);
213//     else
214//       mode = "";
215    ArgReader ar = ArgReader(argc, argv);
216    ar.checkArgument("mode", mode, false);
217    ar.checkArgument("data", this->dataPath_, false);
218    ar.checkArgument("ip", serverIp_, false);
219    //mode = "presentation";
220    if(ar.errorHandling()) die();
221    if(mode == std::string("server"))
222    {
223      serverInit(path);
224      mode_ = SERVER;
225    }
226    else if(mode == std::string("client"))
227    {
228      clientInit(path);
229      mode_ = CLIENT;
230    }
231    else if(mode == std::string("presentation"))
232    {
233      serverInit(path);
234      mode_ = PRESENTATION;
235    }
236    else{
237      standaloneInit(path);
238      mode_ = STANDALONE;
239    }
240  }
241
242  /**
243   * start modules
244   */
245  void Orxonox::start()
246  {
247    //TODO: start modules
248    ogre_->startRender();
249    //TODO: run engine
250    Factory::createClassHierarchy();
251    createScene();
252    setupScene();
253    setupInputSystem();
254    if(mode_!=CLIENT){ // remove this in future ---- presentation hack
255    }
256    else
257      std::cout << "client here" << std::endl;
258    createFrameListener();
259    switch(mode_){
260    case PRESENTATION:
261      //ogre_->getRoot()->addFrameListener(new network::ServerFrameListener());
262      //std::cout << "could not add framelistener" << std::endl;
263//      server_g->open();
264      break;
265    case CLIENT:
266//      client_g->establishConnection();
267      break;
268    case SERVER:
269    case STANDALONE:
270    default:
271      break;
272    }
273
274        #define testandcout(code) \
275          std::cout << #code << " " << code << "\n"
276/*
277        std::cout << "Test 1\n";
278        BaseObject* test1;
279        test1 = new BaseObject();
280        test1 = new BaseObject();
281        test1 = new BaseObject();
282
283        std::cout << "Test 2\n";
284        A1* test2;
285        test2 = new A1();
286        test2 = new A1();
287        test2 = new A1();
288
289        std::cout << "Test 3\n";
290        BaseObject* test3;
291        test3 = new BaseObject();
292        test3 = new BaseObject();
293        test3 = new BaseObject();
294
295        std::cout << "Test 4\n";
296        A3* test4;
297        test4 = new A3();
298        test4 = new A3();
299        test4 = new A3();
300
301
302        std::cout << "Test 5\n";
303        A1* test5_01 = new A1();
304        A2* test5_02 = new A2();
305        A3* test5_03 = new A3();
306        A1B1* test5_04 = new A1B1();
307        A1B2* test5_05 = new A1B2();
308        A2B1* test5_06 = new A2B1();
309        A2B2* test5_07 = new A2B2();
310        A3B1* test5_08 = new A3B1();
311        A3B2* test5_09 = new A3B2();
312        A1B1C1* test5_10 = new A1B1C1();
313        A1B1C2* test5_11 = new A1B1C2();
314        A1B2C1* test5_12 = new A1B2C1();
315        A2B1C1* test5_13 = new A2B1C1();
316        A2B2C1* test5_14 = new A2B2C1();
317        A3B1C1* test5_15 = new A3B1C1();
318        A3B1C2* test5_16 = new A3B1C2();
319        A3B2C1* test5_17 = new A3B2C1();
320        A3B2C2* test5_18 = new A3B2C2();
321*/
322/*
323        OrxonoxClass* test5 = 0;
324        for (int i = 0; i <= 18; i++)
325        {
326          if (i == 0) test5 = new BaseObject;
327          if (i == 1) test5 = test5_01;
328          if (i == 2) test5 = test5_02;
329          if (i == 3) test5 = test5_03;
330          if (i == 4) test5 = test5_04;
331          if (i == 5) test5 = test5_05;
332          if (i == 6) test5 = test5_06;
333          if (i == 7) test5 = test5_07;
334          if (i == 8) test5 = test5_08;
335          if (i == 9) test5 = test5_09;
336          if (i == 10) test5 = test5_10;
337          if (i == 11) test5 = test5_11;
338          if (i == 12) test5 = test5_12;
339          if (i == 13) test5 = test5_13;
340          if (i == 14) test5 = test5_14;
341          if (i == 15) test5 = test5_15;
342          if (i == 16) test5 = test5_16;
343          if (i == 17) test5 = test5_17;
344          if (i == 18) test5 = test5_18;
345
346          std::cout << "\n";
347          std::cout << test5->getIdentifier()->getName() << " (" << test5->getIdentifier()->getNetworkID() << "): parents:         " << test5->getIdentifier()->getParents() << "\n";
348          std::cout << test5->getIdentifier()->getName() << " (" << test5->getIdentifier()->getNetworkID() << "): children:        " << test5->getIdentifier()->getChildren() << "\n";
349          std::cout << test5->getIdentifier()->getName() << " (" << test5->getIdentifier()->getNetworkID() << "): direct parents:  " << test5->getIdentifier()->getDirectParents() << "\n";
350          std::cout << test5->getIdentifier()->getName() << " (" << test5->getIdentifier()->getNetworkID() << "): direct children: " << test5->getIdentifier()->getDirectChildren() << "\n";
351        }
352*/
353/*
354        for (std::map<std::string, Identifier*>::const_iterator it = Factory::getFactoryBegin(); it != Factory::getFactoryEnd(); ++it)
355            std::cout << "Class with ID " << (*it).second->getNetworkID() << ": " << ID((*it).second->getNetworkID()) << " / " << ID((*it).second->getNetworkID())->getName() << std::endl;
356
357        std::cout << "Class with ID 100: " << ID(100) << "\n";
358        std::cout << "ID of BaseObject: " << Class(BaseObject)->getNetworkID() << "\n";
359
360        std::cout << "\nChange ID of BaseObject to 100\n";
361        Class(BaseObject)->setNetworkID(100);
362        std::cout << "Class with ID 100: " << ID(100) << "\n";
363        std::cout << "Class with ID 1: " << ID(1) << "\n";
364        std::cout << "ID of BaseObject: " << Class(BaseObject)->getNetworkID() << "\n";
365
366        std::cout << "\nChange ID of BaseObject to 3\n";
367        Class(BaseObject)->setNetworkID(3);
368        std::cout << "Class with ID 100: " << ID(100) << "\n";
369        std::cout << "Class with ID 1: " << ID(1) << "\n";
370        std::cout << "Class with ID 3: " << ID(3) << "\n";
371        std::cout << "ID of BaseObject: " << Class(BaseObject)->getNetworkID() << "\n";
372        std::cout << "ID of Test1: " << Class(Test1)->getNetworkID() << "\n";
373*/
374/*
375        std::cout << "\n";
376        std::cout << "isA(XYZ)-Test:\n";
377        std::cout << "test5_01 = A1, Erwartet: 1 0 0 1 0\n";
378        testandcout(test5_01->isA(Class(A1)));
379        testandcout(test5_01->isA(Class(A2)));
380        testandcout(test5_01->isA(Class(A1B1)));
381        testandcout(test5_01->isA(Class(BaseObject)));
382        testandcout(test5_01->isA(Class(Interface1)));
383
384        std::cout << "\n";
385        std::cout << "test5_02 = A2, Erwartet: 0 1 0 1 0\n";
386        testandcout(test5_02->isA(Class(A1)));
387        testandcout(test5_02->isA(Class(A2)));
388        testandcout(test5_02->isA(Class(A1B1)));
389        testandcout(test5_02->isA(Class(BaseObject)));
390        testandcout(test5_02->isA(Class(Interface1)));
391
392        std::cout << "\n";
393        std::cout << "test5_01 = A3, Erwartet: 0 0 0 1 1\n";
394        testandcout(test5_03->isA(Class(A1)));
395        testandcout(test5_03->isA(Class(A2)));
396        testandcout(test5_03->isA(Class(A1B1)));
397        testandcout(test5_03->isA(Class(BaseObject)));
398        testandcout(test5_03->isA(Class(Interface1)));
399
400        std::cout << "\n";
401        std::cout << "isDirectA(XYZ)-Test:\n";
402        std::cout << "test5_01 = A1, Erwartet: 1 0 0 0 0\n";
403        testandcout(test5_01->isExactlyA(Class(A1)));
404        testandcout(test5_01->isExactlyA(Class(A2)));
405        testandcout(test5_01->isExactlyA(Class(A1B1)));
406        testandcout(test5_01->isExactlyA(Class(BaseObject)));
407        testandcout(test5_01->isExactlyA(Class(Interface1)));
408
409        std::cout << "\n";
410        std::cout << "test5_02 = A2, Erwartet: 0 1 0 0 0\n";
411        testandcout(test5_02->isExactlyA(Class(A1)));
412        testandcout(test5_02->isExactlyA(Class(A2)));
413        testandcout(test5_02->isExactlyA(Class(A1B1)));
414        testandcout(test5_02->isExactlyA(Class(BaseObject)));
415        testandcout(test5_02->isExactlyA(Class(Interface1)));
416
417        std::cout << "\n";
418        std::cout << "test5_03 = A3, Erwartet: 0 0 0 0 0\n";
419        testandcout(test5_03->isExactlyA(Class(A1)));
420        testandcout(test5_03->isExactlyA(Class(A2)));
421        testandcout(test5_03->isExactlyA(Class(A1B1)));
422        testandcout(test5_03->isExactlyA(Class(BaseObject)));
423        testandcout(test5_03->isExactlyA(Class(Interface1)));
424
425        std::cout << "\n";
426        std::cout << "isChildOf(XYZ)-Test:\n";
427        std::cout << "test5_04 = A1B1, Erwartet: 1 0 1 0 0 0 0\n";
428        testandcout(test5_04->isChildOf(Class(A1)));
429        testandcout(test5_04->isChildOf(Class(A2)));
430        testandcout(test5_04->isChildOf(Class(BaseObject)));
431        testandcout(test5_04->isChildOf(Class(Interface1)));
432        testandcout(test5_04->isChildOf(Class(Interface2)));
433        testandcout(test5_04->isChildOf(Class(A1B1C2)));
434        testandcout(test5_04->isChildOf(Class(A1B1)));
435
436        std::cout << "\n";
437        std::cout << "test5_06 = A2B1, Erwartet: 0 1 1 0 0 0 0\n";
438        testandcout(test5_06->isChildOf(Class(A1)));
439        testandcout(test5_06->isChildOf(Class(A2)));
440        testandcout(test5_06->isChildOf(Class(BaseObject)));
441        testandcout(test5_06->isChildOf(Class(Interface1)));
442        testandcout(test5_06->isChildOf(Class(Interface2)));
443        testandcout(test5_06->isChildOf(Class(A1B1C2)));
444        testandcout(test5_06->isChildOf(Class(A1B1)));
445
446        std::cout << "\n";
447        std::cout << "test5_07 = A2B2, Erwartet: 0 1 1 1 0 0\n";
448        testandcout(test5_07->isChildOf(Class(A1)));
449        testandcout(test5_07->isChildOf(Class(A2)));
450        testandcout(test5_07->isChildOf(Class(BaseObject)));
451        testandcout(test5_07->isChildOf(Class(Interface1)));
452        testandcout(test5_07->isChildOf(Class(Interface2)));
453        testandcout(test5_07->isChildOf(Class(A1B1C2)));
454
455        std::cout << "\n";
456        std::cout << "test5_08 = A3B1, Erwartet: 0 0 1 1 0 0\n";
457        testandcout(test5_08->isChildOf(Class(A1)));
458        testandcout(test5_08->isChildOf(Class(A2)));
459        testandcout(test5_08->isChildOf(Class(BaseObject)));
460        testandcout(test5_08->isChildOf(Class(Interface1)));
461        testandcout(test5_08->isChildOf(Class(Interface2)));
462        testandcout(test5_08->isChildOf(Class(A1B1C2)));
463
464        std::cout << "\n";
465        std::cout << "test5_09 = A3B2, Erwartet: 0 0 1 1 1 0\n";
466        testandcout(test5_09->isChildOf(Class(A1)));
467        testandcout(test5_09->isChildOf(Class(A2)));
468        testandcout(test5_09->isChildOf(Class(BaseObject)));
469        testandcout(test5_09->isChildOf(Class(Interface1)));
470        testandcout(test5_09->isChildOf(Class(Interface2)));
471        testandcout(test5_09->isChildOf(Class(A1B1C2)));
472
473        std::cout << "\n";
474        std::cout << "isDirectChildOf(XYZ)-Test:\n";
475        std::cout << "test5_04 = A1B1, Erwartet: 1 0 0 0 0 0 0\n";
476        testandcout(test5_04->isDirectChildOf(Class(A1)));
477        testandcout(test5_04->isDirectChildOf(Class(A2)));
478        testandcout(test5_04->isDirectChildOf(Class(BaseObject)));
479        testandcout(test5_04->isDirectChildOf(Class(Interface1)));
480        testandcout(test5_04->isDirectChildOf(Class(Interface2)));
481        testandcout(test5_04->isDirectChildOf(Class(A1B1C2)));
482        testandcout(test5_04->isDirectChildOf(Class(A1B1)));
483
484        std::cout << "\n";
485        std::cout << "test5_06 = A2B1, Erwartet: 0 1 0 0 0 0 0\n";
486        testandcout(test5_06->isDirectChildOf(Class(A1)));
487        testandcout(test5_06->isDirectChildOf(Class(A2)));
488        testandcout(test5_06->isDirectChildOf(Class(BaseObject)));
489        testandcout(test5_06->isDirectChildOf(Class(Interface1)));
490        testandcout(test5_06->isDirectChildOf(Class(Interface2)));
491        testandcout(test5_06->isDirectChildOf(Class(A1B1C2)));
492        testandcout(test5_06->isDirectChildOf(Class(A1B1)));
493
494        std::cout << "\n";
495        std::cout << "test5_07 = A2B2, Erwartet: 0 1 0 1 0 0\n";
496        testandcout(test5_07->isDirectChildOf(Class(A1)));
497        testandcout(test5_07->isDirectChildOf(Class(A2)));
498        testandcout(test5_07->isDirectChildOf(Class(BaseObject)));
499        testandcout(test5_07->isDirectChildOf(Class(Interface1)));
500        testandcout(test5_07->isDirectChildOf(Class(Interface2)));
501        testandcout(test5_07->isDirectChildOf(Class(A1B1C2)));
502
503        std::cout << "\n";
504        std::cout << "test5_08 = A3B1, Erwartet: 0 0 0 0 0 0\n";
505        testandcout(test5_08->isDirectChildOf(Class(A1)));
506        testandcout(test5_08->isDirectChildOf(Class(A2)));
507        testandcout(test5_08->isDirectChildOf(Class(BaseObject)));
508        testandcout(test5_08->isDirectChildOf(Class(Interface1)));
509        testandcout(test5_08->isDirectChildOf(Class(Interface2)));
510        testandcout(test5_08->isDirectChildOf(Class(A1B1C2)));
511
512        std::cout << "\n";
513        std::cout << "test5_09 = A3B2, Erwartet: 0 0 0 0 1 0\n";
514        testandcout(test5_09->isDirectChildOf(Class(A1)));
515        testandcout(test5_09->isDirectChildOf(Class(A2)));
516        testandcout(test5_09->isDirectChildOf(Class(BaseObject)));
517        testandcout(test5_09->isDirectChildOf(Class(Interface1)));
518        testandcout(test5_09->isDirectChildOf(Class(Interface2)));
519        testandcout(test5_09->isDirectChildOf(Class(A1B1C2)));
520
521        std::cout << "\n";
522
523        std::cout << "isParentOf(XYZ)-Test:\n";
524        std::cout << "test1 = BaseObject, Erwartet: 0 0 1 1 1 1 1\n";
525        testandcout(test1->isParentOf(Class(BaseObject)));
526        testandcout(test1->isParentOf(Class(Interface1)));
527        testandcout(test1->isParentOf(Class(A1)));
528        testandcout(test1->isParentOf(Class(A2)));
529        testandcout(test1->isParentOf(Class(A1B1)));
530        testandcout(test1->isParentOf(Class(A2B2)));
531        testandcout(test1->isParentOf(Class(A3B1C2)));
532
533        std::cout << "\n";
534        std::cout << "test5_01 = A1, Erwartet: 0 0 0 0 1 0 0\n";
535        testandcout(test5_01->isParentOf(Class(BaseObject)));
536        testandcout(test5_01->isParentOf(Class(Interface1)));
537        testandcout(test5_01->isParentOf(Class(A1)));
538        testandcout(test5_01->isParentOf(Class(A2)));
539        testandcout(test5_01->isParentOf(Class(A1B1)));
540        testandcout(test5_01->isParentOf(Class(A2B2)));
541        testandcout(test5_01->isParentOf(Class(A3B1C2)));
542
543        std::cout << "\n";
544        std::cout << "Interface1, Erwartet: 0 0 0 0 0 1 1\n";
545        testandcout(Class(Interface1)->isParentOf(Class(BaseObject)));
546        testandcout(Class(Interface1)->isParentOf(Class(Interface1)));
547        testandcout(Class(Interface1)->isParentOf(Class(A1)));
548        testandcout(Class(Interface1)->isParentOf(Class(A2)));
549        testandcout(Class(Interface1)->isParentOf(Class(A1B1)));
550        testandcout(Class(Interface1)->isParentOf(Class(A2B2)));
551        testandcout(Class(Interface1)->isParentOf(Class(A3B1C2)));
552
553        std::cout << "\n";
554        std::cout << "isDirectParentOf(XYZ)-Test:\n";
555        std::cout << "test1 = BaseObject, Erwartet: 0 0 1 1 0 0 0\n";
556        testandcout(test1->isDirectParentOf(Class(BaseObject)));
557        testandcout(test1->isDirectParentOf(Class(Interface1)));
558        testandcout(test1->isDirectParentOf(Class(A1)));
559        testandcout(test1->isDirectParentOf(Class(A2)));
560        testandcout(test1->isDirectParentOf(Class(A1B1)));
561        testandcout(test1->isDirectParentOf(Class(A2B2)));
562        testandcout(test1->isDirectParentOf(Class(A3B1C2)));
563
564        std::cout << "\n";
565        std::cout << "test5_01 = A1, Erwartet: 0 0 0 0 1 0 0\n";
566        testandcout(test5_01->isDirectParentOf(Class(BaseObject)));
567        testandcout(test5_01->isDirectParentOf(Class(Interface1)));
568        testandcout(test5_01->isDirectParentOf(Class(A1)));
569        testandcout(test5_01->isDirectParentOf(Class(A2)));
570        testandcout(test5_01->isDirectParentOf(Class(A1B1)));
571        testandcout(test5_01->isDirectParentOf(Class(A2B2)));
572        testandcout(test5_01->isDirectParentOf(Class(A3B1C2)));
573
574        std::cout << "\n";
575        std::cout << "Interface1, Erwartet: 0 0 0 0 0 1 0\n";
576        testandcout(Class(Interface1)->isDirectParentOf(Class(BaseObject)));
577        testandcout(Class(Interface1)->isDirectParentOf(Class(Interface1)));
578        testandcout(Class(Interface1)->isDirectParentOf(Class(A1)));
579        testandcout(Class(Interface1)->isDirectParentOf(Class(A2)));
580        testandcout(Class(Interface1)->isDirectParentOf(Class(A1B1)));
581        testandcout(Class(Interface1)->isDirectParentOf(Class(A2B2)));
582        testandcout(Class(Interface1)->isDirectParentOf(Class(A3B1C2)));
583*/
584/*
585        std::cout << "Test 6\n";
586        std::cout << "1\n";
587        Identifier* test6_01 = Class(A1B1);
588        std::cout << "2\n";
589        Identifier* test6_02 = Class(A1B1);
590        std::cout << "3\n";
591        Identifier* test6_03 = Class(A1);
592        std::cout << "4\n";
593        Identifier* test6_04 = Class(A1B1C1);
594        std::cout << "5\n";
595        Identifier* test6_05 = Class(A1B1);
596        std::cout << "6\n";
597        Identifier* test6_06 = Class(A1B1C1);
598
599        std::cout << "7\n";
600
601        std::cout << "\n";
602        std::cout << "BaseObject: parents:         " << Class(BaseObject)->getParents() << "\n";
603        std::cout << "BaseObject: children:        " << Class(BaseObject)->getChildren() << "\n";
604        std::cout << "BaseObject: direct parents:  " << Class(BaseObject)->getDirectParents() << "\n";
605        std::cout << "BaseObject: direct children: " << Class(BaseObject)->getDirectChildren() << "\n";
606
607        std::cout << "\n";
608        std::cout << "A1: parents:                 " << Class(A1)->getParents() << "\n";
609        std::cout << "A1: children:                " << Class(A1)->getChildren() << "\n";
610        std::cout << "A1: direct parents:          " << Class(A1)->getDirectParents() << "\n";
611        std::cout << "A1: direct children:         " << Class(A1)->getDirectChildren() << "\n";
612
613        std::cout << "\n";
614        std::cout << "A1B1: parents:               " << Class(A1B1)->getParents() << "\n";
615        std::cout << "A1B1: children:              " << Class(A1B1)->getChildren() << "\n";
616        std::cout << "A1B1: direct parents:        " << Class(A1B1)->getDirectParents() << "\n";
617        std::cout << "A1B1: direct children:       " << Class(A1B1)->getDirectChildren() << "\n";
618
619        std::cout << "\n";
620        std::cout << "A1B1C1: parents:             " << Class(A1B1C1)->getParents() << "\n";
621        std::cout << "A1B1C1: children:            " << Class(A1B1C1)->getChildren() << "\n";
622        std::cout << "A1B1C1: direct parents:      " << Class(A1B1C1)->getDirectParents() << "\n";
623        std::cout << "A1B1C1: direct children:     " << Class(A1B1C1)->getDirectChildren() << "\n";
624
625        std::cout << "\n";
626        std::cout << "A3B1C1 child of A3:      " << Class(A3B1C1)->isChildOf(Class(A3)) << "\n";
627        std::cout << "\n";
628        std::cout << "A2 parent of A2B1C1:     " << Class(A2)->isParentOf(Class(A2B1C1)) << "\n";
629
630        std::cout << "8\n";
631*/
632/*
633        std::cout << "Test 7\n";
634        std::cout << "1\n";
635        SubclassIdentifier<A1B1> test7_01;
636        test7_01 = Class(A1B1C1);
637
638        SubclassIdentifier<A1B1> test7_02;
639        test7_02 = Class(A1B1);
640
641        std::cout << test7_01->getName() << "\n";
642        std::cout << test7_02->getName() << "\n";
643*/
644/*
645// ## WARNING - CRASH! ##
646        std::cout << "2\n";
647
648        SubclassIdentifier<A1B1> test7_03;
649        test7_03 = Class(A1);
650
651        SubclassIdentifier<A1B1> test7_04;
652        test7_04 = Class(A1B2);
653
654        SubclassIdentifier<A1B1> test7_05;
655        test7_05 = Class(A2);
656// ## END WARNING - CRASH! ##
657*/
658/*
659        std::cout << "Test 8\n";
660
661        std::cout << "1\n";
662        Test1* test8_01 = new Test1;
663        Test3* test8_03 = new Test3;
664        test8_03->usefullClassesIsATest(test8_01);
665
666        std::cout << "2\n";
667        Test2* test8_02 = new Test2;
668        test8_03->usefullClassesIsATest(test8_02);
669
670        std::cout << "3\n";
671        test8_01->setUsefullClass1(Class(Test1));
672        test8_01->setUsefullClass1(test8_02->getIdentifier());
673        test8_01->setUsefullClass2(Class(Test2));
674        test8_01->setUsefullClassOfTypeTest3(Class(Test3));
675        test8_01->setUsefullClassOfTypeTest3(test8_03->getIdentifier());
676
677
678        testandcout(test8_01->isA(Class(Test1)));
679        testandcout(test8_01->isA(Class(Test2)));
680        testandcout(test8_01->isA(Class(Test3)));
681
682        Test2* test8_04 = new Test2;
683        testandcout(test8_02->isA(Class(Test1)));
684        testandcout(test8_02->isA(Class(Test2)));
685        testandcout(test8_02->isA(Class(Test3)));
686
687        Test3* test8_05 = new Test3;
688        testandcout(test8_03->isA(Class(Test1)));
689        testandcout(test8_03->isA(Class(Test2)));
690        testandcout(test8_03->isA(Class(Test3)));
691
692        delete test8_01;
693        delete test8_02;
694        delete test8_03;
695*/
696/*
697        std::cout << "Test 9\n";
698        std::cout << "1\n";
699        Identifier* test9_01 = Class(A3);
700        BaseObject* test9_02 = test9_01->fabricate();
701        std::cout << test9_02->getIdentifier()->getName() << "\n";
702
703        std::cout << "\n2\n";
704        BaseObject* test9_03 = Class(A1B2)->fabricate();
705        std::cout << test9_03->getIdentifier()->getName() << "\n";
706
707        std::cout << "\n3\n";
708        SubclassIdentifier<A1> test9_04;
709        test9_04 = Class(A1B1C1);
710        A1* test9_05 = test9_04.fabricate();
711        std::cout << test9_05->getIdentifier()->getName() << "\n";
712
713        std::cout << "\n4\n";
714        BaseObject* test9_06 = ID("A2B2")->fabricate();
715        std::cout << test9_06->getIdentifier()->getName() << "\n";
716
717        std::cout << "\n5\n";
718        delete test9_02;
719        delete test9_03;
720        delete test9_05;
721        delete test9_06;
722*/
723/*
724        std::cout << "Test 10\n";
725        Identifier* test10_01 = Class(A1B2);
726        Identifier* test10_02 = Class(A2);
727        Identifier* test10_03 = Class(A3B1C1);
728
729        BaseObject* test10_04 = test10_01->fabricate();
730        BaseObject* test10_05 = test10_02->fabricate();
731        BaseObject* test10_06 = test10_03->fabricate();
732
733        BaseObject* test10_07;
734        for (int i = 0; i < 10; i++)
735            test10_07 = ID("A1B1C1")->fabricate();
736
737        std::cout << "1\n";
738        int count;
739
740        count = 0; for (Iterator<BaseObject> it = ObjectList<BaseObject>::start(); it; ++it) { count++; }
741        std::cout << "Anzahl BaseObjects: " << count << "\n";
742        count = 0; for (Iterator<A1> it = ObjectList<A1>::start(); it; ++it) { count++; }
743        std::cout << "Anzahl A1: " << count << "\n";
744        count = 0; for (Iterator<A1B1> it = ObjectList<A1B1>::start(); it; ++it) { count++; }
745        std::cout << "Anzahl A1B1: " << count << "\n";
746        count = 0; for (Iterator<A1B1C1> it = ObjectList<A1B1C1>::start(); it; ++it) { count++; }
747        std::cout << "Anzahl A1B1C1: " << count << "\n";
748        count = 0; for (Iterator<A2> it = ObjectList<A2>::start(); it; ++it) { count++; }
749        std::cout << "Anzahl A2: " << count << "\n";
750
751        std::cout << "2\n";
752        BaseObject* test10_08;
753        BaseObject* test10_09 = 0;
754        BaseObject* test10_10 = 0;
755        for (int i = 0; i < 10; i++)
756        {
757            test10_08 = ID("A2B1C1")->fabricate();
758            std::string objName = "A2B1C1#";
759            objName += '0' + i;
760            test10_08->setName(objName);
761
762            if (i == 0)
763                test10_09 = test10_08;
764
765            if (i == 5)
766                test10_10 = test10_08;
767        }
768
769        count = 0; for (Iterator<BaseObject> it = ObjectList<BaseObject>::start(); it; ++it) { count++; }
770        std::cout << "Anzahl BaseObjects: " << count << "\n";
771        count = 0; for (Iterator<A1> it = ObjectList<A1>::start(); it; ++it) { count++; }
772        std::cout << "Anzahl A1: " << count << "\n";
773        count = 0; for (Iterator<A1B1> it = ObjectList<A1B1>::start(); it; ++it) { count++; }
774        std::cout << "Anzahl A1B1: " << count << "\n";
775        count = 0; for (Iterator<A1B1C1> it = ObjectList<A1B1C1>::start(); it; ++it) { count++; }
776        std::cout << "Anzahl A1B1C1: " << count << "\n";
777        count = 0; for (Iterator<A2> it = ObjectList<A2>::start(); it; ++it) { count++; }
778        std::cout << "Anzahl A2: " << count << "\n";
779
780        for (Iterator<A2B1C1> it = ObjectList<A2B1C1>::start(); it; ++it)
781            std::cout << "Name: " << it->getName() << "\n";
782
783        std::cout << "3\n";
784        for (Iterator<A2B1C1> it = ObjectList<A2B1C1>::end(); it; --it)
785            std::cout << "Name: " << it->getName() << "\n";
786
787        std::cout << "4\n";
788        delete test10_08;
789
790        count = 0; for (Iterator<BaseObject> it = ObjectList<BaseObject>::start(); it; ++it) { count++; }
791        std::cout << "Anzahl BaseObjects: " << count << "\n";
792        count = 0; for (Iterator<A1> it = ObjectList<A1>::start(); it; ++it) { count++; }
793        std::cout << "Anzahl A1: " << count << "\n";
794        count = 0; for (Iterator<A1B1> it = ObjectList<A1B1>::start(); it; ++it) { count++; }
795        std::cout << "Anzahl A1B1: " << count << "\n";
796        count = 0; for (Iterator<A1B1C1> it = ObjectList<A1B1C1>::start(); it; ++it) { count++; }
797        std::cout << "Anzahl A1B1C1: " << count << "\n";
798        count = 0; for (Iterator<A2> it = ObjectList<A2>::start(); it; ++it) { count++; }
799        std::cout << "Anzahl A2: " << count << "\n";
800
801        std::cout << "5\n";
802        for (Iterator<A2B1C1> it = ObjectList<A2B1C1>::start(); it; ++it)
803            std::cout << "Name: " << it->getName() << "\n";
804
805        std::cout << "6\n";
806        for (Iterator<A2B1C1> it = ObjectList<A2B1C1>::end(); it; --it)
807            std::cout << "Name: " << it->getName() << "\n";
808
809        std::cout << "7\n";
810        delete test10_09;
811
812        count = 0; for (Iterator<BaseObject> it = ObjectList<BaseObject>::end(); it; --it) { count++; }
813        std::cout << "Anzahl BaseObjects: " << count << "\n";
814        count = 0; for (Iterator<A1> it = ObjectList<A1>::end(); it; --it) { count++; }
815        std::cout << "Anzahl A1: " << count << "\n";
816        count = 0; for (Iterator<A1B1> it = ObjectList<A1B1>::end(); it; --it) { count++; }
817        std::cout << "Anzahl A1B1: " << count << "\n";
818        count = 0; for (Iterator<A1B1C1> it = ObjectList<A1B1C1>::end(); it; --it) { count++; }
819        std::cout << "Anzahl A1B1C1: " << count << "\n";
820        count = 0; for (Iterator<A2> it = ObjectList<A2>::end(); it; --it) { count++; }
821        std::cout << "Anzahl A2: " << count << "\n";
822
823        std::cout << "8\n";
824        for (Iterator<A2B1C1> it = ObjectList<A2B1C1>::start(); it; ++it)
825            std::cout << "Name: " << it->getName() << "\n";
826
827        std::cout << "9\n";
828        for (Iterator<A2B1C1> it = ObjectList<A2B1C1>::end(); it; --it)
829            std::cout << "Name: " << it->getName() << "\n";
830
831        std::cout << "10\n";
832        delete test10_10;
833
834        count = 0; for (Iterator<BaseObject> it = ObjectList<BaseObject>::start(); it; ++it) { count++; }
835        std::cout << "Anzahl BaseObjects: " << count << "\n";
836        count = 0; for (Iterator<A1> it = ObjectList<A1>::start(); it; ++it) { count++; }
837        std::cout << "Anzahl A1: " << count << "\n";
838        count = 0; for (Iterator<A1B1> it = ObjectList<A1B1>::start(); it; ++it) { count++; }
839        std::cout << "Anzahl A1B1: " << count << "\n";
840        count = 0; for (Iterator<A1B1C1> it = ObjectList<A1B1C1>::start(); it; ++it) { count++; }
841        std::cout << "Anzahl A1B1C1: " << count << "\n";
842        count = 0; for (Iterator<A2> it = ObjectList<A2>::start(); it; ++it) { count++; }
843        std::cout << "Anzahl A2: " << count << "\n";
844
845        std::cout << "11\n";
846        for (Iterator<A2B1C1> it = ObjectList<A2B1C1>::start(); it; ++it)
847            std::cout << "Name: " << it->getName() << "\n";
848
849        std::cout << "12\n";
850        for (Iterator<A2B1C1> it = ObjectList<A2B1C1>::end(); it; --it)
851            std::cout << "Name: " << it->getName() << "\n";
852
853        std::cout << "13\n";
854*/
855/*
856        std::cout << "Test 11\n";
857        std::cout << "1\n";
858        int count2 = 0; for (Iterator<Tickable> it = ObjectList<Tickable>::start(); it; ++it) { count2++; }
859        std::cout << "AnzahlTickable: " << count2 << "\n";
860
861        Test1* test11_1;
862        for (int i = 0; i < 3; i++)
863            test11_1 = new Test1;
864
865        count2 = 0; for (Iterator<Tickable> it = ObjectList<Tickable>::start(); it; ++it) { count2++; }
866        std::cout << "AnzahlTickable: " << count2 << "\n";
867
868        for (Iterator<Tickable> it = ObjectList<Tickable>::start(); it; ++it)
869            it->tick(0);
870
871        std::cout << "2\n";
872        Test2* test11_2 = new Test2;
873
874
875        std::cout << "3\n";
876        Test3* test11_3 = new Test3;
877        test11_3->configOutput();
878
879        std::cout << "4\n";
880*/
881/*
882        std::cout << "Test 12\n";
883        std::cout << "1\n";
884
885        WorldEntity* test12_1 = new WorldEntity;
886
887        std::cout << sizeof(WorldEntity) << std::endl;
888
889        std::cout << "2\n";
890*/
891/*
892        std::cout << "Test 13\n";
893
894        #define BoolToYesNo(bool) \
895            if (bool) \
896                std::cout << "yes "; \
897            else \
898                std::cout << "no  "
899
900        #define TestClassTreeMask(mask) \
901            std::cout << "========== ClassTreeMask-Test ===========" << std::endl; \
902            std::cout << mask << std::endl << std::endl; \
903            std::cout << "                 "; \
904            BoolToYesNo(mask.isIncluded(Class(BaseObject))); \
905            std::cout << std::endl; \
906            \
907            std::cout << "     "; \
908            BoolToYesNo(mask.isIncluded(Class(A1))); \
909            std::cout << "        "; \
910            BoolToYesNo(mask.isIncluded(Class(A2))); \
911            std::cout << "           "; \
912            BoolToYesNo(mask.isIncluded(Class(A3))); \
913            std::cout << std::endl; \
914            \
915            std::cout << "  "; \
916            BoolToYesNo(mask.isIncluded(Class(A1B1))); \
917            std::cout << "  "; \
918            BoolToYesNo(mask.isIncluded(Class(A1B2))); \
919            std::cout << "  "; \
920            BoolToYesNo(mask.isIncluded(Class(A2B1))); \
921            std::cout << "  "; \
922            BoolToYesNo(mask.isIncluded(Class(A2B2))); \
923            std::cout << "    "; \
924            BoolToYesNo(mask.isIncluded(Class(A3B1))); \
925            std::cout << "    "; \
926            BoolToYesNo(mask.isIncluded(Class(A3B2))); \
927            std::cout << std::endl; \
928            \
929            BoolToYesNo(mask.isIncluded(Class(A1B1C1))); \
930            BoolToYesNo(mask.isIncluded(Class(A1B1C2))); \
931            BoolToYesNo(mask.isIncluded(Class(A1B2C1))); \
932            std::cout << "  "; \
933            BoolToYesNo(mask.isIncluded(Class(A2B1C1))); \
934            std::cout << "  "; \
935            BoolToYesNo(mask.isIncluded(Class(A2B2C1))); \
936            std::cout << "  "; \
937            BoolToYesNo(mask.isIncluded(Class(A3B1C1))); \
938            BoolToYesNo(mask.isIncluded(Class(A3B1C2))); \
939            BoolToYesNo(mask.isIncluded(Class(A3B2C1))); \
940            BoolToYesNo(mask.isIncluded(Class(A3B2C2))); \
941            std::cout << std::endl; \
942            std::cout << "=========================================" << std::endl
943
944        std::cout << "1\n";
945
946        ClassTreeMask test13_1;
947        test13_1.exclude(Class(A1B1));
948        test13_1.exclude(Class(A2));
949        test13_1.include(Class(A2B2));
950        test13_1.exclude(Class(A2B2C1));
951        test13_1.exclude(Class(A3B1));
952        test13_1.include(Class(A3B1C2));
953        test13_1.exclude(Class(A3B2C1));
954        test13_1.exclude(Class(A3B2C2));
955        std::cout << "Mask 1:\n";
956        TestClassTreeMask(test13_1);
957
958        ClassTreeMask test13_2;
959        test13_2.exclude(Class(BaseObject));
960        test13_2.include(Class(A1));
961        test13_2.exclude(Class(A1B2));
962        test13_2.exclude(Class(A1B1C2));
963        test13_2.include(Class(A2));
964        test13_2.exclude(Class(A2B2));
965        test13_2.include(Class(A3B1));
966        test13_2.include(Class(A3B2));
967        test13_2.exclude(Class(A3B2C2));
968        std::cout << std::endl;
969        std::cout << "Mask 2:\n";
970        TestClassTreeMask(test13_2);
971
972        std::cout << "2\n";
973
974        ClassTreeMask test13_3;
975        test13_3.include(Class(A1), true, false);
976        test13_3.exclude(Class(A1B2), true, false);
977        test13_3.exclude(Class(A1B1C2), true, false);
978        test13_3.include(Class(A2), true, false);
979        test13_3.exclude(Class(A2B2), true, false);
980        test13_3.include(Class(A3B1), true, false);
981        test13_3.include(Class(A3B2), true, false);
982        test13_3.exclude(Class(A3B2C2), true, false);
983        std::cout << std::endl;
984        std::cout << "Mask 2 without excluded BaseObject:\n";
985        TestClassTreeMask(test13_3);
986        test13_3.exclude(Class(BaseObject), false, false);
987        std::cout << std::endl;
988        std::cout << "Mask 2 with BaseObject excluded afterwards without overwrite:\n";
989        TestClassTreeMask(test13_3);
990        test13_3.exclude(Class(BaseObject), true);
991        std::cout << std::endl;
992        std::cout << "Mask 2 with BaseObject excluded afterwards with overwrite:\n";
993        TestClassTreeMask(test13_3);
994
995        ClassTreeMask test13_4;
996        test13_4.include(Class(A3B2));
997        test13_4.exclude(Class(A1B1C2));
998        test13_4.include(Class(A3B1));
999        test13_4.exclude(Class(A3B2C2));
1000        test13_4.exclude(Class(BaseObject));
1001        test13_4.include(Class(A2));
1002        test13_4.exclude(Class(A1B2));
1003        test13_4.exclude(Class(A2B2));
1004        test13_4.include(Class(A1));
1005        std::cout << std::endl;
1006        std::cout << "Mask 2 created in random order with overwrite and clean:\n";
1007        TestClassTreeMask(test13_4);
1008
1009        ClassTreeMask test13_4_2;
1010        test13_4_2.include(Class(A3B2), false, false);
1011        test13_4_2.exclude(Class(A1B1C2), false, false);
1012        test13_4_2.include(Class(A3B1), false, false);
1013        test13_4_2.exclude(Class(A3B2C2), false, false);
1014        test13_4_2.exclude(Class(BaseObject), false, false);
1015        test13_4_2.include(Class(A2), false, false);
1016        test13_4_2.exclude(Class(A1B2), false, false);
1017        test13_4_2.exclude(Class(A2B2), false, false);
1018        test13_4_2.include(Class(A1), false, false);
1019        std::cout << std::endl;
1020        std::cout << "Mask 2 created in random order without overwrite and without clean:\n";
1021        TestClassTreeMask(test13_4_2);
1022
1023        std::cout << "3\n";
1024
1025        ClassTreeMask test13_6 = !test13_1;
1026        std::cout << std::endl;
1027        std::cout << "Mask 1 inverted:\n";
1028        TestClassTreeMask(test13_6);
1029
1030        std::cout << "4\n";
1031
1032        ClassTreeMask test13_7 = test13_1 + test13_2;
1033        std::cout << std::endl;
1034        std::cout << "Mask 1 + Mask 2:\n";
1035        TestClassTreeMask(test13_7);
1036
1037        std::cout << "5\n";
1038
1039        ClassTreeMask test13_8 = test13_1 * test13_2;
1040        std::cout << std::endl;
1041        std::cout << "Mask 1 * Mask 2:\n";
1042        TestClassTreeMask(test13_8);
1043
1044        std::cout << "6\n";
1045
1046        ClassTreeMask test13_9 = test13_1 - test13_2;
1047        std::cout << std::endl;
1048        std::cout << "Mask 1 - Mask 2:\n";
1049        TestClassTreeMask(test13_9);
1050
1051        std::cout << "7\n";
1052
1053        ClassTreeMask test13_10 = test13_1 ^ test13_2;
1054        std::cout << std::endl;
1055        std::cout << "Mask 1 ^ Mask 2:\n";
1056        TestClassTreeMask(test13_10);
1057
1058        std::cout << "8\n";
1059
1060        ClassTreeMask test13_12(!test13_1);
1061        std::cout << std::endl;
1062        std::cout << "Mask 1 inverted assigned with copyconstructor + the original from before:\n";
1063        TestClassTreeMask(test13_12);
1064        TestClassTreeMask(test13_1);
1065
1066
1067        ClassTreeMask test13_13 = test13_1 + test13_2;
1068        std::cout << std::endl;
1069        std::cout << "Mask 1 + Mask 2 assigned with copyconstructor + originals from before:\n";
1070        TestClassTreeMask(test13_13);
1071        TestClassTreeMask(test13_1);
1072        TestClassTreeMask(test13_2);
1073
1074        ClassTreeMask test13_14 = test13_1;
1075        test13_14 += test13_2;
1076        std::cout << std::endl;
1077        std::cout << "Mask 1 + Mask 2 with += operator + original of mask 2 from before:\n";
1078        TestClassTreeMask(test13_14);
1079        TestClassTreeMask(test13_2);
1080
1081        test13_1 = test13_1;
1082        std::cout << std::endl;
1083        std::cout << "Mask 1 assigned with = operator to itself:\n";
1084        TestClassTreeMask(test13_1);
1085
1086        std::cout << "9\n";
1087
1088        ClassTreeMask test13_15;
1089        test13_15.exclude(Class(Interface1));
1090        std::cout << std::endl;
1091        std::cout << "Mask with excluded Interface 1:\n";
1092        TestClassTreeMask(test13_15);
1093
1094        ClassTreeMask test13_16 = test13_1;
1095        test13_16.exclude(Class(Interface1));
1096        std::cout << std::endl;
1097        std::cout << "Mask 1 with excluded Interface 1 (overwrite):\n";
1098        TestClassTreeMask(test13_16);
1099
1100        ClassTreeMask test13_17 = test13_1;
1101        test13_17.exclude(Class(Interface1), false);
1102        std::cout << std::endl;
1103        std::cout << "Mask 1 with excluded Interface 1 (without overwrite):\n";
1104        TestClassTreeMask(test13_17);
1105
1106        ClassTreeMask test13_18 = test13_2;
1107        test13_18.exclude(Class(Interface1), false);
1108        std::cout << std::endl;
1109        std::cout << "Mask 2 with excluded Interface 1 (without overwrite):\n";
1110        TestClassTreeMask(test13_18);
1111
1112        std::cout << "10\n";
1113
1114        ClassTreeMask test13_19;
1115        test13_19.exclude(Class(Test1));
1116        std::cout << std::endl;
1117        std::cout << "Mask with excluded Test1:\n";
1118        TestClassTreeMask(test13_19);
1119
1120        std::cout << "11\n";
1121
1122        ClassTreeMask test13_20;
1123        test13_20.exclude(Class(DebugLevel));
1124        std::cout << std::endl;
1125        std::cout << "Mask with excluded DebugLevel:\n";
1126        TestClassTreeMask(test13_20);
1127
1128        std::cout << "12\n";
1129
1130        ClassTreeMask test13_21;
1131        test13_21.excludeSingle(Class(A2));
1132        std::cout << std::endl;
1133        std::cout << "Mask with single-excluded A2:\n";
1134        TestClassTreeMask(test13_21);
1135
1136        test13_21.exclude(Class(A2));
1137        std::cout << std::endl;
1138        std::cout << "Mask with excluded A2:\n";
1139        TestClassTreeMask(test13_21);
1140
1141        test13_21.includeSingle(Class(A2));
1142        std::cout << std::endl;
1143        std::cout << "Previous mask with single-included A2:\n";
1144        TestClassTreeMask(test13_21);
1145
1146        test13_21.includeSingle(Class(A2), false);
1147        std::cout << std::endl;
1148        std::cout << "Previous mask with single-included A2 without clean:\n";
1149        TestClassTreeMask(test13_21);
1150
1151        std::cout << "13\n";
1152*/
1153/*
1154        std::cout << "Test 14\n";
1155        std::cout << "1\n";
1156
1157        SubclassIdentifier<A1> test14_1;
1158        test14_1 = Class(A1B1C1);
1159        std::cout << test14_1.getIdentifier()->getName() << std::endl;
1160
1161        SubclassIdentifier<A1> test14_2 = Class(A1B1C2);
1162        std::cout << test14_2.getIdentifier()->getName() << std::endl;
1163
1164        SubclassIdentifier<Interface1> test14_3;
1165        test14_3 = Class(A2B2C1);
1166        std::cout << test14_3.getIdentifier()->getName() << std::endl;
1167
1168        SubclassIdentifier<A1B2> test14_4;
1169        test14_4 = Class(A1B2C1);
1170        std::cout << test14_4.getIdentifier()->getName() << std::endl;
1171
1172        SubclassIdentifier<BaseObject> test14_5 = Class(Test1);
1173        std::cout << test14_5.getIdentifier()->getName() << std::endl;
1174
1175        std::cout << "2\n";
1176*/
1177/*
1178        std::cout << "Test 15\n";
1179        std::cout << "1\n";
1180
1181        Level* test15_1 = new Level("levels/sample.oxw");
1182        Loader::open(test15_1);
1183
1184        std::cout << "2\n";
1185*/
1186        InputBuffer* ib = new InputBuffer(this->getKeyboard());
1187        Testlistener* testlistener = new Testlistener(ib);
1188        ib->registerListener(testlistener, &Testlistener::listen, true);
1189        ib->registerListener(testlistener, &Testlistener::execute, '\r', false);
1190        ib->registerListener(testlistener, &Testlistener::hintandcomplete, '\t', true);
1191        ib->registerListener(testlistener, &Testlistener::clear, '§', true);
1192        ib->registerListener(testlistener, &Testlistener::removeLast, '\b', true);
1193
1194    startRenderLoop();
1195  }
1196
1197  /**
1198   * @return singleton object
1199   */
1200  Orxonox* Orxonox::getSingleton()
1201  {
1202    if (!singletonRef_)
1203      singletonRef_ = new Orxonox();
1204    return singletonRef_;
1205  }
1206
1207  /**
1208   * error kills orxonox
1209   */
1210  void Orxonox::die(/* some error code */)
1211  {
1212    //TODO: destroy and destruct everything and print nice error msg
1213    delete this;
1214  }
1215
1216  void Orxonox::standaloneInit(std::string path)
1217  {
1218    ogre_->setConfigPath(path);
1219    ogre_->setup();
1220    root_ = ogre_->getRoot();
1221    if(!ogre_->load()) die(/* unable to load */);
1222
1223    //defineResources();
1224    //setupRenderSystem();
1225    //createRenderWindow();
1226    //initializeResourceGroups();
1227    /*createScene();
1228    setupScene();
1229    setupInputSystem();
1230    createFrameListener();
1231    Factory::createClassHierarchy();
1232    startRenderLoop();*/
1233  }
1234
1235  void Orxonox::playableServer(std::string path)
1236  {
1237    ogre_->setConfigPath(path);
1238    ogre_->setup();
1239    root_ = ogre_->getRoot();
1240    defineResources();
1241    setupRenderSystem();
1242    createRenderWindow();
1243    initializeResourceGroups();
1244    setupInputSystem();
1245    Factory::createClassHierarchy();
1246    createScene();
1247    setupScene();
1248    createFrameListener();
1249    try{
1250//      server_g = new network::Server(); //!< add port and bindadress
1251//      server_g->open(); //!< open server and create listener thread
1252//      if(ogre_ && ogre_->getRoot())
1253//        ogre_->getRoot()->addFrameListener(new network::ServerFrameListener()); // adds a framelistener for the server
1254      COUT(3) << "Info: network framelistener added" << std::endl;
1255    }
1256    catch(...)
1257    {
1258      COUT(1) << "Error: There was a problem initialising the server :(" << std::endl;
1259    }
1260    startRenderLoop();
1261  }
1262
1263  void Orxonox::standalone(){
1264
1265
1266
1267  }
1268
1269  void Orxonox::serverInit(std::string path)
1270  {
1271    COUT(2) << "initialising server" << std::endl;
1272    ogre_->setConfigPath(path);
1273    ogre_->setup();
1274//    server_g = new network::Server(); // FIXME add some settings if wanted
1275    if(!ogre_->load()) die(/* unable to load */);
1276    // FIXME add network framelistener
1277  }
1278
1279  void Orxonox::clientInit(std::string path)
1280  {
1281    COUT(2) << "initialising client" << std::endl;
1282    ogre_->setConfigPath(path);
1283    ogre_->setup();
1284//    if(serverIp_.compare("")==0)
1285//      client_g = new network::Client();
1286//    else
1287//      client_g = new network::Client(serverIp_, 55556);
1288    if(!ogre_->load()) die(/* unable to load */);
1289//    ogre_->getRoot()->addFrameListener(new network::ClientFrameListener());
1290  }
1291
1292  void Orxonox::defineResources()
1293  {
1294    std::string secName, typeName, archName;
1295    Ogre::ConfigFile cf;
1296#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
1297    cf.load(macBundlePath() + "/Contents/Resources/resources.cfg");
1298#else
1299    cf.load(dataPath_ + "resources.cfg");
1300#endif
1301
1302    Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator();
1303    while (seci.hasMoreElements())
1304    {
1305      secName = seci.peekNextKey();
1306      Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext();
1307      Ogre::ConfigFile::SettingsMultiMap::iterator i;
1308      for (i = settings->begin(); i != settings->end(); ++i)
1309      {
1310        typeName = i->first;
1311        archName = i->second;
1312#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
1313        Ogre::ResourceGroupManager::getSingleton().addResourceLocation( std::string(macBundlePath() + "/" + archName), typeName, secName);
1314#else
1315        Ogre::ResourceGroupManager::getSingleton().addResourceLocation( archName, typeName, secName);
1316#endif
1317      }
1318    }
1319  }
1320
1321  void Orxonox::setupRenderSystem()
1322  {
1323    if (!root_->restoreConfig() && !root_->showConfigDialog())
1324      throw Ogre::Exception(52, "User canceled the config dialog!", "OrxApplication::setupRenderSystem()");
1325  }
1326
1327  void Orxonox::createRenderWindow()
1328  {
1329    root_->initialise(true, "OrxonoxV2");
1330  }
1331
1332  void Orxonox::initializeResourceGroups()
1333  {
1334    Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5);
1335    Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
1336  }
1337
1338  /**
1339   *
1340   * @param
1341   */
1342  void Orxonox::createScene(void)
1343  {
1344        // Init audio
1345//    auMan_ = new audio::AudioManager();
1346
1347//    bulletMgr_ = new BulletManager();
1348
1349    // load this file from config
1350//    loader_ = new loader::LevelLoader("sample.oxw");
1351//    loader_->loadLevel();
1352    Level* startlevel = new Level("levels/sample.oxw");
1353    Loader::open(startlevel);
1354
1355//    Ogre::Overlay* hudOverlay = Ogre::OverlayManager::getSingleton().getByName("Orxonox/HUD1.2");
1356//    HUD* orxonoxHud;
1357//    orxonoxHud = new HUD();
1358//    orxonoxHud->setEnergyValue(20);
1359//    orxonoxHud->setEnergyDistr(20,20,60);
1360//    hudOverlay->show();
1361
1362        /*
1363    auMan_->ambientAdd("a1");
1364    auMan_->ambientAdd("a2");
1365    auMan_->ambientAdd("a3");
1366                                //auMan->ambientAdd("ambient1");
1367    auMan_->ambientStart();*/
1368  }
1369
1370
1371  /**
1372   *
1373   */
1374  void Orxonox::setupScene()
1375  {
1376//    SceneManager *mgr = ogre_->getSceneManager();
1377
1378
1379//    SceneNode* node = (SceneNode*)mgr->getRootSceneNode()->getChild("OgreHeadNode");
1380//     SceneNode *node = mgr->getRootSceneNode()->createChildSceneNode("OgreHeadNode", Vector3(0,0,0));
1381
1382
1383/*
1384    particle::ParticleInterface *e = new particle::ParticleInterface(mgr,"engine","Orxonox/strahl");
1385    e->particleSystem_->setParameter("local_space","true");
1386    e->setPositionOfEmitter(0, Vector3(0,-10,0));
1387    e->setDirection(Vector3(0,0,-1));
1388    e->addToSceneNode(node);
1389*/
1390  }
1391
1392
1393  void Orxonox::setupInputSystem()
1394  {
1395    size_t windowHnd = 0;
1396    std::ostringstream windowHndStr;
1397    OIS::ParamList pl;
1398
1399    // fixes auto repeat problem
1400    #if defined OIS_LINUX_PLATFORM
1401      pl.insert(std::make_pair(std::string("XAutoRepeatOn"), std::string("true")));
1402    #endif
1403
1404      Ogre::RenderWindow *win = ogre_->getRoot()->getAutoCreatedWindow();
1405    win->getCustomAttribute("WINDOW", &windowHnd);
1406    windowHndStr << windowHnd;
1407    pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
1408    inputManager_ = OIS::InputManager::createInputSystem(pl);
1409
1410    try
1411    {
1412      keyboard_ = static_cast<OIS::Keyboard*>(inputManager_->createInputObject(OIS::OISKeyboard, true));
1413      mouse_ = static_cast<OIS::Mouse*>(inputManager_->createInputObject(OIS::OISMouse, true));
1414    }
1415    catch (const OIS::Exception &e)
1416    {
1417      throw new Ogre::Exception(42, e.eText, "OrxApplication::setupInputSystem");
1418    }
1419  }
1420
1421  // FIXME we actually want to do this differently...
1422  void Orxonox::createFrameListener()
1423  {
1424    TickFrameListener* TickFL = new TickFrameListener();
1425    ogre_->getRoot()->addFrameListener(TickFL);
1426
1427    TimerFrameListener* TimerFL = new TimerFrameListener();
1428    ogre_->getRoot()->addFrameListener(TimerFL);
1429
1430    //if(mode_!=CLIENT) // FIXME just a hack ------- remove this in future
1431      frameListener_ = new OrxListener(keyboard_/*, auMan_*/, mode_);
1432    ogre_->getRoot()->addFrameListener(frameListener_);
1433  }
1434
1435  void Orxonox::startRenderLoop()
1436  {
1437    // FIXME
1438    // this is a hack!!!
1439    // the call to reset the mouse clipping size should probably be somewhere
1440    // else, however this works for the moment.
1441    unsigned int width, height, depth;
1442    int left, top;
1443    ogre_->getRoot()->getAutoCreatedWindow()->getMetrics(width, height, depth, left, top);
1444
1445    if(mode_!=CLIENT){
1446      const OIS::MouseState &ms = mouse_->getMouseState();
1447      ms.width = width;
1448      ms.height = height;
1449    }
1450    ogre_->getRoot()->startRendering();
1451  }
1452}
Note: See TracBrowser for help on using the repository browser.