Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 995 was 993, checked in by landauf, 17 years ago
  • added exit command: quits orxonox (no, it's not a hidden segfault :D)
  • added exec command: executes files (that contain other commands)

funny: use the log function to write commands into orxonox.log and then use 'exec orxonox.log' - it works. I've even added a recursion-blocker to avoid an (almost) endless loop after logging 'exec orxonox.log' ;)

I'm currently thinking about more complex commands (what about delayed commands? or commands with returnvalue and a pipeline symbol?).

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