Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/core2/src/orxonox/objects/test3.cc @ 1031

Last change on this file since 1031 was 1030, checked in by landauf, 18 years ago

extracted all config-value related macros from CoreIncludes.h and moved them to ConfigValueIncludes.h.

ConfigValueContainer can now handle std::vector<x> where 'x' is is any type supported by MultiTypeMath (all primitives, pointer, string, vector2, vector3, quaternion, colourvalue, radian, degree).

the vectors size is currently limited to 256 elements. this is just a practical limit, it can be raised if it's necessary. the reason for the limit is: you can add new elements to a vector by simply typing 'set classname varname index value' into the console or adding a new entry in the config-file. if 'index' is bigger than the vectors size, all elements up to 'index' are inserted. if the user accidentally enters a big number, he could end up with >4*109 elements in his config-file, resulting in 10-100gb on the hdd and a completely filled memory. and that's not exactly what i want ;)

File size: 5.2 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 *      Fabian 'x3n' Landau
23 *   Co-authors:
24 *      ...
25 *
26 */
27
28#include "test1.h"
29#include "test2.h"
30#include "test3.h"
31#include "core/CoreIncludes.h"
32#include "core/ConfigValueIncludes.h"
33
34namespace orxonox
35{
36    CreateFactory(Test3);
37
38    Test3::Test3()
39    {
40        RegisterObject(Test3);
41
42        this->setConfigValues();
43    }
44
45    void Test3::setConfigValues()
46    {
47        SetConfigValue(value_int_, 1);
48        SetConfigValue(value_uint_, 1);
49        SetConfigValue(value_char_, 1);
50        SetConfigValue(value_uchar_, 1);
51        SetConfigValue(value_float_, 1);
52        SetConfigValue(value_double_, 1);
53        SetConfigValue(value_bool_, 1);
54        SetConfigValue(value_string_, "This is a test");
55        SetConfigValue(value_constchar_, "This is another test");
56        SetConfigValue(value_vector2_, Vector2(101, 202));
57        SetConfigValue(value_vector3_, Vector3(13, 26, 39));
58        SetConfigValue(value_colourvalue_, ColourValue(1.0, 0.5, 0.25, 0.887));
59        SetConfigValueVector(vector_int_, std::vector<int>(1, 13));
60        SetConfigValueVector(vector_string_, std::vector<std::string>(3, "nothing"));
61        SetConfigValueVector(vector_vector3_, std::vector<Vector3>(1, Vector3(3, 2, 1)));
62    }
63
64    Test3::~Test3()
65    {
66    }
67
68    void Test3::configOutput()
69    {
70        std::cout << "int:             " << this->value_int_ << std::endl;
71        std::cout << "uint:            " << this->value_uint_ << std::endl;
72        std::cout << "char:            " << (int)this->value_char_ << std::endl;
73        std::cout << "uchar:           " << (int)this->value_uchar_ << std::endl;
74        std::cout << "float:           " << this->value_float_ << std::endl;
75        std::cout << "double:          " << this->value_double_ << std::endl;
76        std::cout << "bool:            " << this->value_bool_ << std::endl;
77        std::cout << "string:         >" << this->value_string_ << "<" << std::endl;
78        std::cout << "constchar:      >" << this->value_constchar_ << "<" << std::endl;
79        std::cout << "vector2:         " << this->value_vector2_ << std::endl;
80        std::cout << "vector3:         " << this->value_vector3_ << std::endl;
81        std::cout << "colourvalue:     " << this->value_colourvalue_ << std::endl;
82        std::cout << std::endl;
83        for (unsigned int i = 0; i < this->vector_int_.size(); i++)
84        std::cout << "vector<int>:     " << i << ": " << this->vector_int_[i] << std::endl;
85        for (unsigned int i = 0; i < this->vector_string_.size(); i++)
86        std::cout << "vector<string>:  " << i << ": " << this->vector_string_[i] << std::endl;
87        for (unsigned int i = 0; i < this->vector_vector3_.size(); i++)
88        std::cout << "vector<vector3>: " << i << ": " << this->vector_vector3_[i] << std::endl;
89    }
90
91    #define testandcout(code) \
92      std::cout << #code << " " << code << std::endl
93
94    void Test3::usefullClassesIsATest(Test1* test1)
95    {
96        std::cout << std::endl;
97        std::cout << "Test1:" << std::endl;
98        testandcout(test1->usefullClass1isA(Class(Test1)));
99        testandcout(test1->usefullClass1isA(Class(Test2)));
100        testandcout(test1->usefullClass1isA(Class(Test3)));
101        std::cout << std::endl;
102        testandcout(test1->usefullClass2isA(Class(Test1)));
103        testandcout(test1->usefullClass2isA(Class(Test2)));
104        testandcout(test1->usefullClass2isA(Class(Test3)));
105        std::cout << std::endl;
106        testandcout(test1->usefullClass3isA(Class(Test1)));
107        testandcout(test1->usefullClass3isA(Class(Test2)));
108        testandcout(test1->usefullClass3isA(Class(Test3)));
109    }
110
111    void Test3::usefullClassesIsATest(Test2* test2)
112    {
113        std::cout << std::endl;
114        std::cout << "Test2:" << std::endl;
115        testandcout(test2->usefullClass1isA(Class(Test1)));
116        testandcout(test2->usefullClass1isA(Class(Test2)));
117        testandcout(test2->usefullClass1isA(Class(Test3)));
118        std::cout << std::endl;
119        testandcout(test2->usefullClass2isA(Class(Test1)));
120        testandcout(test2->usefullClass2isA(Class(Test2)));
121        testandcout(test2->usefullClass2isA(Class(Test3)));
122        std::cout << std::endl;
123        testandcout(test2->usefullClass3isA(Class(Test1)));
124        testandcout(test2->usefullClass3isA(Class(Test2)));
125        testandcout(test2->usefullClass3isA(Class(Test3)));
126    }
127}
Note: See TracBrowser for help on using the repository browser.