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