Changeset 7401
- Timestamp:
- Sep 11, 2010, 12:34:00 AM (14 years ago)
- Location:
- code/trunk
- Files:
-
- 12 deleted
- 206 edited
- 16 copied
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
/code/branches/doc (added) merged: 7290-7292,7296-7300,7302-7304,7306-7312,7315-7318,7323,7325,7327,7331-7332,7334-7335,7345-7347,7352-7353,7356-7357,7361,7363-7367,7371-7375,7388
- Property svn:mergeinfo changed
-
code/trunk/cmake/tools/TargetUtilities.cmake
r7170 r7401 209 209 ) 210 210 ADD_MODULE(${_target_name}) 211 # Ensure that the main program depends on the module 212 SET(ORXONOX_MODULES ${ORXONOX_MODULES} ${_target_name} CACHE STRING "" FORCE) 211 213 ENDIF() 212 214 -
code/trunk/doc/api/CMakeLists.txt
r6417 r7401 46 46 #ENDIF (NOT DVIPS_CONVERTER) 47 47 48 SET(INTERNAL_DOCFILE ${CMAKE_CURRENT_BINARY_DIR}/Internal.dox) 49 IF(WIN32) 50 SET(_working_dir ${RUNTIME_LIBRARY_DIRECTORY}) 51 ELSE() 52 SET(_working_dir ${CMAKE_CURRENT_BINARY_DIR}) 53 ENDIF() 54 ADD_CUSTOM_COMMAND( 55 OUTPUT ${INTERNAL_DOCFILE} 56 COMMAND orxonox-main 57 ARGS --noIOConsole --generateDoc ${INTERNAL_DOCFILE} 58 WORKING_DIRECTORY ${_working_dir} 59 COMMENT "Generating additional Doxygen documentation from Orxonox executable" 60 ) 61 ADD_CUSTOM_TARGET(doc_internal DEPENDS ${INTERNAL_DOCFILE}) 62 IF (NOT EXISTS ${INTERNAL_DOCFILE}) 63 FILE(WRITE ${INTERNAL_DOCFILE} "// empty...") 64 ENDIF() 65 66 # Take care of most of the conditional compilation problems 67 # (Doxygen requires separate input for that) 68 IF(WIN32) 69 SET(DOXY_PLATFORM_DEF "ORXONOX_PLATFORM_WINDOWS") 70 ELSEIF(APPLE) 71 SET(DOXY_PLATFORM_DEF "ORXONOX_PLATFORM_APPLE ORXONOX_PLATFORM_UNIX") 72 ELSE() 73 SET(DOXY_PLATFORM_DEF "ORXONOX_PLATFORM_LINUX ORXONOX_PLATFORM_UNIX") 74 ENDIF() 75 IF(MSVC) 76 SET(DOXY_COMPILER_DEF "ORXONOX_COMPILER_MSVC") 77 ELSE() 78 SET(DOXY_COMPILER_DEF "ORXONOX_COMPILER_GCC") 79 ENDIF() 80 48 81 IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/doxy.config.in) 49 CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/doxy.config.in ${CMAKE_CURRENT_BINARY_DIR}/doxy.config @ONLY)50 82 # use (configured) doxy.config from (out of place) BUILD tree: 51 83 SET(DOXY_CONFIG ${CMAKE_CURRENT_BINARY_DIR}/doxy.config) 52 84 SET(DOXY_LOGFILE ${CMAKE_CURRENT_BINARY_DIR}/doxy.log) 85 CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/doxy.config.in ${CMAKE_CURRENT_BINARY_DIR}/doxy.config @ONLY) 53 86 ELSE() 54 87 MESSAGE(FATAL_ERROR "Warning: Could not find dox.config.in in the root directory.") -
code/trunk/doc/api/doxy.config.in
r6085 r7401 1 # Doxyfile 1. 4.51 # Doxyfile 1.6.3 2 2 3 3 # This file describes the settings to be used by the documentation system … … 15 15 #--------------------------------------------------------------------------- 16 16 17 # The PROJECT_NAME tag is a single word (or a sequence of words surrounded 17 # This tag specifies the encoding used for all characters in the config file 18 # that follow. The default is UTF-8 which is also the encoding used for all 19 # text before the first occurrence of this tag. Doxygen uses libiconv (or the 20 # iconv built into libc) for the transcoding. See 21 # http://www.gnu.org/software/libiconv for the list of possible encodings. 22 23 DOXYFILE_ENCODING = UTF-8 24 25 # The PROJECT_NAME tag is a single word (or a sequence of words surrounded 18 26 # by quotes) that should identify the project. 19 27 20 28 PROJECT_NAME = "@PROJECT_NAME@" 21 29 22 # The PROJECT_NUMBER tag can be used to enter a project or revision number. 23 # This could be handy for archiving the generated documentation or 30 # The PROJECT_NUMBER tag can be used to enter a project or revision number. 31 # This could be handy for archiving the generated documentation or 24 32 # if some version control system is used. 25 33 26 34 PROJECT_NUMBER = "@ORXONOX_VERSION@ Codename: @ORXONOX_VERSION_NAME@" 27 35 28 # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) 29 # base path where the generated documentation will be put. 30 # If a relative path is entered, it will be relative to the location 36 # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) 37 # base path where the generated documentation will be put. 38 # If a relative path is entered, it will be relative to the location 31 39 # where doxygen was started. If left blank the current directory will be used. 32 40 33 41 OUTPUT_DIRECTORY = @DOXY_OUTPUT_DIR@ 34 42 35 # If the CREATE_SUBDIRS tag is set to YES, then doxygen will create 36 # 4096 sub-directories (in 2 levels) under the output directory of each output 37 # format and will distribute the generated files over these directories. 38 # Enabling this option can be useful when feeding doxygen a huge amount of 39 # source files, where putting all generated files in the same directory would 43 # If the CREATE_SUBDIRS tag is set to YES, then doxygen will create 44 # 4096 sub-directories (in 2 levels) under the output directory of each output 45 # format and will distribute the generated files over these directories. 46 # Enabling this option can be useful when feeding doxygen a huge amount of 47 # source files, where putting all generated files in the same directory would 40 48 # otherwise cause performance problems for the file system. 41 49 42 50 CREATE_SUBDIRS = NO 43 51 44 # The OUTPUT_LANGUAGE tag is used to specify the language in which all 45 # documentation generated by doxygen is written. Doxygen will use this 46 # information to generate all constant output in the proper language. 47 # The default language is English, other supported languages are: 48 # Brazilian, Catalan, Chinese, Chinese-Traditional, Croatian, Czech, Danish, 49 # Dutch, Finnish, French, German, Greek, Hungarian, Italian, Japanese, 50 # Japanese-en (Japanese with English messages), Korean, Korean-en, Norwegian, 51 # Polish, Portuguese, Romanian, Russian, Serbian, Slovak, Slovene, Spanish, 52 # Swedish, and Ukrainian. 52 # The OUTPUT_LANGUAGE tag is used to specify the language in which all 53 # documentation generated by doxygen is written. Doxygen will use this 54 # information to generate all constant output in the proper language. 55 # The default language is English, other supported languages are: 56 # Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, 57 # Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, 58 # Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English 59 # messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, 60 # Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrilic, Slovak, 61 # Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. 53 62 54 63 OUTPUT_LANGUAGE = English 55 64 56 # If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will 57 # include brief member descriptions after the members that are listed in 58 # the file and class documentation (similar to JavaDoc). 65 # If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will 66 # include brief member descriptions after the members that are listed in 67 # the file and class documentation (similar to JavaDoc). 59 68 # Set to NO to disable this. 60 69 61 70 BRIEF_MEMBER_DESC = YES 62 71 63 # If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend 64 # the brief description of a member or function before the detailed description. 65 # Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the 72 # If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend 73 # the brief description of a member or function before the detailed description. 74 # Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the 66 75 # brief descriptions will be completely suppressed. 67 76 68 77 REPEAT_BRIEF = YES 69 78 70 # This tag implements a quasi-intelligent brief description abbreviator 71 # that is used to form the text in various listings. Each string 72 # in this list, if found as the leading text of the brief description, will be 73 # stripped from the text and the result after processing the whole list, is 74 # used as the annotated text. Otherwise, the brief description is used as-is. 75 # If left blank, the following values are used ("$name" is automatically 76 # replaced with the name of the entity): "The $name class" "The $name widget" 77 # "The $name file" "is" "provides" "specifies" "contains" 79 # This tag implements a quasi-intelligent brief description abbreviator 80 # that is used to form the text in various listings. Each string 81 # in this list, if found as the leading text of the brief description, will be 82 # stripped from the text and the result after processing the whole list, is 83 # used as the annotated text. Otherwise, the brief description is used as-is. 84 # If left blank, the following values are used ("$name" is automatically 85 # replaced with the name of the entity): "The $name class" "The $name widget" 86 # "The $name file" "is" "provides" "specifies" "contains" 78 87 # "represents" "a" "an" "the" 79 88 … … 90 99 the 91 100 92 # If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then 93 # Doxygen will generate a detailed section even if there is only a brief 101 # If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then 102 # Doxygen will generate a detailed section even if there is only a brief 94 103 # description. 95 104 96 105 ALWAYS_DETAILED_SEC = NO 97 106 98 # If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all 99 # inherited members of a class in the documentation of that class as if those 100 # members were ordinary class members. Constructors, destructors and assignment 107 # If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all 108 # inherited members of a class in the documentation of that class as if those 109 # members were ordinary class members. Constructors, destructors and assignment 101 110 # operators of the base classes will not be shown. 102 111 103 112 INLINE_INHERITED_MEMB = NO 104 113 105 # If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full 106 # path before files name in the file list and in the header files. If set 114 # If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full 115 # path before files name in the file list and in the header files. If set 107 116 # to NO the shortest path that makes the file name unique will be used. 108 117 109 118 FULL_PATH_NAMES = YES 110 119 111 # If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag 112 # can be used to strip a user-defined part of the path. Stripping is 113 # only done if one of the specified strings matches the left-hand part of 114 # the path. The tag can be used to show relative paths in the file list. 115 # If left blank the directory from which doxygen is run is used as the 120 # If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag 121 # can be used to strip a user-defined part of the path. Stripping is 122 # only done if one of the specified strings matches the left-hand part of 123 # the path. The tag can be used to show relative paths in the file list. 124 # If left blank the directory from which doxygen is run is used as the 116 125 # path to strip. 117 126 118 STRIP_FROM_PATH = @CMAKE_SOURCE_DIR@ 119 120 121 # The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of 122 # the path mentioned in the documentation of a class, which tells 123 # the reader which header file to include in order to use a class. 124 # If left blank only the name of the header file containing the class 125 # definition is used. Otherwise one should specify the include paths that 127 STRIP_FROM_PATH = @CMAKE_SOURCE_DIR@/src \ 128 @CMAKE_BINARY_DIR@/src 129 130 # The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of 131 # the path mentioned in the documentation of a class, which tells 132 # the reader which header file to include in order to use a class. 133 # If left blank only the name of the header file containing the class 134 # definition is used. Otherwise one should specify the include paths that 126 135 # are normally passed to the compiler using the -I flag. 127 136 128 STRIP_FROM_INC_PATH = @ CMAKE_SOURCE_DIR@129 130 # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter 131 # (but less readable) file names. This can be useful is your file systems 137 STRIP_FROM_INC_PATH = @DOXYGEN_INCLUDE_DIRECTORIES@ 138 139 # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter 140 # (but less readable) file names. This can be useful is your file systems 132 141 # doesn't support long names like on DOS, Mac, or CD-ROM. 133 142 134 143 SHORT_NAMES = NO 135 144 136 # If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen 137 # will interpret the first line (until the first dot) of a JavaDoc-style 138 # comment as the brief description. If set to NO, the JavaDoc 139 # comments will behave just like the Qt-style comments (thus requiring an140 # explicit @brief command for a brief description.145 # If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen 146 # will interpret the first line (until the first dot) of a JavaDoc-style 147 # comment as the brief description. If set to NO, the JavaDoc 148 # comments will behave just like regular Qt-style comments 149 # (thus requiring an explicit @brief command for a brief description.) 141 150 142 151 JAVADOC_AUTOBRIEF = YES 143 152 144 # The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen 145 # treat a multi-line C++ special comment block (i.e. a block of //! or /// 146 # comments) as a brief description. This used to be the default behaviour. 147 # The new default is to treat a multi-line C++ comment block as a detailed 153 # If the QT_AUTOBRIEF tag is set to YES then Doxygen will 154 # interpret the first line (until the first dot) of a Qt-style 155 # comment as the brief description. If set to NO, the comments 156 # will behave just like regular Qt-style comments (thus requiring 157 # an explicit \brief command for a brief description.) 158 159 QT_AUTOBRIEF = NO 160 161 # The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen 162 # treat a multi-line C++ special comment block (i.e. a block of //! or /// 163 # comments) as a brief description. This used to be the default behaviour. 164 # The new default is to treat a multi-line C++ comment block as a detailed 148 165 # description. Set this tag to YES if you prefer the old behaviour instead. 149 166 150 167 MULTILINE_CPP_IS_BRIEF = NO 151 168 152 # If the DETAILS_AT_TOP tag is set to YES then Doxygen 153 # will output the detailed description near the top, like JavaDoc. 154 # If set to NO, the detailed description appears after the member 169 # If the INHERIT_DOCS tag is set to YES (the default) then an undocumented 170 # member inherits the documentation from any documented member that it 171 # re-implements. 172 173 INHERIT_DOCS = YES 174 175 # If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce 176 # a new page for each member. If set to NO, the documentation of a member will 177 # be part of the file/class/namespace that contains it. 178 179 SEPARATE_MEMBER_PAGES = NO 180 181 # The TAB_SIZE tag can be used to set the number of spaces in a tab. 182 # Doxygen uses this value to replace tabs by spaces in code fragments. 183 184 TAB_SIZE = 4 185 186 # This tag can be used to specify a number of aliases that acts 187 # as commands in the documentation. An alias has the form "name=value". 188 # For example adding "sideeffect=\par Side Effects:\n" will allow you to 189 # put the command \sideeffect (or @sideeffect) in the documentation, which 190 # will result in a user-defined paragraph with heading "Side Effects:". 191 # You can put \n's in the value part of an alias to insert newlines. 192 193 ALIASES = 194 195 # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C 196 # sources only. Doxygen will then generate output that is more tailored for C. 197 # For instance, some of the names that are used will be different. The list 198 # of all members will be omitted, etc. 199 200 OPTIMIZE_OUTPUT_FOR_C = NO 201 202 # Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java 203 # sources only. Doxygen will then generate output that is more tailored for 204 # Java. For instance, namespaces will be presented as packages, qualified 205 # scopes will look different, etc. 206 207 OPTIMIZE_OUTPUT_JAVA = NO 208 209 # Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran 210 # sources only. Doxygen will then generate output that is more tailored for 211 # Fortran. 212 213 OPTIMIZE_FOR_FORTRAN = NO 214 215 # Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL 216 # sources. Doxygen will then generate output that is tailored for 217 # VHDL. 218 219 OPTIMIZE_OUTPUT_VHDL = NO 220 221 # Doxygen selects the parser to use depending on the extension of the files it parses. 222 # With this tag you can assign which parser to use for a given extension. 223 # Doxygen has a built-in mapping, but you can override or extend it using this tag. 224 # The format is ext=language, where ext is a file extension, and language is one of 225 # the parsers supported by doxygen: IDL, Java, Javascript, C#, C, C++, D, PHP, 226 # Objective-C, Python, Fortran, VHDL, C, C++. For instance to make doxygen treat 227 # .inc files as Fortran files (default is PHP), and .f files as C (default is Fortran), 228 # use: inc=Fortran f=C. Note that for custom extensions you also need to set FILE_PATTERNS otherwise the files are not read by doxygen. 229 230 EXTENSION_MAPPING = 231 232 # If you use STL classes (i.e. std::string, std::vector, etc.) but do not want 233 # to include (a tag file for) the STL sources as input, then you should 234 # set this tag to YES in order to let doxygen match functions declarations and 235 # definitions whose arguments contain STL classes (e.g. func(std::string); v.s. 236 # func(std::string) {}). This also make the inheritance and collaboration 237 # diagrams that involve STL classes more complete and accurate. 238 239 BUILTIN_STL_SUPPORT = YES 240 241 # If you use Microsoft's C++/CLI language, you should set this option to YES to 242 # enable parsing support. 243 244 CPP_CLI_SUPPORT = NO 245 246 # Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. 247 # Doxygen will parse them like normal C++ but will assume all classes use public 248 # instead of private inheritance when no explicit protection keyword is present. 249 250 SIP_SUPPORT = NO 251 252 # For Microsoft's IDL there are propget and propput attributes to indicate getter 253 # and setter methods for a property. Setting this option to YES (the default) 254 # will make doxygen to replace the get and set methods by a property in the 255 # documentation. This will only work if the methods are indeed getting or 256 # setting a simple type. If this is not the case, or you want to show the 257 # methods anyway, you should set this option to NO. 258 259 IDL_PROPERTY_SUPPORT = YES 260 261 # If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC 262 # tag is set to YES, then doxygen will reuse the documentation of the first 263 # member in the group (if any) for the other members of the group. By default 264 # all members of a group must be documented explicitly. 265 266 DISTRIBUTE_GROUP_DOC = NO 267 268 # Set the SUBGROUPING tag to YES (the default) to allow class member groups of 269 # the same type (for instance a group of public functions) to be put as a 270 # subgroup of that type (e.g. under the Public Functions section). Set it to 271 # NO to prevent subgrouping. Alternatively, this can be done per class using 272 # the \nosubgrouping command. 273 274 SUBGROUPING = YES 275 276 # When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum 277 # is documented as struct, union, or enum with the name of the typedef. So 278 # typedef struct TypeS {} TypeT, will appear in the documentation as a struct 279 # with name TypeT. When disabled the typedef will appear as a member of a file, 280 # namespace, or class. And the struct will be named TypeS. This can typically 281 # be useful for C code in case the coding convention dictates that all compound 282 # types are typedef'ed and only the typedef is referenced, never the tag name. 283 284 TYPEDEF_HIDES_STRUCT = NO 285 286 # The SYMBOL_CACHE_SIZE determines the size of the internal cache use to 287 # determine which symbols to keep in memory and which to flush to disk. 288 # When the cache is full, less often used symbols will be written to disk. 289 # For small to medium size projects (<1000 input files) the default value is 290 # probably good enough. For larger projects a too small cache size can cause 291 # doxygen to be busy swapping symbols to and from disk most of the time 292 # causing a significant performance penality. 293 # If the system has enough physical memory increasing the cache will improve the 294 # performance by keeping more symbols in memory. Note that the value works on 295 # a logarithmic scale so increasing the size by one will rougly double the 296 # memory usage. The cache size is given by this formula: 297 # 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, 298 # corresponding to a cache size of 2^16 = 65536 symbols 299 300 SYMBOL_CACHE_SIZE = 0 301 302 #--------------------------------------------------------------------------- 303 # Build related configuration options 304 #--------------------------------------------------------------------------- 305 306 # If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in 307 # documentation are documented, even if no documentation was available. 308 # Private class members and static file members will be hidden unless 309 # the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES 310 311 EXTRACT_ALL = YES 312 313 # If the EXTRACT_PRIVATE tag is set to YES all private members of a class 314 # will be included in the documentation. 315 316 EXTRACT_PRIVATE = YES 317 318 # If the EXTRACT_STATIC tag is set to YES all static members of a file 319 # will be included in the documentation. 320 321 EXTRACT_STATIC = YES 322 323 # If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) 324 # defined locally in source files will be included in the documentation. 325 # If set to NO only classes defined in header files are included. 326 327 EXTRACT_LOCAL_CLASSES = YES 328 329 # This flag is only useful for Objective-C code. When set to YES local 330 # methods, which are defined in the implementation section but not in 331 # the interface are included in the documentation. 332 # If set to NO (the default) only methods in the interface are included. 333 334 EXTRACT_LOCAL_METHODS = NO 335 336 # If this flag is set to YES, the members of anonymous namespaces will be 337 # extracted and appear in the documentation as a namespace called 338 # 'anonymous_namespace{file}', where file will be replaced with the base 339 # name of the file that contains the anonymous namespace. By default 340 # anonymous namespace are hidden. 341 342 EXTRACT_ANON_NSPACES = NO 343 344 # If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all 345 # undocumented members of documented classes, files or namespaces. 346 # If set to NO (the default) these members will be included in the 347 # various overviews, but no documentation section is generated. 348 # This option has no effect if EXTRACT_ALL is enabled. 349 350 HIDE_UNDOC_MEMBERS = NO 351 352 # If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all 353 # undocumented classes that are normally visible in the class hierarchy. 354 # If set to NO (the default) these classes will be included in the various 355 # overviews. This option has no effect if EXTRACT_ALL is enabled. 356 357 HIDE_UNDOC_CLASSES = NO 358 359 # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all 360 # friend (class|struct|union) declarations. 361 # If set to NO (the default) these declarations will be included in the 155 362 # documentation. 156 363 157 DETAILS_AT_TOP = NO 158 159 # If the INHERIT_DOCS tag is set to YES (the default) then an undocumented 160 # member inherits the documentation from any documented member that it 161 # re-implements. 162 163 INHERIT_DOCS = YES 164 165 # If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce 166 # a new page for each member. If set to NO, the documentation of a member will 167 # be part of the file/class/namespace that contains it. 168 169 SEPARATE_MEMBER_PAGES = NO 170 171 # The TAB_SIZE tag can be used to set the number of spaces in a tab. 172 # Doxygen uses this value to replace tabs by spaces in code fragments. 173 174 TAB_SIZE = 4 175 176 # This tag can be used to specify a number of aliases that acts 177 # as commands in the documentation. An alias has the form "name=value". 178 # For example adding "sideeffect=\par Side Effects:\n" will allow you to 179 # put the command \sideeffect (or @sideeffect) in the documentation, which 180 # will result in a user-defined paragraph with heading "Side Effects:". 181 # You can put \n's in the value part of an alias to insert newlines. 182 183 ALIASES = 184 185 # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C 186 # sources only. Doxygen will then generate output that is more tailored for C. 187 # For instance, some of the names that are used will be different. The list 188 # of all members will be omitted, etc. 189 190 OPTIMIZE_OUTPUT_FOR_C = NO 191 192 # Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java 193 # sources only. Doxygen will then generate output that is more tailored for Java. 194 # For instance, namespaces will be presented as packages, qualified scopes 195 # will look different, etc. 196 197 OPTIMIZE_OUTPUT_JAVA = NO 198 199 # If you use STL classes (i.e. std::string, std::vector, etc.) but do not want to 200 # include (a tag file for) the STL sources as input, then you should 201 # set this tag to YES in order to let doxygen match functions declarations and 202 # definitions whose arguments contain STL classes (e.g. func(std::string); v.s. 203 # func(std::string) {}). This also make the inheritance and collaboration 204 # diagrams that involve STL classes more complete and accurate. 205 206 BUILTIN_STL_SUPPORT = NO 207 208 # If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC 209 # tag is set to YES, then doxygen will reuse the documentation of the first 210 # member in the group (if any) for the other members of the group. By default 211 # all members of a group must be documented explicitly. 212 213 DISTRIBUTE_GROUP_DOC = NO 214 215 # Set the SUBGROUPING tag to YES (the default) to allow class member groups of 216 # the same type (for instance a group of public functions) to be put as a 217 # subgroup of that type (e.g. under the Public Functions section). Set it to 218 # NO to prevent subgrouping. Alternatively, this can be done per class using 219 # the \nosubgrouping command. 220 221 SUBGROUPING = YES 222 223 #--------------------------------------------------------------------------- 224 # Build related configuration options 225 #--------------------------------------------------------------------------- 226 227 # If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in 228 # documentation are documented, even if no documentation was available. 229 # Private class members and static file members will be hidden unless 230 # the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES 231 232 EXTRACT_ALL = YES 233 234 # If the EXTRACT_PRIVATE tag is set to YES all private members of a class 235 # will be included in the documentation. 236 237 EXTRACT_PRIVATE = YES 238 239 # If the EXTRACT_STATIC tag is set to YES all static members of a file 240 # will be included in the documentation. 241 242 EXTRACT_STATIC = YES 243 244 # If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) 245 # defined locally in source files will be included in the documentation. 246 # If set to NO only classes defined in header files are included. 247 248 EXTRACT_LOCAL_CLASSES = YES 249 250 # This flag is only useful for Objective-C code. When set to YES local 251 # methods, which are defined in the implementation section but not in 252 # the interface are included in the documentation. 253 # If set to NO (the default) only methods in the interface are included. 254 255 EXTRACT_LOCAL_METHODS = NO 256 257 # If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all 258 # undocumented members of documented classes, files or namespaces. 259 # If set to NO (the default) these members will be included in the 260 # various overviews, but no documentation section is generated. 261 # This option has no effect if EXTRACT_ALL is enabled. 262 263 HIDE_UNDOC_MEMBERS = NO 264 265 # If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all 266 # undocumented classes that are normally visible in the class hierarchy. 267 # If set to NO (the default) these classes will be included in the various 268 # overviews. This option has no effect if EXTRACT_ALL is enabled. 269 270 HIDE_UNDOC_CLASSES = NO 271 272 # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all 273 # friend (class|struct|union) declarations. 274 # If set to NO (the default) these declarations will be included in the 364 HIDE_FRIEND_COMPOUNDS = NO 365 366 # If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any 367 # documentation blocks found inside the body of a function. 368 # If set to NO (the default) these blocks will be appended to the 369 # function's detailed documentation block. 370 371 HIDE_IN_BODY_DOCS = NO 372 373 # The INTERNAL_DOCS tag determines if documentation 374 # that is typed after a \internal command is included. If the tag is set 375 # to NO (the default) then the documentation will be excluded. 376 # Set it to YES to include the internal documentation. 377 378 INTERNAL_DOCS = NO 379 380 # If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate 381 # file names in lower-case letters. If set to YES upper-case letters are also 382 # allowed. This is useful if you have classes or files whose names only differ 383 # in case and if your file system supports case sensitive file names. Windows 384 # and Mac users are advised to set this option to NO. 385 386 CASE_SENSE_NAMES = NO 387 388 # If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen 389 # will show members with their full class and namespace scopes in the 390 # documentation. If set to YES the scope will be hidden. 391 392 HIDE_SCOPE_NAMES = NO 393 394 # If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen 395 # will put a list of the files that are included by a file in the documentation 396 # of that file. 397 398 SHOW_INCLUDE_FILES = YES 399 400 # If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen 401 # will list include files with double quotes in the documentation 402 # rather than with sharp brackets. 403 404 FORCE_LOCAL_INCLUDES = NO 405 406 # If the INLINE_INFO tag is set to YES (the default) then a tag [inline] 407 # is inserted in the documentation for inline members. 408 409 INLINE_INFO = YES 410 411 # If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen 412 # will sort the (detailed) documentation of file and class members 413 # alphabetically by member name. If set to NO the members will appear in 414 # declaration order. 415 416 SORT_MEMBER_DOCS = YES 417 418 # If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the 419 # brief documentation of file, namespace and class members alphabetically 420 # by member name. If set to NO (the default) the members will appear in 421 # declaration order. 422 423 SORT_BRIEF_DOCS = YES 424 425 # If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the (brief and detailed) documentation of class members so that constructors and destructors are listed first. If set to NO (the default) the constructors will appear in the respective orders defined by SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. 426 427 SORT_MEMBERS_CTORS_1ST = YES 428 429 # If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the 430 # hierarchy of group names into alphabetical order. If set to NO (the default) 431 # the group names will appear in their defined order. 432 433 SORT_GROUP_NAMES = NO 434 435 # If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be 436 # sorted by fully-qualified names, including namespaces. If set to 437 # NO (the default), the class list will be sorted only by class name, 438 # not including the namespace part. 439 # Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. 440 # Note: This option applies only to the class list, not to the 441 # alphabetical list. 442 443 SORT_BY_SCOPE_NAME = YES 444 445 # The GENERATE_TODOLIST tag can be used to enable (YES) or 446 # disable (NO) the todo list. This list is created by putting \todo 447 # commands in the documentation. 448 449 GENERATE_TODOLIST = YES 450 451 # The GENERATE_TESTLIST tag can be used to enable (YES) or 452 # disable (NO) the test list. This list is created by putting \test 453 # commands in the documentation. 454 455 GENERATE_TESTLIST = YES 456 457 # The GENERATE_BUGLIST tag can be used to enable (YES) or 458 # disable (NO) the bug list. This list is created by putting \bug 459 # commands in the documentation. 460 461 GENERATE_BUGLIST = YES 462 463 # The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or 464 # disable (NO) the deprecated list. This list is created by putting 465 # \deprecated commands in the documentation. 466 467 GENERATE_DEPRECATEDLIST= YES 468 469 # The ENABLED_SECTIONS tag can be used to enable conditional 470 # documentation sections, marked by \if sectionname ... \endif. 471 472 ENABLED_SECTIONS = 473 474 # The MAX_INITIALIZER_LINES tag determines the maximum number of lines 475 # the initial value of a variable or define consists of for it to appear in 476 # the documentation. If the initializer consists of more lines than specified 477 # here it will be hidden. Use a value of 0 to hide initializers completely. 478 # The appearance of the initializer of individual variables and defines in the 479 # documentation can be controlled using \showinitializer or \hideinitializer 480 # command in the documentation regardless of this setting. 481 482 MAX_INITIALIZER_LINES = 30 483 484 # Set the SHOW_USED_FILES tag to NO to disable the list of files generated 485 # at the bottom of the documentation of classes and structs. If set to YES the 486 # list will mention the files that were used to generate the documentation. 487 488 SHOW_USED_FILES = YES 489 490 # If the sources in your project are distributed over multiple directories 491 # then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy 492 # in the documentation. The default is NO. 493 494 SHOW_DIRECTORIES = YES 495 496 # Set the SHOW_FILES tag to NO to disable the generation of the Files page. 497 # This will remove the Files entry from the Quick Index and from the 498 # Folder Tree View (if specified). The default is YES. 499 500 SHOW_FILES = YES 501 502 # Set the SHOW_NAMESPACES tag to NO to disable the generation of the 503 # Namespaces page. 504 # This will remove the Namespaces entry from the Quick Index 505 # and from the Folder Tree View (if specified). The default is YES. 506 507 SHOW_NAMESPACES = YES 508 509 # The FILE_VERSION_FILTER tag can be used to specify a program or script that 510 # doxygen should invoke to get the current version for each file (typically from 511 # the version control system). Doxygen will invoke the program by executing (via 512 # popen()) the command <command> <input-file>, where <command> is the value of 513 # the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file 514 # provided by doxygen. Whatever the program writes to standard output 515 # is used as the file version. See the manual for examples. 516 517 FILE_VERSION_FILTER = 518 519 # The LAYOUT_FILE tag can be used to specify a layout file which will be parsed by 520 # doxygen. The layout file controls the global structure of the generated output files 521 # in an output format independent way. The create the layout file that represents 522 # doxygen's defaults, run doxygen with the -l option. You can optionally specify a 523 # file name after the option, if omitted DoxygenLayout.xml will be used as the name 524 # of the layout file. 525 526 LAYOUT_FILE = 527 528 #--------------------------------------------------------------------------- 529 # configuration options related to warning and progress messages 530 #--------------------------------------------------------------------------- 531 532 # The QUIET tag can be used to turn on/off the messages that are generated 533 # by doxygen. Possible values are YES and NO. If left blank NO is used. 534 535 QUIET = NO 536 537 # The WARNINGS tag can be used to turn on/off the warning messages that are 538 # generated by doxygen. Possible values are YES and NO. If left blank 539 # NO is used. 540 541 WARNINGS = YES 542 543 # If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings 544 # for undocumented members. If EXTRACT_ALL is set to YES then this flag will 545 # automatically be disabled. 546 547 WARN_IF_UNDOCUMENTED = YES 548 549 # If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for 550 # potential errors in the documentation, such as not documenting some 551 # parameters in a documented function, or documenting parameters that 552 # don't exist or using markup commands wrongly. 553 554 WARN_IF_DOC_ERROR = YES 555 556 # This WARN_NO_PARAMDOC option can be abled to get warnings for 557 # functions that are documented, but have no documentation for their parameters 558 # or return value. If set to NO (the default) doxygen will only warn about 559 # wrong or incomplete parameter documentation, but not about the absence of 275 560 # documentation. 276 561 277 HIDE_FRIEND_COMPOUNDS = NO278 279 # If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any280 # documentation blocks found inside the body of a function.281 # If set to NO (the default) these blocks will be appended to the282 # function's detailed documentation block.283 284 HIDE_IN_BODY_DOCS = NO285 286 # The INTERNAL_DOCS tag determines if documentation287 # that is typed after a \internal command is included. If the tag is set288 # to NO (the default) then the documentation will be excluded.289 # Set it to YES to include the internal documentation.290 291 INTERNAL_DOCS = NO292 293 # If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate294 # file names in lower-case letters. If set to YES upper-case letters are also295 # allowed. This is useful if you have classes or files whose names only differ296 # in case and if your file system supports case sensitive file names. Windows297 # and Mac users are advised to set this option to NO.298 299 CASE_SENSE_NAMES = YES300 301 # If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen302 # will show members with their full class and namespace scopes in the303 # documentation. If set to YES the scope will be hidden.304 305 HIDE_SCOPE_NAMES = NO306 307 # If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen308 # will put a list of the files that are included by a file in the documentation309 # of that file.310 311 SHOW_INCLUDE_FILES = YES312 313 # If the INLINE_INFO tag is set to YES (the default) then a tag [inline]314 # is inserted in the documentation for inline members.315 316 INLINE_INFO = YES317 318 # If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen319 # will sort the (detailed) documentation of file and class members320 # alphabetically by member name. If set to NO the members will appear in321 # declaration order.322 323 SORT_MEMBER_DOCS = YES324 325 # If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the326 # brief documentation of file, namespace and class members alphabetically327 # by member name. If set to NO (the default) the members will appear in328 # declaration order.329 330 SORT_BRIEF_DOCS = YES331 332 # If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be333 # sorted by fully-qualified names, including namespaces. If set to334 # NO (the default), the class list will be sorted only by class name,335 # not including the namespace part.336 # Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.337 # Note: This option applies only to the class list, not to the338 # alphabetical list.339 340 SORT_BY_SCOPE_NAME = NO341 342 # The GENERATE_TODOLIST tag can be used to enable (YES) or343 # disable (NO) the todo list. This list is created by putting \todo344 # commands in the documentation.345 346 GENERATE_TODOLIST = YES347 348 # The GENERATE_TESTLIST tag can be used to enable (YES) or349 # disable (NO) the test list. This list is created by putting \test350 # commands in the documentation.351 352 GENERATE_TESTLIST = YES353 354 # The GENERATE_BUGLIST tag can be used to enable (YES) or355 # disable (NO) the bug list. This list is created by putting \bug356 # commands in the documentation.357 358 GENERATE_BUGLIST = YES359 360 # The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or361 # disable (NO) the deprecated list. This list is created by putting362 # \deprecated commands in the documentation.363 364 GENERATE_DEPRECATEDLIST= YES365 366 # The ENABLED_SECTIONS tag can be used to enable conditional367 # documentation sections, marked by \if sectionname ... \endif.368 369 ENABLED_SECTIONS = YES370 371 # The MAX_INITIALIZER_LINES tag determines the maximum number of lines372 # the initial value of a variable or define consists of for it to appear in373 # the documentation. If the initializer consists of more lines than specified374 # here it will be hidden. Use a value of 0 to hide initializers completely.375 # The appearance of the initializer of individual variables and defines in the376 # documentation can be controlled using \showinitializer or \hideinitializer377 # command in the documentation regardless of this setting.378 379 MAX_INITIALIZER_LINES = 30380 381 # Set the SHOW_USED_FILES tag to NO to disable the list of files generated382 # at the bottom of the documentation of classes and structs. If set to YES the383 # list will mention the files that were used to generate the documentation.384 385 SHOW_USED_FILES = YES386 387 # If the sources in your project are distributed over multiple directories388 # then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy389 # in the documentation. The default is YES.390 391 SHOW_DIRECTORIES = YES392 393 # Set the SHOW_FILES tag to NO to disable the generation of the Files page.394 # This will remove the Files entry from the Quick Index and from the Folder395 # Tree View (if specified). The default is YES.396 397 SHOW_FILES = YES398 399 # Set the SHOW_NAMESPACES tag to NO to disable the generation of the400 # Namespaces page. This will remove the Namespaces entry from the Quick Index401 # and from the Folder Tree View (if specified). The default is YES.402 403 SHOW_NAMESPACES = YES404 405 # The FILE_VERSION_FILTER tag can be used to specify a program or script that406 # doxygen should invoke to get the current version for each file (typically from the407 # version control system). Doxygen will invoke the program by executing (via408 # popen()) the command <command> <input-file>, where <command> is the value of409 # the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file410 # provided by doxygen. Whatever the program writes to standard output411 # is used as the file version. See the manual for examples.412 413 FILE_VERSION_FILTER =414 415 #---------------------------------------------------------------------------416 # configuration options related to warning and progress messages417 #---------------------------------------------------------------------------418 419 # The QUIET tag can be used to turn on/off the messages that are generated420 # by doxygen. Possible values are YES and NO. If left blank NO is used.421 422 QUIET = NO423 424 # The WARNINGS tag can be used to turn on/off the warning messages that are425 # generated by doxygen. Possible values are YES and NO. If left blank426 # NO is used.427 428 WARNINGS = YES429 430 # If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings431 # for undocumented members. If EXTRACT_ALL is set to YES then this flag will432 # automatically be disabled.433 434 WARN_IF_UNDOCUMENTED = YES435 436 # If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for437 # potential errors in the documentation, such as not documenting some438 # parameters in a documented function, or documenting parameters that439 # don't exist or using markup commands wrongly.440 441 WARN_IF_DOC_ERROR = YES442 443 # This WARN_NO_PARAMDOC option can be abled to get warnings for444 # functions that are documented, but have no documentation for their parameters445 # or return value. If set to NO (the default) doxygen will only warn about446 # wrong or incomplete parameter documentation, but not about the absence of447 # documentation.448 449 562 WARN_NO_PARAMDOC = NO 450 563 451 # The WARN_FORMAT tag determines the format of the warning messages that 452 # doxygen can produce. The string should contain the $file, $line, and $text 453 # tags, which will be replaced by the file and line number from which the 454 # warning originated and the warning text. Optionally the format may contain 455 # $version, which will be replaced by the version of the file (if it could 564 # The WARN_FORMAT tag determines the format of the warning messages that 565 # doxygen can produce. The string should contain the $file, $line, and $text 566 # tags, which will be replaced by the file and line number from which the 567 # warning originated and the warning text. Optionally the format may contain 568 # $version, which will be replaced by the version of the file (if it could 456 569 # be obtained via FILE_VERSION_FILTER) 457 570 458 571 WARN_FORMAT = @DOXY_WARN_FORMAT@ 459 572 460 # The WARN_LOGFILE tag can be used to specify a file to which warning 461 # and error messages should be written. If left blank the output is written 573 # The WARN_LOGFILE tag can be used to specify a file to which warning 574 # and error messages should be written. If left blank the output is written 462 575 # to stderr. 463 576 … … 468 581 #--------------------------------------------------------------------------- 469 582 470 # The INPUT tag can be used to specify the files and/or directories that contain 471 # documented source files. You may enter file names like "myfile.cpp" or 472 # directories like "/usr/src/myproject". Separate the files or directories 583 # The INPUT tag can be used to specify the files and/or directories that contain 584 # documented source files. You may enter file names like "myfile.cpp" or 585 # directories like "/usr/src/myproject". Separate the files or directories 473 586 # with spaces. 474 587 … … 476 589 @CMAKE_CURRENT_SOURCE_DIR@ \ 477 590 @CMAKE_BINARY_DIR@/src/OrxonoxConfig.h \ 478 @CMAKE_BINARY_DIR@/src/SpecialConfig.h 479 480 # If the value of the INPUT tag contains directories, you can use the 481 # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp 482 # and *.h) to filter out the source-files in the directories. If left 483 # blank the following patterns are tested: 484 # *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx 485 # *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py 591 @CMAKE_BINARY_DIR@/src/SpecialConfig.h \ 592 @INTERNAL_DOCFILE@ 593 594 # This tag can be used to specify the character encoding of the source files 595 # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is 596 # also the default input encoding. Doxygen uses libiconv (or the iconv built 597 # into libc) for the transcoding. See http://www.gnu.org/software/libiconv for 598 # the list of possible encodings. 599 600 INPUT_ENCODING = UTF-8 601 602 # If the value of the INPUT tag contains directories, you can use the 603 # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp 604 # and *.h) to filter out the source-files in the directories. If left 605 # blank the following patterns are tested: 606 # *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx 607 # *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90 486 608 487 609 FILE_PATTERNS = *.cpp \ … … 492 614 *.dox 493 615 494 # The RECURSIVE tag can be used to turn specify whether or not subdirectories 495 # should be searched for input files as well. Possible values are YES and NO. 616 # The RECURSIVE tag can be used to turn specify whether or not subdirectories 617 # should be searched for input files as well. Possible values are YES and NO. 496 618 # If left blank NO is used. 497 619 498 620 RECURSIVE = YES 499 621 500 # The EXCLUDE tag can be used to specify files and/or directories that should 501 # excluded from the INPUT source files. This way you can easily exclude a 622 # The EXCLUDE tag can be used to specify files and/or directories that should 623 # excluded from the INPUT source files. This way you can easily exclude a 502 624 # subdirectory from a directory tree whose root is specified with the INPUT tag. 503 625 504 EXCLUDE = @CMAKE_SOURCE_DIR@/src/external/bullet/ 505 506 # The EXCLUDE_SYMLINKS tag can be used select whether or not files or 507 # directories that are symbolic links (a Unix filesystem feature) are excluded 626 EXCLUDE = @CMAKE_SOURCE_DIR@/src/external/bullet/ \ 627 @CMAKE_SOURCE_DIR@/src/external/cpptcl/ \ 628 @CMAKE_SOURCE_DIR@/src/external/ceguilua/ceguilua-0.5.0 \ 629 @CMAKE_SOURCE_DIR@/src/external/ceguilua/ceguilua-0.6.0 \ 630 @CMAKE_SOURCE_DIR@/src/external/ceguilua/ceguilua-0.6.1 \ 631 @CMAKE_SOURCE_DIR@/src/libraries/core/command/IOConsoleWindows.h \ 632 @CMAKE_SOURCE_DIR@/src/libraries/core/command/IOConsoleWindows.cc \ 633 @CMAKE_SOURCE_DIR@/src/libraries/tools/bsp \ 634 635 # The EXCLUDE_SYMLINKS tag can be used select whether or not files or 636 # directories that are symbolic links (a Unix filesystem feature) are excluded 508 637 # from the input. 509 638 510 639 EXCLUDE_SYMLINKS = NO 511 640 512 # If the value of the INPUT tag contains directories, you can use the 513 # EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude 514 # certain files from those directories. Note that the wildcards are matched 515 # against the file with absolute path, so to exclude all test directories 641 # If the value of the INPUT tag contains directories, you can use the 642 # EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude 643 # certain files from those directories. Note that the wildcards are matched 644 # against the file with absolute path, so to exclude all test directories 516 645 # for example use the pattern */test/* 517 646 518 647 EXCLUDE_PATTERNS = */.svn/* 519 648 520 # The EXAMPLE_PATH tag can be used to specify one or more files or 521 # directories that contain example code fragments that are included (see 649 # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names 650 # (namespaces, classes, functions, etc.) that should be excluded from the 651 # output. The symbol name can be a fully qualified name, a word, or if the 652 # wildcard * is used, a substring. Examples: ANamespace, AClass, 653 # AClass::ANamespace, ANamespace::*Test 654 655 EXCLUDE_SYMBOLS = orxonox::detail 656 657 # The EXAMPLE_PATH tag can be used to specify one or more files or 658 # directories that contain example code fragments that are included (see 522 659 # the \include command). 523 660 524 661 EXAMPLE_PATH = @CMAKE_CURRENT_SOURCE_DIR@/examples/ 525 662 526 # If the value of the EXAMPLE_PATH tag contains directories, you can use the 527 # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp 528 # and *.h) to filter out the source-files in the directories. If left 663 # If the value of the EXAMPLE_PATH tag contains directories, you can use the 664 # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp 665 # and *.h) to filter out the source-files in the directories. If left 529 666 # blank all files are included. 530 667 … … 535 672 INSTALL DEPENDENCIES CHANGELOG LICENSE LGPL 536 673 537 # If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be 538 # searched for input files to be used with the \include or \dontinclude 539 # commands irrespective of the value of the RECURSIVE tag. 674 # If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be 675 # searched for input files to be used with the \include or \dontinclude 676 # commands irrespective of the value of the RECURSIVE tag. 540 677 # Possible values are YES and NO. If left blank NO is used. 541 678 542 679 EXAMPLE_RECURSIVE = YES 543 680 544 # The IMAGE_PATH tag can be used to specify one or more files or 545 # directories that contain image that are included in the documentation (see 681 # The IMAGE_PATH tag can be used to specify one or more files or 682 # directories that contain image that are included in the documentation (see 546 683 # the \image command). 547 684 548 685 IMAGE_PATH = @CMAKE_CURRENT_SOURCE_DIR@/images/ 549 686 550 551 # The INPUT_FILTER tag can be used to specify a program that doxygen should552 # invoke to filter for each input file. Doxygen will invoke the filter program553 # by executing (via popen()) the command <filter> <input-file>, where <filter>554 # i s the value of the INPUT_FILTER tag, and <input-file> is the name of an555 # input file. Doxygen will then use the output that the filter program writes556 # to standard output. If FILTER_PATTERNS is specified, this tag will be687 # The INPUT_FILTER tag can be used to specify a program that doxygen should 688 # invoke to filter for each input file. Doxygen will invoke the filter program 689 # by executing (via popen()) the command <filter> <input-file>, where <filter> 690 # is the value of the INPUT_FILTER tag, and <input-file> is the name of an 691 # input file. Doxygen will then use the output that the filter program writes 692 # to standard output. 693 # If FILTER_PATTERNS is specified, this tag will be 557 694 # ignored. 558 695 559 INPUT_FILTER = 560 561 # The FILTER_PATTERNS tag can be used to specify filters on a per file pattern 562 # basis. Doxygen will compare the file name with each pattern and apply the 563 # filter if there is a match. The filters are a list of the form: 564 # pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further 565 # info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER 696 INPUT_FILTER = 697 698 # The FILTER_PATTERNS tag can be used to specify filters on a per file pattern 699 # basis. 700 # Doxygen will compare the file name with each pattern and apply the 701 # filter if there is a match. 702 # The filters are a list of the form: 703 # pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further 704 # info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER 566 705 # is applied to all files. 567 706 568 FILTER_PATTERNS = 569 570 # If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using 571 # INPUT_FILTER) will be used to filter the input files when producing source 707 FILTER_PATTERNS = 708 709 # If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using 710 # INPUT_FILTER) will be used to filter the input files when producing source 572 711 # files to browse (i.e. when SOURCE_BROWSER is set to YES). 573 712 … … 578 717 #--------------------------------------------------------------------------- 579 718 580 # If the SOURCE_BROWSER tag is set to YES then a list of source files will 581 # be generated. Documented entities will be cross-referenced with these sources. 582 # Note: To get rid of all source code in the generated output, make sure also 719 # If the SOURCE_BROWSER tag is set to YES then a list of source files will 720 # be generated. Documented entities will be cross-referenced with these sources. 721 # Note: To get rid of all source code in the generated output, make sure also 583 722 # VERBATIM_HEADERS is set to NO. 584 723 585 724 SOURCE_BROWSER = NO 586 725 587 # Setting the INLINE_SOURCES tag to YES will include the body 726 # Setting the INLINE_SOURCES tag to YES will include the body 588 727 # of functions and classes directly in the documentation. 589 728 590 729 INLINE_SOURCES = NO 591 730 592 # Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct 593 # doxygen to hide any special comment blocks from generated source code 731 # Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct 732 # doxygen to hide any special comment blocks from generated source code 594 733 # fragments. Normal C and C++ comments will always remain visible. 595 734 596 735 STRIP_CODE_COMMENTS = YES 597 736 598 # If the REFERENCED_BY_RELATION tag is set to YES (the default)599 # then for each documented function all documented 737 # If the REFERENCED_BY_RELATION tag is set to YES 738 # then for each documented function all documented 600 739 # functions referencing it will be listed. 601 740 602 REFERENCED_BY_RELATION = YES603 604 # If the REFERENCES_RELATION tag is set to YES (the default)605 # then for each documented function all documented entities 741 REFERENCED_BY_RELATION = NO 742 743 # If the REFERENCES_RELATION tag is set to YES 744 # then for each documented function all documented entities 606 745 # called/used by that function will be listed. 607 746 608 REFERENCES_RELATION = YES 609 610 # If the USE_HTAGS tag is set to YES then the references to source code 611 # will point to the HTML generated by the htags(1) tool instead of doxygen 612 # built-in source browser. The htags tool is part of GNU's global source 613 # tagging system (see http://www.gnu.org/software/global/global.html). You 747 REFERENCES_RELATION = NO 748 749 # If the REFERENCES_LINK_SOURCE tag is set to YES (the default) 750 # and SOURCE_BROWSER tag is set to YES, then the hyperlinks from 751 # functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will 752 # link to the source code. 753 # Otherwise they will link to the documentation. 754 755 REFERENCES_LINK_SOURCE = YES 756 757 # If the USE_HTAGS tag is set to YES then the references to source code 758 # will point to the HTML generated by the htags(1) tool instead of doxygen 759 # built-in source browser. The htags tool is part of GNU's global source 760 # tagging system (see http://www.gnu.org/software/global/global.html). You 614 761 # will need version 4.8.6 or higher. 615 762 616 763 USE_HTAGS = NO 617 764 618 # If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen 619 # will generate a verbatim copy of the header file for each class for 765 # If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen 766 # will generate a verbatim copy of the header file for each class for 620 767 # which an include is specified. Set to NO to disable this. 621 768 … … 626 773 #--------------------------------------------------------------------------- 627 774 628 # If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index 629 # of all compounds will be generated. Enable this if the project 775 # If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index 776 # of all compounds will be generated. Enable this if the project 630 777 # contains a lot of classes, structs, unions or interfaces. 631 778 632 779 ALPHABETICAL_INDEX = YES 633 780 634 # If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then 635 # the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns 781 # If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then 782 # the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns 636 783 # in which this list will be split (can be a number in the range [1..20]) 637 784 638 785 COLS_IN_ALPHA_INDEX = 2 639 786 640 # In case all classes in a project start with a common prefix, all 641 # classes will be put under the same header in the alphabetical index. 642 # The IGNORE_PREFIX tag can be used to specify one or more prefixes that 787 # In case all classes in a project start with a common prefix, all 788 # classes will be put under the same header in the alphabetical index. 789 # The IGNORE_PREFIX tag can be used to specify one or more prefixes that 643 790 # should be ignored while generating the index headers. 644 791 645 IGNORE_PREFIX = 792 IGNORE_PREFIX = 646 793 647 794 #--------------------------------------------------------------------------- … … 649 796 #--------------------------------------------------------------------------- 650 797 651 # If the GENERATE_HTML tag is set to YES (the default) Doxygen will 798 # If the GENERATE_HTML tag is set to YES (the default) Doxygen will 652 799 # generate HTML output. 653 800 654 801 GENERATE_HTML = YES 655 802 656 # The HTML_OUTPUT tag is used to specify where the HTML docs will be put. 657 # If a relative path is entered the value of OUTPUT_DIRECTORY will be 803 # The HTML_OUTPUT tag is used to specify where the HTML docs will be put. 804 # If a relative path is entered the value of OUTPUT_DIRECTORY will be 658 805 # put in front of it. If left blank `html' will be used as the default path. 659 806 660 807 HTML_OUTPUT = html 661 808 662 # The HTML_FILE_EXTENSION tag can be used to specify the file extension for 663 # each generated HTML page (for example: .htm,.php,.asp). If it is left blank 809 # The HTML_FILE_EXTENSION tag can be used to specify the file extension for 810 # each generated HTML page (for example: .htm,.php,.asp). If it is left blank 664 811 # doxygen will generate files with .html extension. 665 812 666 813 HTML_FILE_EXTENSION = .html 667 814 668 # The HTML_HEADER tag can be used to specify a personal HTML header for 669 # each generated HTML page. If it is left blank doxygen will generate a 815 # The HTML_HEADER tag can be used to specify a personal HTML header for 816 # each generated HTML page. If it is left blank doxygen will generate a 670 817 # standard header. 671 HTML_HEADER = 672 673 674 # The HTML_FOOTER tag can be used to specify a personal HTML footer for 675 # each generated HTML page. If it is left blank doxygen will generate a 818 819 HTML_HEADER = 820 821 # The HTML_FOOTER tag can be used to specify a personal HTML footer for 822 # each generated HTML page. If it is left blank doxygen will generate a 676 823 # standard footer. 677 824 678 HTML_FOOTER = 679 680 # The HTML_STYLESHEET tag can be used to specify a user-defined cascading 681 # style sheet that is used by each HTML page. It can be used to 682 # fine-tune the look of the HTML output. If the tag is left blank doxygen 683 # will generate a default style sheet. Note that doxygen will try to copy 684 # the style sheet file to the HTML output directory, so don't put your own 825 HTML_FOOTER = 826 827 # The HTML_STYLESHEET tag can be used to specify a user-defined cascading 828 # style sheet that is used by each HTML page. It can be used to 829 # fine-tune the look of the HTML output. If the tag is left blank doxygen 830 # will generate a default style sheet. Note that doxygen will try to copy 831 # the style sheet file to the HTML output directory, so don't put your own 685 832 # stylesheet in the HTML output directory as well, or it will be erased! 686 833 687 HTML_STYLESHEET = 688 689 # If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, 690 # files or namespaces will be aligned in HTML using tables. If set to 834 HTML_STYLESHEET = 835 836 # If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML 837 # page will contain the date and time when the page was generated. Setting 838 # this to NO can help when comparing the output of multiple runs. 839 840 HTML_TIMESTAMP = YES 841 842 # If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, 843 # files or namespaces will be aligned in HTML using tables. If set to 691 844 # NO a bullet list will be used. 692 845 693 846 HTML_ALIGN_MEMBERS = YES 694 847 695 # If the GENERATE_HTMLHELP tag is set to YES, additional index files 696 # will be generated that can be used as input for tools like the 697 # Microsoft HTML help workshop to generate a compressed HTML help file (.chm) 848 # If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML 849 # documentation will contain sections that can be hidden and shown after the 850 # page has loaded. For this to work a browser that supports 851 # JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox 852 # Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). 853 854 HTML_DYNAMIC_SECTIONS = NO 855 856 # If the GENERATE_DOCSET tag is set to YES, additional index files 857 # will be generated that can be used as input for Apple's Xcode 3 858 # integrated development environment, introduced with OSX 10.5 (Leopard). 859 # To create a documentation set, doxygen will generate a Makefile in the 860 # HTML output directory. Running make will produce the docset in that 861 # directory and running "make install" will install the docset in 862 # ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find 863 # it at startup. 864 # See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html for more information. 865 866 GENERATE_DOCSET = NO 867 868 # When GENERATE_DOCSET tag is set to YES, this tag determines the name of the 869 # feed. A documentation feed provides an umbrella under which multiple 870 # documentation sets from a single provider (such as a company or product suite) 871 # can be grouped. 872 873 DOCSET_FEEDNAME = "Doxygen generated docs" 874 875 # When GENERATE_DOCSET tag is set to YES, this tag specifies a string that 876 # should uniquely identify the documentation set bundle. This should be a 877 # reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen 878 # will append .docset to the name. 879 880 DOCSET_BUNDLE_ID = org.doxygen.Project 881 882 # If the GENERATE_HTMLHELP tag is set to YES, additional index files 883 # will be generated that can be used as input for tools like the 884 # Microsoft HTML help workshop to generate a compiled HTML help file (.chm) 698 885 # of the generated HTML documentation. 699 886 700 887 GENERATE_HTMLHELP = YES 701 888 702 # If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can 703 # be used to specify the file name of the resulting .chm file. You 704 # can add a path in front of the file if the result should not be 889 # If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can 890 # be used to specify the file name of the resulting .chm file. You 891 # can add a path in front of the file if the result should not be 705 892 # written to the html output directory. 706 893 707 CHM_FILE = 708 709 # If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can 710 # be used to specify the location (absolute path including file name) of 711 # the HTML help compiler (hhc.exe). If non-empty doxygen will try to run 894 CHM_FILE = 895 896 # If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can 897 # be used to specify the location (absolute path including file name) of 898 # the HTML help compiler (hhc.exe). If non-empty doxygen will try to run 712 899 # the HTML help compiler on the generated index.hhp. 713 900 714 HHC_LOCATION = 715 716 # If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag 717 # controls if a separate .chi index file is generated (YES) or that 901 HHC_LOCATION = 902 903 # If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag 904 # controls if a separate .chi index file is generated (YES) or that 718 905 # it should be included in the master .chm file (NO). 719 906 720 907 GENERATE_CHI = NO 721 908 722 # If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag 723 # controls whether a binary table of contents is generated (YES) or a 909 # If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING 910 # is used to encode HtmlHelp index (hhk), content (hhc) and project file 911 # content. 912 913 CHM_INDEX_ENCODING = 914 915 # If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag 916 # controls whether a binary table of contents is generated (YES) or a 724 917 # normal table of contents (NO) in the .chm file. 725 918 726 919 BINARY_TOC = NO 727 920 728 # The TOC_EXPAND flag can be set to YES to add extra items for group members 921 # The TOC_EXPAND flag can be set to YES to add extra items for group members 729 922 # to the contents of the HTML help documentation and to the tree view. 730 923 731 924 TOC_EXPAND = NO 732 925 733 # The DISABLE_INDEX tag can be used to turn on/off the condensed index at 734 # top of each HTML page. The value NO (the default) enables the index and 926 # If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and QHP_VIRTUAL_FOLDER 927 # are set, an additional index file will be generated that can be used as input for 928 # Qt's qhelpgenerator to generate a Qt Compressed Help (.qch) of the generated 929 # HTML documentation. 930 931 GENERATE_QHP = NO 932 933 # If the QHG_LOCATION tag is specified, the QCH_FILE tag can 934 # be used to specify the file name of the resulting .qch file. 935 # The path specified is relative to the HTML output folder. 936 937 QCH_FILE = 938 939 # The QHP_NAMESPACE tag specifies the namespace to use when generating 940 # Qt Help Project output. For more information please see 941 # http://doc.trolltech.com/qthelpproject.html#namespace 942 943 QHP_NAMESPACE = org.doxygen.Project 944 945 # The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating 946 # Qt Help Project output. For more information please see 947 # http://doc.trolltech.com/qthelpproject.html#virtual-folders 948 949 QHP_VIRTUAL_FOLDER = doc 950 951 # If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to add. 952 # For more information please see 953 # http://doc.trolltech.com/qthelpproject.html#custom-filters 954 955 QHP_CUST_FILTER_NAME = 956 957 # The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the custom filter to add.For more information please see 958 # <a href="http://doc.trolltech.com/qthelpproject.html#custom-filters">Qt Help Project / Custom Filters</a>. 959 960 QHP_CUST_FILTER_ATTRS = 961 962 # The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this project's 963 # filter section matches. 964 # <a href="http://doc.trolltech.com/qthelpproject.html#filter-attributes">Qt Help Project / Filter Attributes</a>. 965 966 QHP_SECT_FILTER_ATTRS = 967 968 # If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can 969 # be used to specify the location of Qt's qhelpgenerator. 970 # If non-empty doxygen will try to run qhelpgenerator on the generated 971 # .qhp file. 972 973 QHG_LOCATION = 974 975 # If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files 976 # will be generated, which together with the HTML files, form an Eclipse help 977 # plugin. To install this plugin and make it available under the help contents 978 # menu in Eclipse, the contents of the directory containing the HTML and XML 979 # files needs to be copied into the plugins directory of eclipse. The name of 980 # the directory within the plugins directory should be the same as 981 # the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before the help appears. 982 983 GENERATE_ECLIPSEHELP = NO 984 985 # A unique identifier for the eclipse help plugin. When installing the plugin 986 # the directory name containing the HTML and XML files should also have 987 # this name. 988 989 ECLIPSE_DOC_ID = org.doxygen.Project 990 991 # The DISABLE_INDEX tag can be used to turn on/off the condensed index at 992 # top of each HTML page. The value NO (the default) enables the index and 735 993 # the value YES disables it. 736 994 737 995 DISABLE_INDEX = NO 738 996 739 # This tag can be used to set the number of enum values (range [1..20]) 997 # This tag can be used to set the number of enum values (range [1..20]) 740 998 # that doxygen will group on one line in the generated HTML documentation. 741 999 742 1000 ENUM_VALUES_PER_LINE = 4 743 1001 744 # If the GENERATE_TREEVIEW tag is set to YES, a side panel will be 745 # generated containing a tree-like index structure (just like the one that 746 # is generated for HTML Help). For this to work a browser that supports 747 # JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, 748 # Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are 749 # probably better off using the HTML help feature. 1002 # The GENERATE_TREEVIEW tag is used to specify whether a tree-like index 1003 # structure should be generated to display hierarchical information. 1004 # If the tag value is set to YES, a side panel will be generated 1005 # containing a tree-like index structure (just like the one that 1006 # is generated for HTML Help). For this to work a browser that supports 1007 # JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). 1008 # Windows users are probably better off using the HTML help feature. 750 1009 751 1010 GENERATE_TREEVIEW = NO 752 1011 753 # If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be 754 # used to set the initial width (in pixels) of the frame in which the tree 1012 # By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories, 1013 # and Class Hierarchy pages using a tree view instead of an ordered list. 1014 1015 USE_INLINE_TREES = NO 1016 1017 # If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be 1018 # used to set the initial width (in pixels) of the frame in which the tree 755 1019 # is shown. 756 1020 757 1021 TREEVIEW_WIDTH = 250 758 1022 1023 # Use this tag to change the font size of Latex formulas included 1024 # as images in the HTML documentation. The default is 10. Note that 1025 # when you change the font size after a successful doxygen run you need 1026 # to manually remove any form_*.png images from the HTML output directory 1027 # to force them to be regenerated. 1028 1029 FORMULA_FONTSIZE = 10 1030 1031 # When the SEARCHENGINE tag is enabled doxygen will generate a search box for the HTML output. The underlying search engine uses javascript 1032 # and DHTML and should work on any modern browser. Note that when using HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET) there is already a search function so this one should 1033 # typically be disabled. For large projects the javascript based search engine 1034 # can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. 1035 1036 SEARCHENGINE = YES 1037 1038 # When the SERVER_BASED_SEARCH tag is enabled the search engine will be implemented using a PHP enabled web server instead of at the web client using Javascript. Doxygen will generate the search PHP script and index 1039 # file to put on the web server. The advantage of the server based approach is that it scales better to large projects and allows full text search. The disadvances is that it is more difficult to setup 1040 # and does not have live searching capabilities. 1041 1042 SERVER_BASED_SEARCH = NO 1043 759 1044 #--------------------------------------------------------------------------- 760 1045 # configuration options related to the LaTeX output 761 1046 #--------------------------------------------------------------------------- 762 1047 763 # If the GENERATE_LATEX tag is set to YES (the default) Doxygen will 1048 # If the GENERATE_LATEX tag is set to YES (the default) Doxygen will 764 1049 # generate Latex output. 765 1050 766 1051 GENERATE_LATEX = NO 767 1052 768 # The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. 769 # If a relative path is entered the value of OUTPUT_DIRECTORY will be 1053 # The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. 1054 # If a relative path is entered the value of OUTPUT_DIRECTORY will be 770 1055 # put in front of it. If left blank `latex' will be used as the default path. 771 1056 772 1057 LATEX_OUTPUT = latex 773 1058 774 # The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be 1059 # The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be 775 1060 # invoked. If left blank `latex' will be used as the default command name. 776 777 #LATEX_CMD_NAME = latex 778 LATEX_CMD_NAME = @LATEX_COMPILER@ 779 780 # The MAKEINDEX_CMD_NAME tag can be used to specify the command name to 781 # generate index for LaTeX. If left blank `makeindex' will be used as the 1061 # Note that when enabling USE_PDFLATEX this option is only used for 1062 # generating bitmaps for formulas in the HTML output, but not in the 1063 # Makefile that is written to the output directory. 1064 1065 LATEX_CMD_NAME = @LATEX_COMPILER@ 1066 1067 # The MAKEINDEX_CMD_NAME tag can be used to specify the command name to 1068 # generate index for LaTeX. If left blank `makeindex' will be used as the 782 1069 # default command name. 783 1070 784 #MAKEINDEX_CMD_NAME = makeindex785 1071 MAKEINDEX_CMD_NAME = @MAKEINDEX_COMPILER@ 786 1072 787 # If the COMPACT_LATEX tag is set to YES Doxygen generates more compact 788 # LaTeX documents. This may be useful for small projects and may help to 1073 # If the COMPACT_LATEX tag is set to YES Doxygen generates more compact 1074 # LaTeX documents. This may be useful for small projects and may help to 789 1075 # save some trees in general. 790 1076 791 1077 COMPACT_LATEX = NO 792 1078 793 # The PAPER_TYPE tag can be used to set the paper type that is used 794 # by the printer. Possible values are: a4, a4wide, letter, legal and 1079 # The PAPER_TYPE tag can be used to set the paper type that is used 1080 # by the printer. Possible values are: a4, a4wide, letter, legal and 795 1081 # executive. If left blank a4wide will be used. 796 1082 797 1083 PAPER_TYPE = a4wide 798 1084 799 # The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX 1085 # The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX 800 1086 # packages that should be included in the LaTeX output. 801 1087 802 EXTRA_PACKAGES = 803 804 # The LATEX_HEADER tag can be used to specify a personal LaTeX header for 805 # the generated latex document. The header should contain everything until 806 # the first chapter. If it is left blank doxygen will generate a 1088 EXTRA_PACKAGES = 1089 1090 # The LATEX_HEADER tag can be used to specify a personal LaTeX header for 1091 # the generated latex document. The header should contain everything until 1092 # the first chapter. If it is left blank doxygen will generate a 807 1093 # standard header. Notice: only use this tag if you know what you are doing! 808 1094 809 LATEX_HEADER = 810 811 # If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated 812 # is prepared for conversion to pdf (using ps2pdf). The pdf file will 813 # contain links (just like the HTML output) instead of page references 1095 LATEX_HEADER = 1096 1097 # If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated 1098 # is prepared for conversion to pdf (using ps2pdf). The pdf file will 1099 # contain links (just like the HTML output) instead of page references 814 1100 # This makes the output suitable for online browsing using a pdf viewer. 815 1101 816 1102 PDF_HYPERLINKS = YES 817 1103 818 # If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of 819 # plain latex in the generated Makefile. Set this option to YES to get a 1104 # If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of 1105 # plain latex in the generated Makefile. Set this option to YES to get a 820 1106 # higher quality PDF documentation. 821 1107 822 1108 USE_PDFLATEX = YES 823 1109 824 # If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. 825 # command to the generated LaTeX files. This will instruct LaTeX to keep 826 # running if errors occur, instead of asking the user for help. 1110 # If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. 1111 # command to the generated LaTeX files. This will instruct LaTeX to keep 1112 # running if errors occur, instead of asking the user for help. 827 1113 # This option is also used when generating formulas in HTML. 828 1114 829 1115 LATEX_BATCHMODE = YES 830 1116 831 # If LATEX_HIDE_INDICES is set to YES then doxygen will not 832 # include the index chapters (such as File Index, Compound Index, etc.) 1117 # If LATEX_HIDE_INDICES is set to YES then doxygen will not 1118 # include the index chapters (such as File Index, Compound Index, etc.) 833 1119 # in the output. 834 1120 835 1121 LATEX_HIDE_INDICES = NO 836 1122 1123 # If LATEX_SOURCE_CODE is set to YES then doxygen will include source code with syntax highlighting in the LaTeX output. Note that which sources are shown also depends on other settings such as SOURCE_BROWSER. 1124 1125 LATEX_SOURCE_CODE = NO 1126 837 1127 #--------------------------------------------------------------------------- 838 1128 # configuration options related to the RTF output 839 1129 #--------------------------------------------------------------------------- 840 1130 841 # If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output 842 # The RTF output is optimized for Word 97 and may not look very pretty with 1131 # If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output 1132 # The RTF output is optimized for Word 97 and may not look very pretty with 843 1133 # other RTF readers or editors. 844 1134 845 1135 GENERATE_RTF = NO 846 1136 847 # The RTF_OUTPUT tag is used to specify where the RTF docs will be put. 848 # If a relative path is entered the value of OUTPUT_DIRECTORY will be 1137 # The RTF_OUTPUT tag is used to specify where the RTF docs will be put. 1138 # If a relative path is entered the value of OUTPUT_DIRECTORY will be 849 1139 # put in front of it. If left blank `rtf' will be used as the default path. 850 1140 851 1141 RTF_OUTPUT = rtf 852 1142 853 # If the COMPACT_RTF tag is set to YES Doxygen generates more compact 854 # RTF documents. This may be useful for small projects and may help to 1143 # If the COMPACT_RTF tag is set to YES Doxygen generates more compact 1144 # RTF documents. This may be useful for small projects and may help to 855 1145 # save some trees in general. 856 1146 857 1147 COMPACT_RTF = NO 858 1148 859 # If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated 860 # will contain hyperlink fields. The RTF file will 861 # contain links (just like the HTML output) instead of page references. 862 # This makes the output suitable for online browsing using WORD or other 863 # programs which support those fields. 1149 # If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated 1150 # will contain hyperlink fields. The RTF file will 1151 # contain links (just like the HTML output) instead of page references. 1152 # This makes the output suitable for online browsing using WORD or other 1153 # programs which support those fields. 864 1154 # Note: wordpad (write) and others do not support links. 865 1155 866 1156 RTF_HYPERLINKS = NO 867 1157 868 # Load stylesheet definitions from file. Syntax is similar to doxygen's 869 # config file, i.e. a series of assignments. You only have to provide 1158 # Load stylesheet definitions from file. Syntax is similar to doxygen's 1159 # config file, i.e. a series of assignments. You only have to provide 870 1160 # replacements, missing definitions are set to their default value. 871 1161 872 RTF_STYLESHEET_FILE = 873 874 # Set optional variables used in the generation of an rtf document. 1162 RTF_STYLESHEET_FILE = 1163 1164 # Set optional variables used in the generation of an rtf document. 875 1165 # Syntax is similar to doxygen's config file. 876 1166 877 RTF_EXTENSIONS_FILE = 1167 RTF_EXTENSIONS_FILE = 878 1168 879 1169 #--------------------------------------------------------------------------- … … 881 1171 #--------------------------------------------------------------------------- 882 1172 883 # If the GENERATE_MAN tag is set to YES (the default) Doxygen will 1173 # If the GENERATE_MAN tag is set to YES (the default) Doxygen will 884 1174 # generate man pages 885 1175 886 1176 GENERATE_MAN = NO 887 1177 888 # The MAN_OUTPUT tag is used to specify where the man pages will be put. 889 # If a relative path is entered the value of OUTPUT_DIRECTORY will be 1178 # The MAN_OUTPUT tag is used to specify where the man pages will be put. 1179 # If a relative path is entered the value of OUTPUT_DIRECTORY will be 890 1180 # put in front of it. If left blank `man' will be used as the default path. 891 1181 892 1182 MAN_OUTPUT = man 893 1183 894 # The MAN_EXTENSION tag determines the extension that is added to 1184 # The MAN_EXTENSION tag determines the extension that is added to 895 1185 # the generated man pages (default is the subroutine's section .3) 896 1186 897 1187 MAN_EXTENSION = .3 898 1188 899 # If the MAN_LINKS tag is set to YES and Doxygen generates man output, 900 # then it will generate one additional man file for each entity 901 # documented in the real man page(s). These additional files 902 # only source the real man page, but without them the man command 1189 # If the MAN_LINKS tag is set to YES and Doxygen generates man output, 1190 # then it will generate one additional man file for each entity 1191 # documented in the real man page(s). These additional files 1192 # only source the real man page, but without them the man command 903 1193 # would be unable to find the correct page. The default is NO. 904 1194 … … 909 1199 #--------------------------------------------------------------------------- 910 1200 911 # If the GENERATE_XML tag is set to YES Doxygen will 912 # generate an XML file that captures the structure of 1201 # If the GENERATE_XML tag is set to YES Doxygen will 1202 # generate an XML file that captures the structure of 913 1203 # the code including all documentation. 914 1204 915 1205 GENERATE_XML = NO 916 1206 917 # The XML_OUTPUT tag is used to specify where the XML pages will be put. 918 # If a relative path is entered the value of OUTPUT_DIRECTORY will be 1207 # The XML_OUTPUT tag is used to specify where the XML pages will be put. 1208 # If a relative path is entered the value of OUTPUT_DIRECTORY will be 919 1209 # put in front of it. If left blank `xml' will be used as the default path. 920 1210 921 1211 XML_OUTPUT = xml 922 1212 923 # The XML_SCHEMA tag can be used to specify an XML schema, 924 # which can be used by a validating XML parser to check the 1213 # The XML_SCHEMA tag can be used to specify an XML schema, 1214 # which can be used by a validating XML parser to check the 925 1215 # syntax of the XML files. 926 1216 927 XML_SCHEMA = 928 929 # The XML_DTD tag can be used to specify an XML DTD, 930 # which can be used by a validating XML parser to check the 1217 XML_SCHEMA = 1218 1219 # The XML_DTD tag can be used to specify an XML DTD, 1220 # which can be used by a validating XML parser to check the 931 1221 # syntax of the XML files. 932 1222 933 XML_DTD = 934 935 # If the XML_PROGRAMLISTING tag is set to YES Doxygen will 936 # dump the program listings (including syntax highlighting 937 # and cross-referencing information) to the XML output. Note that 1223 XML_DTD = 1224 1225 # If the XML_PROGRAMLISTING tag is set to YES Doxygen will 1226 # dump the program listings (including syntax highlighting 1227 # and cross-referencing information) to the XML output. Note that 938 1228 # enabling this will significantly increase the size of the XML output. 939 1229 … … 944 1234 #--------------------------------------------------------------------------- 945 1235 946 # If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will 947 # generate an AutoGen Definitions (see autogen.sf.net) file 948 # that captures the structure of the code including all 949 # documentation. Note that this feature is still experimental 1236 # If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will 1237 # generate an AutoGen Definitions (see autogen.sf.net) file 1238 # that captures the structure of the code including all 1239 # documentation. Note that this feature is still experimental 950 1240 # and incomplete at the moment. 951 1241 … … 956 1246 #--------------------------------------------------------------------------- 957 1247 958 # If the GENERATE_PERLMOD tag is set to YES Doxygen will 959 # generate a Perl module file that captures the structure of 960 # the code including all documentation. Note that this 961 # feature is still experimental and incomplete at the 1248 # If the GENERATE_PERLMOD tag is set to YES Doxygen will 1249 # generate a Perl module file that captures the structure of 1250 # the code including all documentation. Note that this 1251 # feature is still experimental and incomplete at the 962 1252 # moment. 963 1253 964 1254 GENERATE_PERLMOD = NO 965 1255 966 # If the PERLMOD_LATEX tag is set to YES Doxygen will generate 967 # the necessary Makefile rules, Perl scripts and LaTeX code to be able 1256 # If the PERLMOD_LATEX tag is set to YES Doxygen will generate 1257 # the necessary Makefile rules, Perl scripts and LaTeX code to be able 968 1258 # to generate PDF and DVI output from the Perl module output. 969 1259 970 1260 PERLMOD_LATEX = NO 971 1261 972 # If the PERLMOD_PRETTY tag is set to YES the Perl module output will be 973 # nicely formatted so it can be parsed by a human reader. This is useful 974 # if you want to understand what is going on. On the other hand, if this 975 # tag is set to NO the size of the Perl module output will be much smaller 1262 # If the PERLMOD_PRETTY tag is set to YES the Perl module output will be 1263 # nicely formatted so it can be parsed by a human reader. 1264 # This is useful 1265 # if you want to understand what is going on. 1266 # On the other hand, if this 1267 # tag is set to NO the size of the Perl module output will be much smaller 976 1268 # and Perl will parse it just the same. 977 1269 978 1270 PERLMOD_PRETTY = YES 979 1271 980 # The names of the make variables in the generated doxyrules.make file 981 # are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. 982 # This is useful so different doxyrules.make files included by the same 1272 # The names of the make variables in the generated doxyrules.make file 1273 # are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. 1274 # This is useful so different doxyrules.make files included by the same 983 1275 # Makefile don't overwrite each other's variables. 984 1276 985 PERLMOD_MAKEVAR_PREFIX = 986 987 #--------------------------------------------------------------------------- 988 # Configuration options related to the preprocessor 989 #--------------------------------------------------------------------------- 990 991 # If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will 992 # evaluate all C-preprocessor directives found in the sources and include 1277 PERLMOD_MAKEVAR_PREFIX = 1278 1279 #--------------------------------------------------------------------------- 1280 # Configuration options related to the preprocessor 1281 #--------------------------------------------------------------------------- 1282 1283 # If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will 1284 # evaluate all C-preprocessor directives found in the sources and include 993 1285 # files. 994 1286 995 1287 ENABLE_PREPROCESSING = YES 996 1288 997 # If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro 998 # names in the source code. If set to NO (the default) only conditional 999 # compilation will be performed. Macro expansion can be done in a controlled 1289 # If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro 1290 # names in the source code. If set to NO (the default) only conditional 1291 # compilation will be performed. Macro expansion can be done in a controlled 1000 1292 # way by setting EXPAND_ONLY_PREDEF to YES. 1001 1293 1002 MACRO_EXPANSION = YES1003 1004 # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES 1005 # then the macro expansion is limited to the macros specified with the 1294 MACRO_EXPANSION = NO 1295 1296 # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES 1297 # then the macro expansion is limited to the macros specified with the 1006 1298 # PREDEFINED and EXPAND_AS_DEFINED tags. 1007 1299 1008 1300 EXPAND_ONLY_PREDEF = YES 1009 1301 1010 # If the SEARCH_INCLUDES tag is set to YES (the default) the includes files 1302 # If the SEARCH_INCLUDES tag is set to YES (the default) the includes files 1011 1303 # in the INCLUDE_PATH (see below) will be search if a #include is found. 1012 1304 1013 SEARCH_INCLUDES = YES1014 1015 # The INCLUDE_PATH tag can be used to specify one or more directories that 1016 # contain include files that are not input files but should be processed by 1305 SEARCH_INCLUDES = NO 1306 1307 # The INCLUDE_PATH tag can be used to specify one or more directories that 1308 # contain include files that are not input files but should be processed by 1017 1309 # the preprocessor. 1018 1310 1019 INCLUDE_PATH = 1020 1021 # You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard 1022 # patterns (like *.h and *.hpp) to filter out the header-files in the 1023 # directories. If left blank, the patterns specified with FILE_PATTERNS will 1311 INCLUDE_PATH = #@DOXYGEN_INCLUDE_DIRECTORIES@ 1312 1313 # You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard 1314 # patterns (like *.h and *.hpp) to filter out the header-files in the 1315 # directories. If left blank, the patterns specified with FILE_PATTERNS will 1024 1316 # be used. 1025 1317 1026 INCLUDE_FILE_PATTERNS = 1027 1028 # The PREDEFINED tag can be used to specify one or more macro names that 1029 # are defined before the preprocessor is started (similar to the -D option of 1030 # gcc). The argument of the tag is a list of macros of the form: name 1031 # or name=definition (no spaces). If the definition and the = are 1032 # omitted =1 is assumed. To prevent a macro definition from being 1033 # undefined via #undef or recursively expanded use the := operator 1318 INCLUDE_FILE_PATTERNS = 1319 1320 # The PREDEFINED tag can be used to specify one or more macro names that 1321 # are defined before the preprocessor is started (similar to the -D option of 1322 # gcc). The argument of the tag is a list of macros of the form: name 1323 # or name=definition (no spaces). If the definition and the = are 1324 # omitted =1 is assumed. To prevent a macro definition from being 1325 # undefined via #undef or recursively expanded use the := operator 1034 1326 # instead of the = operator. 1035 1327 1036 PREDEFINED = DOXYGEN_SHOULD_SKIP_THIS 1037 1038 # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then 1039 # this tag can be used to specify a list of macro names that should be expanded. 1040 # The macro definition that is found in the sources will be used. 1328 PREDEFINED = DOXYGEN_SHOULD_SKIP_THIS \ 1329 @DOXY_PLATFORM_DEF@ \ 1330 @DOXY_COMPILER_DEF@ 1331 1332 # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then 1333 # this tag can be used to specify a list of macro names that should be expanded. 1334 # The macro definition that is found in the sources will be used. 1041 1335 # Use the PREDEFINED tag if you want to use a different macro definition. 1042 1336 1043 EXPAND_AS_DEFINED = 1044 1045 # If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then 1046 # doxygen's preprocessor will remove all function-like macros that are alone 1047 # on a line, have an all uppercase name, and do not end with a semicolon. Such 1048 # function macros are typically used for boiler-plate code, and will confuse 1337 EXPAND_AS_DEFINED = 1338 1339 # If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then 1340 # doxygen's preprocessor will remove all function-like macros that are alone 1341 # on a line, have an all uppercase name, and do not end with a semicolon. Such 1342 # function macros are typically used for boiler-plate code, and will confuse 1049 1343 # the parser if not removed. 1050 1344 … … 1052 1346 1053 1347 #--------------------------------------------------------------------------- 1054 # Configuration::additions related to external references 1055 #--------------------------------------------------------------------------- 1056 1057 # The TAGFILES option can be used to specify one or more tagfiles. 1058 # Optionally an initial location of the external documentation 1059 # can be added for each tagfile. The format of a tag file without 1060 # this location is as follows: 1061 # TAGFILES = file1 file2 ... 1062 # Adding location for the tag files is done as follows: 1063 # TAGFILES = file1=loc1 "file2 = loc2" ... 1064 # where "loc1" and "loc2" can be relative or absolute paths or 1065 # URLs. If a location is present for each tag, the installdox tool 1348 # Configuration::additions related to external references 1349 #--------------------------------------------------------------------------- 1350 1351 # The TAGFILES option can be used to specify one or more tagfiles. 1352 # Optionally an initial location of the external documentation 1353 # can be added for each tagfile. The format of a tag file without 1354 # this location is as follows: 1355 # 1356 # TAGFILES = file1 file2 ... 1357 # Adding location for the tag files is done as follows: 1358 # 1359 # TAGFILES = file1=loc1 "file2 = loc2" ... 1360 # where "loc1" and "loc2" can be relative or absolute paths or 1361 # URLs. If a location is present for each tag, the installdox tool 1066 1362 # does not have to be run to correct the links. 1067 1363 # Note that each tag file must have a unique name 1068 1364 # (where the name does NOT include the path) 1069 # If a tag file is not located in the directory in which doxygen 1365 # If a tag file is not located in the directory in which doxygen 1070 1366 # is run, you must also specify the path to the tagfile here. 1071 1367 1072 TAGFILES = 1073 1074 # When a file name is specified after GENERATE_TAGFILE, doxygen will create 1368 TAGFILES = 1369 1370 # When a file name is specified after GENERATE_TAGFILE, doxygen will create 1075 1371 # a tag file that is based on the input files it reads. 1076 1372 1077 1373 GENERATE_TAGFILE = @DOXY_OUTPUT_DIR@/html/@PROJECT_NAME@.TAGFILE 1078 1374 1079 # If the ALLEXTERNALS tag is set to YES all external classes will be listed 1080 # in the class index. If set to NO only the inherited external classes 1375 # If the ALLEXTERNALS tag is set to YES all external classes will be listed 1376 # in the class index. If set to NO only the inherited external classes 1081 1377 # will be listed. 1082 1378 1083 1379 ALLEXTERNALS = NO 1084 1380 1085 # If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed 1086 # in the modules index. If set to NO, only the current project's groups will 1381 # If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed 1382 # in the modules index. If set to NO, only the current project's groups will 1087 1383 # be listed. 1088 1384 1089 1385 EXTERNAL_GROUPS = YES 1090 1386 1091 # The PERL_PATH should be the absolute path and name of the perl script 1387 # The PERL_PATH should be the absolute path and name of the perl script 1092 1388 # interpreter (i.e. the result of `which perl'). 1093 1389 … … 1095 1391 1096 1392 #--------------------------------------------------------------------------- 1097 # Configuration options related to the dot tool 1098 #--------------------------------------------------------------------------- 1099 1100 # If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will 1101 # generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base 1102 # or super classes. Setting the tag to NO turns the diagrams off. Note that 1103 # this option is superseded by the HAVE_DOT option below. This is only a 1104 # fallback. It is recommended to install and use dot, since it yields more 1393 # Configuration options related to the dot tool 1394 #--------------------------------------------------------------------------- 1395 1396 # If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will 1397 # generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base 1398 # or super classes. Setting the tag to NO turns the diagrams off. Note that 1399 # this option is superseded by the HAVE_DOT option below. This is only a 1400 # fallback. It is recommended to install and use dot, since it yields more 1105 1401 # powerful graphs. 1106 1402 1107 1403 CLASS_DIAGRAMS = YES 1108 1404 1109 # If set to YES, the inheritance and collaboration graphs will hide 1110 # inheritance and usage relations if the target is undocumented 1405 # You can define message sequence charts within doxygen comments using the \msc 1406 # command. Doxygen will then run the mscgen tool (see 1407 # http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the 1408 # documentation. The MSCGEN_PATH tag allows you to specify the directory where 1409 # the mscgen tool resides. If left empty the tool is assumed to be found in the 1410 # default search path. 1411 1412 MSCGEN_PATH = 1413 1414 # If set to YES, the inheritance and collaboration graphs will hide 1415 # inheritance and usage relations if the target is undocumented 1111 1416 # or is not a class. 1112 1417 1113 1418 HIDE_UNDOC_RELATIONS = YES 1114 1419 1115 # If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is 1116 # available from the path. This tool is part of Graphviz, a graph visualization 1117 # toolkit from AT&T and Lucent Bell Labs. The other options in this section 1420 # If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is 1421 # available from the path. This tool is part of Graphviz, a graph visualization 1422 # toolkit from AT&T and Lucent Bell Labs. The other options in this section 1118 1423 # have no effect if this option is set to NO (the default) 1119 1424 1120 1425 HAVE_DOT = NO 1121 1426 1122 # If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen 1123 # will generate a graph for each documented class showing the direct and 1124 # indirect inheritance relations. Setting this tag to YES will force the 1427 # By default doxygen will write a font called FreeSans.ttf to the output 1428 # directory and reference it in all dot files that doxygen generates. This 1429 # font does not include all possible unicode characters however, so when you need 1430 # these (or just want a differently looking font) you can specify the font name 1431 # using DOT_FONTNAME. You need need to make sure dot is able to find the font, 1432 # which can be done by putting it in a standard location or by setting the 1433 # DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory 1434 # containing the font. 1435 1436 DOT_FONTNAME = FreeSans 1437 1438 # The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. 1439 # The default size is 10pt. 1440 1441 DOT_FONTSIZE = 10 1442 1443 # By default doxygen will tell dot to use the output directory to look for the 1444 # FreeSans.ttf font (which doxygen will put there itself). If you specify a 1445 # different font using DOT_FONTNAME you can set the path where dot 1446 # can find it using this tag. 1447 1448 DOT_FONTPATH = 1449 1450 # If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen 1451 # will generate a graph for each documented class showing the direct and 1452 # indirect inheritance relations. Setting this tag to YES will force the 1125 1453 # the CLASS_DIAGRAMS tag to NO. 1126 1454 1127 1455 CLASS_GRAPH = YES 1128 1456 1129 # If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen 1130 # will generate a graph for each documented class showing the direct and 1131 # indirect implementation dependencies (inheritance, containment, and 1457 # If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen 1458 # will generate a graph for each documented class showing the direct and 1459 # indirect implementation dependencies (inheritance, containment, and 1132 1460 # class references variables) of the class with other documented classes. 1133 1461 1134 1462 COLLABORATION_GRAPH = YES 1135 1463 1136 # If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen 1464 # If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen 1137 1465 # will generate a graph for groups, showing the direct groups dependencies 1138 1466 1139 1467 GROUP_GRAPHS = YES 1140 1468 1141 # If the UML_LOOK tag is set to YES doxygen will generate inheritance and 1142 # collaboration diagrams in a style similar to the OMG's Unified Modeling 1469 # If the UML_LOOK tag is set to YES doxygen will generate inheritance and 1470 # collaboration diagrams in a style similar to the OMG's Unified Modeling 1143 1471 # Language. 1144 1472 1145 1473 UML_LOOK = NO 1146 1474 1147 # If set to YES, the inheritance and collaboration graphs will show the 1475 # If set to YES, the inheritance and collaboration graphs will show the 1148 1476 # relations between templates and their instances. 1149 1477 1150 1478 TEMPLATE_RELATIONS = NO 1151 1479 1152 # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT 1153 # tags are set to YES then doxygen will generate a graph for each documented 1154 # file showing the direct and indirect include dependencies of the file with 1480 # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT 1481 # tags are set to YES then doxygen will generate a graph for each documented 1482 # file showing the direct and indirect include dependencies of the file with 1155 1483 # other documented files. 1156 1484 1157 1485 INCLUDE_GRAPH = YES 1158 1486 1159 # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and 1160 # HAVE_DOT tags are set to YES then doxygen will generate a graph for each 1161 # documented header file showing the documented files that directly or 1487 # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and 1488 # HAVE_DOT tags are set to YES then doxygen will generate a graph for each 1489 # documented header file showing the documented files that directly or 1162 1490 # indirectly include this file. 1163 1491 1164 1492 INCLUDED_BY_GRAPH = YES 1165 1493 1166 # If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will1167 # generate a call dependency graph for every global function or class method.1168 # Note that enabling this option will significantly increase the time of a run.1169 # So in most cases it will be better to enable call graphs for selected1170 # f unctions only using the \callgraph command.1494 # If the CALL_GRAPH and HAVE_DOT options are set to YES then 1495 # doxygen will generate a call dependency graph for every global function 1496 # or class method. Note that enabling this option will significantly increase 1497 # the time of a run. So in most cases it will be better to enable call graphs 1498 # for selected functions only using the \callgraph command. 1171 1499 1172 1500 CALL_GRAPH = NO 1173 1501 1174 # If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen 1502 # If the CALLER_GRAPH and HAVE_DOT tags are set to YES then 1503 # doxygen will generate a caller dependency graph for every global function 1504 # or class method. Note that enabling this option will significantly increase 1505 # the time of a run. So in most cases it will be better to enable caller 1506 # graphs for selected functions only using the \callergraph command. 1507 1508 CALLER_GRAPH = NO 1509 1510 # If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen 1175 1511 # will graphical hierarchy of all classes instead of a textual one. 1176 1512 1177 1513 GRAPHICAL_HIERARCHY = YES 1178 1514 1179 # If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES 1180 # then doxygen will show the dependencies a directory has on other directories 1515 # If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES 1516 # then doxygen will show the dependencies a directory has on other directories 1181 1517 # in a graphical way. The dependency relations are determined by the #include 1182 1518 # relations between the files in the directories. … … 1184 1520 DIRECTORY_GRAPH = YES 1185 1521 1186 # The DOT_IMAGE_FORMAT tag can be used to set the image format of the images 1522 # The DOT_IMAGE_FORMAT tag can be used to set the image format of the images 1187 1523 # generated by dot. Possible values are png, jpg, or gif 1188 1524 # If left blank png will be used. … … 1190 1526 DOT_IMAGE_FORMAT = png 1191 1527 1192 # The tag DOT_PATH can be used to specify the path where the dot tool can be 1528 # The tag DOT_PATH can be used to specify the path where the dot tool can be 1193 1529 # found. If left blank, it is assumed the dot tool can be found in the path. 1194 1530 1195 1531 DOT_PATH = @DOXYGEN_DOT_EXECUTABLE_PATH@ 1196 1532 1197 # The DOTFILE_DIRS tag can be used to specify one or more directories that 1198 # contain dot files that are included in the documentation (see the 1533 # The DOTFILE_DIRS tag can be used to specify one or more directories that 1534 # contain dot files that are included in the documentation (see the 1199 1535 # \dotfile command). 1200 1536 1201 1537 DOTFILE_DIRS = @CMAKE_CURRENT_SOURCE_DIR@/dot 1202 1538 1203 # The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the 1204 # graphs generated by dot. A depth value of 3 means that only nodes reachable 1205 # from the root by following a path via at most 3 edges will be shown. Nodes 1206 # that lay further from the root node will be omitted. Note that setting this 1207 # option to 1 or 2 may greatly reduce the computation time needed for large 1208 # code bases. Also note that a graph may be further truncated if the graph's 1209 # image dimensions are not sufficient to fit the graph (see MAX_DOT_GRAPH_WIDTH 1210 # and MAX_DOT_GRAPH_HEIGHT). If 0 is used for the depth value (the default), 1211 # the graph is not depth-constrained. 1539 # The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of 1540 # nodes that will be shown in the graph. If the number of nodes in a graph 1541 # becomes larger than this value, doxygen will truncate the graph, which is 1542 # visualized by representing a node as a red box. Note that doxygen if the 1543 # number of direct children of the root node in a graph is already larger than 1544 # DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note 1545 # that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. 1546 1547 DOT_GRAPH_MAX_NODES = 50 1548 1549 # The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the 1550 # graphs generated by dot. A depth value of 3 means that only nodes reachable 1551 # from the root by following a path via at most 3 edges will be shown. Nodes 1552 # that lay further from the root node will be omitted. Note that setting this 1553 # option to 1 or 2 may greatly reduce the computation time needed for large 1554 # code bases. Also note that the size of a graph can be further restricted by 1555 # DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. 1212 1556 1213 1557 MAX_DOT_GRAPH_DEPTH = 1000 1214 1558 1215 # Set the DOT_TRANSPARENT tag to YES to generate images with a transparent 1216 # background. This is disabled by default, which results in a white background.1217 # Warning: Depending on the platform used, enabling this option may lead to1218 # badly anti-aliased labels on the edges of a graph (i.e. they become hard to1219 # read).1559 # Set the DOT_TRANSPARENT tag to YES to generate images with a transparent 1560 # background. This is disabled by default, because dot on Windows does not 1561 # seem to support this out of the box. Warning: Depending on the platform used, 1562 # enabling this option may lead to badly anti-aliased labels on the edges of 1563 # a graph (i.e. they become hard to read). 1220 1564 1221 1565 DOT_TRANSPARENT = NO 1222 1566 1223 # Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output 1224 # files in one run (i.e. multiple -o and -T options on the command line). This 1225 # makes dot run faster, but since only newer versions of dot (>1.8.10) 1567 # Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output 1568 # files in one run (i.e. multiple -o and -T options on the command line). This 1569 # makes dot run faster, but since only newer versions of dot (>1.8.10) 1226 1570 # support this, this feature is disabled by default. 1227 1571 1228 1572 DOT_MULTI_TARGETS = NO 1229 1573 1230 # If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will 1231 # generate a legend page explaining the meaning of the various boxes and 1574 # If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will 1575 # generate a legend page explaining the meaning of the various boxes and 1232 1576 # arrows in the dot generated graphs. 1233 1577 1234 1578 GENERATE_LEGEND = YES 1235 1579 1236 # If the DOT_CLEANUP tag is set to YES (the default) Doxygen will 1237 # remove the intermediate dot files that are used to generate 1580 # If the DOT_CLEANUP tag is set to YES (the default) Doxygen will 1581 # remove the intermediate dot files that are used to generate 1238 1582 # the various graphs. 1239 1583 1240 1584 DOT_CLEANUP = YES 1241 1242 #---------------------------------------------------------------------------1243 # Configuration::additions related to the search engine1244 #---------------------------------------------------------------------------1245 1246 # The SEARCHENGINE tag specifies whether or not a search engine should be1247 # used. If set to NO the values of all tags below this one will be ignored.1248 1249 SEARCHENGINE = YES -
code/trunk/doc/api/main.dox
r6417 r7401 1 1 /** 2 @mainpage 3 Orxonox Doxygen Reference 2 @mainpage 3 4 @image html orxonox.jpg 5 6 This is the documentation of Orxonox. It contains descriptions of our classes and functions and 7 explains their usage with several examples and background information. Because Orxonox is so big, 8 we can't document all of our code - sorry for that! But we do your best to document the most 9 important parts of it, namely the @ref Core "core" and @ref Util "util" libraries, as well as the 10 central classes in the @ref Orxonox "orxonox" main library and some @ref Modules "modules". 11 12 To understand the connection between different classes in Orxonox, have a look at the 13 <a href="modules.html"><b>Modules section</b></a>. It contains a list of the most important topics 14 and groups files that contribute to the same feature. 4 15 */ -
code/trunk/src/CMakeLists.txt
r7224 r7401 116 116 ADD_SUBDIRECTORY(modules) 117 117 118 ################ Executable################118 ################## Executable ################### 119 119 120 120 INCLUDE_DIRECTORIES( … … 137 137 OUTPUT_NAME orxonox 138 138 ) 139 # Main executable should depend on all modules 140 ADD_DEPENDENCIES(orxonox-main ${ORXONOX_MODULES}) 139 141 140 142 # Get name to configure the run scripts … … 161 163 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/orxonox-main.vcproj.user.in" "${CMAKE_CURRENT_BINARY_DIR}/orxonox-main.vcproj.user") 162 164 ENDIF(MSVC) 165 166 #################### Doxygen #################### 167 168 # Prepare include paths for Doxygen. This is necessary to display 169 # the correct path to use when including a file, e.g. 170 # core/XMLPort.h instead of src/core/XMLPort.h 171 172 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/modules) 173 GET_DIRECTORY_PROPERTY(_temp INCLUDE_DIRECTORIES) 174 # Replace ';' by spaces 175 STRING(REPLACE ";" " " _temp "${_temp}") 176 SET(DOXYGEN_INCLUDE_DIRECTORIES "${_temp}" PARENT_SCOPE) -
code/trunk/src/OrxonoxConfig.h.in
r5695 r7401 145 145 * Options 146 146 *-------------------------------*/ 147 /** 148 @def ORXONOX_RELEASE 149 Enables expensive (build time) optimisations and disables certain features 150 */ 151 #cmakedefine ORXONOX_RELEASE 147 #cmakedefine ORXONOX_RELEASE ///< Enables expensive (build time) optimisations and disables certain features 152 148 153 149 -
code/trunk/src/SpecialConfig.h.in
r7380 r7401 42 42 #include "OrxonoxConfig.h" 43 43 44 /** 45 @def CEGUILUA_USE_INTERNAL_LIBRARY 46 Set whether we must suffix "ceguilua/" for the CEGUILua.h include 47 */ 48 #cmakedefine CEGUILUA_USE_INTERNAL_LIBRARY 44 #cmakedefine CEGUILUA_USE_INTERNAL_LIBRARY ///< Set whether we must suffix "ceguilua/" for the CEGUILua.h include 49 45 50 /** 51 @def DEPENDENCY_PACKAGE_ENABLE 52 Defined if a precompiled depdency package was used. We then copy all libraries 53 too when installing. 54 */ 55 #cmakedefine DEPENDENCY_PACKAGE_ENABLE 46 #cmakedefine DEPENDENCY_PACKAGE_ENABLE ///< Defined if a precompiled depdency package was used. We then copy all libraries too when installing. 56 47 57 /** 58 @def INSTALL_COPYABLE 59 Orxonox either gets installed to the system or just into a folder. 60 The latter uses relative paths. 61 */ 62 #cmakedefine INSTALL_COPYABLE 48 #cmakedefine INSTALL_COPYABLE ///< Orxonox either gets installed to the system or just into a folder. The latter uses relative paths. 63 49 64 /** 65 @def CMAKE_CONFIGURATION_TYPES 66 Using MSVC or XCode IDE 67 */ 68 #cmakedefine CMAKE_CONFIGURATION_TYPES 50 #cmakedefine CMAKE_CONFIGURATION_TYPES ///< Using MSVC or XCode IDE 69 51 70 52 // Handle default ConfigValues … … 125 107 } } 126 108 127 /** 128 @def ORXONOX_USE_WINMAIN 129 Use main() or WinMain()? 130 */ 131 #cmakedefine ORXONOX_USE_WINMAIN 109 #cmakedefine ORXONOX_USE_WINMAIN ///< Using MSVC or XCode IDE 132 110 133 111 #endif /* _SpecialConfig_H__ */ -
code/trunk/src/libraries/CMakeLists.txt
r5929 r7401 18 18 # 19 19 20 INCLUDE_DIRECTORIES( 21 ${CMAKE_SOURCE_DIR}/src/external 22 ${CMAKE_CURRENT_SOURCE_DIR} 23 ) 20 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) 24 21 25 22 ################ Sub Directories ################ -
code/trunk/src/libraries/core/BaseObject.cc
r7284 r7401 116 116 @brief XML loading and saving. 117 117 @param xmlelement The XML-element 118 @param loading Loading (true) or saving (false)118 @param mode The mode defines the operation that is being executed: loading or saving the object (from or to XML respectively) 119 119 */ 120 120 void BaseObject::XMLPort(Element& xmlelement, XMLPort::Mode mode) … … 141 141 @brief Defines the possible event states of this object and parses eventsources from an XML file. 142 142 @param xmlelement The XML-element 143 @param loading Loading (true) or saving (false)143 @param mode The mode defines the operation that is being executed: loading or saving the object (from or to XML respectively) 144 144 */ 145 145 void BaseObject::XMLEventPort(Element& xmlelement, XMLPort::Mode mode) -
code/trunk/src/libraries/core/BaseObject.h
r7284 r7401 28 28 29 29 /** 30 @defgroup BaseObject BaseObject 31 @ingroup Core 32 */ 33 34 /** 30 35 @file 31 @brief Definition of the BaseObject class. 36 @ingroup BaseObject 37 @brief Declaration of BaseObject, the base class of all objects in Orxonox. 32 38 33 39 The BaseObject is the parent of all classes representing an instance in the game. … … 53 59 class Level; 54 60 55 // !The BaseObject is the parent of all classes representing an instance in the game.61 /// The BaseObject is the parent of all classes representing an instance in the game. 56 62 class _CoreExport BaseObject : virtual public OrxonoxClass 57 63 { -
code/trunk/src/libraries/core/ClassFactory.h
r5929 r7401 29 29 /** 30 30 @file 31 @ingroup Object Factory 31 32 @brief Definition and implementation of the ClassFactory class 32 33 33 The ClassFactory is able to create new objects of a specific class .34 The ClassFactory is able to create new objects of a specific class which creates objects. 34 35 */ 35 36 … … 49 50 // ### Factory ### 50 51 // ########################### 51 // !Base-class of ClassFactory.52 /// Base-class of ClassFactory. 52 53 class _CoreExport Factory 53 54 { … … 60 61 // ### ClassFactory ### 61 62 // ############################### 62 // !The ClassFactory is able to create new objects of a specific class.63 /// The ClassFactory is able to create new objects of a specific class. 63 64 template <class T> 64 65 class ClassFactory : public Factory -
code/trunk/src/libraries/core/ClassTreeMask.cc
r7268 r7401 29 29 /** 30 30 @file 31 @brief Implementation of the ClassTreeMask, ClassTreeMaskNode and ClassTreeMaskIterator classes.31 @brief Implementation of the ClassTreeMask, ClassTreeMaskNode, and ClassTreeMaskIterator classes. 32 32 */ 33 33 … … 93 93 /** 94 94 @brief Adds a new subnode to the list of subnodes. 95 @param subnode The new subnode96 95 */ 97 96 void ClassTreeMaskNode::addSubnode(ClassTreeMaskNode* subnode) … … 178 177 /** 179 178 @brief Returns a pointer to the ClassTreeMaskNode whereon the iterator points. 180 @return The pointer to the node181 179 */ 182 180 ClassTreeMaskNode* ClassTreeMaskIterator::operator*() const … … 187 185 /** 188 186 @brief Returns a pointer to the ClassTreeMaskNode whereon the iterator points. 189 @return The pointer to the node190 187 */ 191 188 ClassTreeMaskNode* ClassTreeMaskIterator::operator->() const … … 196 193 /** 197 194 @brief Returns true if the stack is empty, meaning we've reached the end of the tree. 198 @return True if we've reached the end of the tree199 195 */ 200 196 ClassTreeMaskIterator::operator bool() const … … 205 201 /** 206 202 @brief Compares the current node with the given one and returns true if they match. 207 @param compare The node to compare with208 @return The result of the comparison (true if they match)209 203 */ 210 204 bool ClassTreeMaskIterator::operator==(ClassTreeMaskNode* compare) const … … 218 212 /** 219 213 @brief Compares the current node with the given one and returns true if they don't match. 220 @param compare The node to compare with221 @return The result of the comparison (true if they don't match)222 214 */ 223 215 bool ClassTreeMaskIterator::operator!=(ClassTreeMaskNode* compare) const … … 242 234 243 235 /** 244 @brief Copyconstructor: Adds the root-node of the tree with the first rule ("include everything") and adds all rules from the other mask. 245 @param other The other mask 236 @brief Copy-constructor: Adds the root-node of the tree with the first rule ("include everything") and adds all rules from the other mask. 246 237 */ 247 238 ClassTreeMask::ClassTreeMask(const ClassTreeMask& other) -
code/trunk/src/libraries/core/ClassTreeMask.h
r7268 r7401 29 29 /** 30 30 @file 31 @brief Definition of the ClassTreeMask, ClassTreeMaskNode and ClassTreeMaskIterator classes. 32 33 ClassTreeMask is a class to define a mask of the class-tree beginning with BaseObject. 31 @ingroup Class 32 @brief Declaration of the ClassTreeMask, ClassTreeMaskNode, and ClassTreeMaskIterator classes. 33 34 ClassTreeMask is a class to define a mask of the class-tree beginning with orxonox::BaseObject. 34 35 You can include or exclude classes by calling the corresponding functions with the 35 Identifier of the class. 36 orxonox::Identifier of the class. This mask can then be used to filter out objects that 37 are instances of classes which aren't included in the tree, for example when Loading a 38 level file or if a Trigger should be triggered by only a few classes. 39 40 See the description of orxonox::ClassTreeMask for a short example. 36 41 37 42 You can work with a ClassTreeMask in the sense of the set-theory, meaning that you can create 38 43 unions, intersections, complements and differences by using overloaded operators. 39 44 40 45 @par Tree structure 41 46 42 47 The ClassTreeMask is internally represented by a tree. The nodes in the tree are … … 45 50 nodes changing the mask. By adding new rules, the tree gets reordered dynamically. 46 51 47 Adding a new rule overwrites all rules assigned to inherited classes. Use overwrite = false52 Adding a new rule overwrites all rules assigned to inherited classes. Use <tt>overwrite = false</tt> 48 53 if you don't like this feature. Useless rules that don't change the information of the mask 49 aren't saved in the internal tree. Use clean = false if you wan't to save them. 50 51 With overwrite = false and clean = false it doesn't matter in which way you create the mask. 52 You can manually drop useless rules from the tree by calling clean(). 53 54 55 56 Because of the complicated shape of the internal tree, there is an iterator to iterate 57 through all ClassTreeMaskNodes of a mask. It starts with the BaseObject and moves on to 58 the first subclass until it reaches a leaf of the tree. Then the iterator moves one step 59 back and iterates to the second subclass. If there are no more subclasses, it steps another 60 step back, and so on. 61 62 Example: A and B are children of BaseObject, A1 and A2 are children of A, B1 and B2 are children of B. 63 The ClassTreeMaskIterator would move trough the tree in the following order: 64 BaseObject, A, A1, A2, B, B1, B2. 65 66 Note that the iterator doesn't move trough the whole class-tree, but only through the 67 internal tree of the mask, containing the minimal needed set of nodes to describe the mask. 54 aren't saved in the internal tree. Use <tt>clean = false</tt> if you still want to save them. 55 56 With <tt>overwrite = false</tt> and <tt>clean = false</tt> it doesn't matter in which order 57 you create the mask. You can manually drop useless rules from the tree by calling 58 @ref orxonox::ClassTreeMask::clean() "clean()". 59 60 @par Objects 61 62 To iterate through all objects of the classes that were included by a ClassTreeMask, 63 use orxonox::ClassTreeMaskObjectIterator. The description of this class also contains 64 a short example of how to use it. 68 65 */ 69 66 … … 83 80 // ### ClassTreeMaskNode ### 84 81 // ################################### 85 //! The ClassTreeMaskNode is a node in the internal tree of the ClassTreeMask, containing the rules of the mask.86 82 /** 83 @brief The ClassTreeMaskNode is a node in the internal tree of the ClassTreeMask, containing the rules of the mask. 84 87 85 The ClassTreeMaskNode is used to store the rule (included or excluded) for a given 88 86 class (described by the corresponding Identifier). The nodes are used in the internal … … 105 103 void addSubnode(ClassTreeMaskNode* subnode); 106 104 107 / ** @brief Tells if the rule is "included" or not. @return The rule: true = included, false = excluded */105 /// Tells if the rule is "included" or not. 108 106 inline bool isIncluded() const { return this->bIncluded_; } 109 / ** @brief Tells if the rule is "excluded" or not. @return The inverted rule: true = excluded, false = included */107 /// Tells if the rule is "excluded" or not. 110 108 inline bool isExcluded() const { return (!this->bIncluded_); } 111 109 112 / ** @brief Returns the Identifier of the class the rule refers to. @return The Identifier representing the class */110 /// Returns the Identifier of the class the rule refers to. 113 111 inline const Identifier* getClass() const { return this->subclass_; } 114 112 115 / ** @brief Returns true if the Node has some subnodes. */113 /// Returns true if the node has some subnodes. 116 114 inline bool hasSubnodes() const { return !this->subnodes_.empty(); } 117 115 … … 119 117 void deleteAllSubnodes(); 120 118 121 const Identifier* subclass_; // !< The Identifier of the subclass the rule refers to122 bool bIncluded_; // !< The rule: included or excluded123 std::list<ClassTreeMaskNode*> subnodes_; // !< A list containing all subnodes in the tree119 const Identifier* subclass_; ///< The Identifier of the subclass the rule refers to 120 bool bIncluded_; ///< The rule: included or excluded 121 std::list<ClassTreeMaskNode*> subnodes_; ///< A list containing all subnodes of this node 124 122 }; 125 123 … … 128 126 // ### ClassTreeMaskIterator ### 129 127 // ################################### 130 //! The ClassTreeMaskIterator moves through all ClassTreeMaskNodes of the internal tree of a ClassTreeMask, containing the rules.131 128 /** 129 @brief The ClassTreeMaskIterator moves through all ClassTreeMaskNodes of the internal tree of a ClassTreeMask which contains the rules. 130 132 131 Because of the complicated shape of the internal rule-tree of ClassTreeMask, an 133 132 iterator is used to move through all nodes of the tree. It starts with the BaseObject … … 135 134 iterator moves one step back and iterates to the second subclass. If there are no more 136 135 subclasses, it steps another step back, and so on. 136 137 Example: A and B are children of BaseObject, A1 and A2 are children of A, B1 and B2 are children of B. 138 The ClassTreeMaskIterator would move trough the tree in the following order: 139 BaseObject, A, A1, A2, B, B1, B2. 140 141 Note that the iterator doesn't move trough the whole class-tree, but only through the 142 internal tree of the mask, containing the minimal needed set of nodes to describe the mask. 137 143 */ 138 144 class _CoreExport ClassTreeMaskIterator … … 150 156 151 157 private: 152 std::stack<std::pair<std::list<ClassTreeMaskNode*>::iterator, std::list<ClassTreeMaskNode*>::iterator> > nodes_; // !< A stack to store list-iterators153 std::list<ClassTreeMaskNode*> rootlist_; // !< A list for internal use (it only stores the root-node)158 std::stack<std::pair<std::list<ClassTreeMaskNode*>::iterator, std::list<ClassTreeMaskNode*>::iterator> > nodes_; ///< A stack to store list-iterators 159 std::list<ClassTreeMaskNode*> rootlist_; ///< A list for internal use (it only stores the root-node) 154 160 }; 155 161 … … 158 164 // ### ClassTreeMask ### 159 165 // ################################### 160 //! The ClassTreeMask is a set of rules, containing the information for each class whether it's included or not.161 166 /** 167 @brief The ClassTreeMask is a set of rules, containing the information for each class whether it's included or not. 168 162 169 With a ClassTreeMask, you can include or exclude subtrees of the class-tree, starting 163 170 with a given subclass, described by the corresponding Identifier. To minimize the size 164 171 of the mask, the mask saves only relevant rules. But you can manually add rules that 165 don't change the information of the mask by using clean = false. If you want to drop172 don't change the information of the mask by using <tt>clean = false</tt>. If you want to drop 166 173 useless rules, call the clean() function. 174 175 Example: 176 @code 177 ClassTreeMask mymask; 178 mymask.exclude(Class(A)); 179 mymask.exclude(Class(B)); 180 mymask.include(Class(ChildOfA)); 181 @endcode 182 183 In this example, the classes A and B are excluded from the mask, but one of the child 184 classes of A is included again. 167 185 */ 168 186 class _CoreExport ClassTreeMask … … 189 207 bool isExcluded(const Identifier* subclass) const; 190 208 191 / ** @brief Begin of the ClassTreeMaskObjectIterator. */209 /// Begin of the ClassTreeMaskObjectIterator. 192 210 inline const ClassTreeMask& begin() const { return (*this); } 193 / ** @brief End of the ClassTreeMaskObjectIterator. */211 /// End of the ClassTreeMaskObjectIterator. 194 212 inline BaseObject* end() const { return 0; } 195 213 … … 228 246 bool nodeExists(const Identifier* subclass); 229 247 230 ClassTreeMaskNode* root_; // !< The root-node of the internal rule-tree, usually BaseObject248 ClassTreeMaskNode* root_; ///< The root-node of the internal rule-tree, usually BaseObject 231 249 }; 232 250 … … 235 253 // ### ClassTreeMaskObjectIterator ### 236 254 // ################################### 237 //! The ClassTreeMaskObjectIterator iterates through all objects of all classes, included by a ClassTreeMask.238 255 /** 239 The ClassTreeMaskObjectIterator iterates through all objects of all classes, 240 included by a ClassTreeMask. This is done the following way: 241 256 @brief The ClassTreeMaskObjectIterator iterates through all objects of the classes that were included by a ClassTreeMask. 257 258 This is done the following way: 259 @code 242 260 ClassTreeMask mask; 243 261 for (ClassTreeMaskObjectIterator it = mask.begin(); it != mask.end(); ++it) 244 262 it->doSomething(); 245 246 Note: The ClassTreeMaskObjectIterator handles all objects as BaseObjects. If 263 @endcode 264 265 @note The ClassTreeMaskObjectIterator handles all objects as BaseObjects. If 247 266 you want to use another class, you should use a dynamic_cast. 248 267 249 Performance of ClassTreeMaskObjectIterator is good as long as you don't exclude268 The performance of ClassTreeMaskObjectIterator is good as long as you don't exclude 250 269 subclasses of included classes. Of course you can still exlucde subclasses, but 251 270 if this is done more often, we need a new implementation using a second ObjectList … … 255 274 { 256 275 public: 257 / ** @brief Defaultconstructor: Does nothing. */276 /// Default-constructor: Does nothing. 258 277 inline ClassTreeMaskObjectIterator() {} 259 / ** @brief Constructor: Initializes the iterator from a given ClassTreeMask. @param mask The mask */278 /// Copy-Constructor: Initializes the iterator from another ClassTreeMask. 260 279 inline ClassTreeMaskObjectIterator(const ClassTreeMask& mask) { (*this) = mask; } 261 280 … … 264 283 const ClassTreeMaskObjectIterator& operator++(); 265 284 266 / ** @brief Returns true if the ClassTreeMaskObjectIterator points at the given object. @param pointer The pointer of the object */285 /// Returns true if the ClassTreeMaskObjectIterator points at the given object. 267 286 inline bool operator==(BaseObject* pointer) const { return (this->objectIterator_ && (*this->objectIterator_) == pointer) || (!this->objectIterator_ && pointer == 0); } 268 / ** @brief Returns true if the ClassTreeMaskObjectIterator doesn't point at the given object. @param pointer The pointer of the object */287 /// Returns true if the ClassTreeMaskObjectIterator doesn't point at the given object. 269 288 inline bool operator!=(BaseObject* pointer) const { return (this->objectIterator_ && (*this->objectIterator_) != pointer) || (!this->objectIterator_ && pointer != 0); } 270 / ** @brief Returns true if the ClassTreeMaskObjectIterator hasn't already reached the end. */289 /// Returns true if the ClassTreeMaskObjectIterator hasn't already reached the end. 271 290 inline operator bool() const { return (this->objectIterator_); } 272 / ** @brief Returns the object the ClassTreeMaskObjectIterator currently points at. */291 /// Returns the object the ClassTreeMaskObjectIterator currently points at. 273 292 inline BaseObject* operator*() const { return (*this->objectIterator_); } 274 / ** @brief Returns the object the ClassTreeMaskObjectIterator currently points at. */293 /// Returns the object the ClassTreeMaskObjectIterator currently points at. 275 294 inline BaseObject* operator->() const { return (*this->objectIterator_); } 276 295 … … 278 297 void create(ClassTreeMaskNode* node); 279 298 280 std::list<std::pair<const Identifier*, bool> > subclasses_; // !< A list of all Identifiers through which objects the iterator should iterate281 std::list<std::pair<const Identifier*, bool> >::iterator subclassIterator_; // !< The current class of the iterator282 Iterator<BaseObject> objectIterator_; // !< The current object of the iterator299 std::list<std::pair<const Identifier*, bool> > subclasses_; ///< A list of all Identifiers through which objects the iterator should iterate 300 std::list<std::pair<const Identifier*, bool> >::iterator subclassIterator_; ///< The current class of the iterator 301 Iterator<BaseObject> objectIterator_; ///< The current object of the iterator 283 302 }; 284 303 } -
code/trunk/src/libraries/core/CommandLineParser.cc
r7284 r7401 126 126 @param arguments 127 127 Vector of space separated strings. 128 @param bParsingFile 129 Parsing a file or the command line itself 128 130 */ 129 131 void CommandLineParser::_parse(const std::vector<std::string>& arguments, bool bParsingFile) … … 244 246 @param value 245 247 String containing the value 248 @param bParsingFile 249 Parsing a file or the command line itself 246 250 */ 247 251 void CommandLineParser::checkFullArgument(const std::string& name, const std::string& value, bool bParsingFile) … … 258 262 Parses an argument based on its shortcut. 259 263 @param shortcut 260 Sho tcut to the argument264 Shortcut to the argument 261 265 @param value 262 266 String containing the value 267 @param bParsingFile 268 Parsing a file or the command line itself 263 269 */ 264 270 void CommandLineParser::checkShortcut(const std::string& shortcut, const std::string& value, bool bParsingFile) … … 308 314 } 309 315 316 void CommandLineParser::generateDoc(std::ofstream& file) 317 { 318 file << "/** @page cmdargspage Command Line Arguments Reference" << endl; 319 file << " @verbatim"; /*no endl*/ 320 file << getUsageInformation(); /*no endl*/ 321 file << " @endverbatim" << endl; 322 file << "*/" << endl; 323 } 324 310 325 /** 311 326 @brief … … 313 328 The method throws an exception if 'name' was not found or the value could not be converted. 314 329 @note 315 You sho ld of course not call this method before the command line has been parsed.330 You should of course not call this method before the command line has been parsed. 316 331 */ 317 332 const CommandLineArgument* CommandLineParser::getArgument(const std::string& name) -
code/trunk/src/libraries/core/CommandLineParser.h
r7284 r7401 27 27 */ 28 28 29 /** 30 @defgroup CmdArgs Commandline arguments 31 @ingroup Config 32 @brief For a reference of all commandline arguments see @ref cmdargspage 33 */ 34 35 /** 36 @file 37 @ingroup Config CmdArgs 38 @brief Declaration of CommandLineParser and CommandLineArgument, definition of the SetCommandLineArgument() macros. 39 */ 40 29 41 #ifndef _CommandLine_H__ 30 42 #define _CommandLine_H__ … … 32 44 #include "CorePrereqs.h" 33 45 46 #include <fstream> 34 47 #include <map> 35 48 #include "util/OrxAssert.h" … … 165 178 static void destroyAllArguments(); 166 179 180 static void generateDoc(std::ofstream& file); 181 167 182 private: 168 183 //! Constructor initialises bFirstTimeParse_ with true. … … 207 222 @param defaultValue 208 223 Default value that is used when argument was not given. 224 @param bCommandLineOnly 225 Parsing a file or the command line itself 209 226 */ 210 227 template <class T> -
code/trunk/src/libraries/core/ConfigFileManager.cc
r7284 r7401 27 27 */ 28 28 29 /** 30 @file 31 @brief Implementation of ConfigFileManager and its helper classes. 32 */ 33 29 34 #include "ConfigFileManager.h" 30 35 … … 43 48 // ConfigFileEntryValue // 44 49 ////////////////////////// 45 50 /** 51 @brief Updates the string that will be stored in the file after one of it's components (name, value, comment) has changed. 52 */ 46 53 void ConfigFileEntryValue::update() 47 54 { … … 63 70 // ConfigFileEntryVectorValue // 64 71 //////////////////////////////// 72 /** 73 @brief Updates the string that will be stored in the file after one of it's components (name, value, index, comment) has changed. 74 */ 65 75 void ConfigFileEntryVectorValue::update() 66 76 { … … 73 83 // ConfigFileSection // 74 84 /////////////////////// 85 /** 86 @brief Destructor: Deletes all entries. 87 */ 75 88 ConfigFileSection::~ConfigFileSection() 76 89 { … … 79 92 } 80 93 94 /** 95 @brief Deletes all elements of a config vector if their index is greater or equal to @a startindex. 96 97 @param name The name of the vector 98 @param startindex The index of the first element that will be deleted 99 */ 81 100 void ConfigFileSection::deleteVectorEntries(const std::string& name, unsigned int startindex) 82 101 { … … 95 114 } 96 115 116 /** 117 @brief Returns the size of a config vector. 118 @param name The name of the vector 119 */ 97 120 unsigned int ConfigFileSection::getVectorSize(const std::string& name) const 98 121 { … … 108 131 } 109 132 133 /** 134 @brief Returns the title and comment of the section as it will be stored in the file. 135 */ 110 136 std::string ConfigFileSection::getFileEntry() const 111 137 { … … 116 142 } 117 143 144 /** 145 @brief Returns the entry with given name (or NULL if it doesn't exist). 146 147 @param name The name of the entry 148 */ 118 149 ConfigFileEntry* ConfigFileSection::getEntry(const std::string& name) const 119 150 { … … 126 157 } 127 158 159 /** 160 @brief Returns the entry of a vector element with given name and index (or NULL if it doesn't exist). 161 162 @param name The name of the vector 163 @param index The index of the element in the vector 164 */ 128 165 ConfigFileEntry* ConfigFileSection::getEntry(const std::string& name, unsigned int index) const 129 166 { … … 136 173 } 137 174 175 /** 176 @brief Returns the iterator to the entry with given name. If the entry doesn't exist, it is created using the fallback value. 177 178 @param name The name of the entry 179 @param fallback The value that will be used if the entry doesn't exist 180 @param bString If true, the value is treated as string which means some special treatment of special characters. 181 */ 138 182 std::list<ConfigFileEntry*>::iterator ConfigFileSection::getOrCreateEntryIterator(const std::string& name, const std::string& fallback, bool bString) 139 183 { … … 152 196 } 153 197 198 /** 199 @brief Returns the iterator to the entry of a vector element with given name and index. If the entry doesn't exist, it is created using the fallback value. 200 201 @param name The name of the vector 202 @param index The index of the element in the vector 203 @param fallback The value that will be used if the entry doesn't exist 204 @param bString If true, the value is treated as string which means some special treatment of special characters. 205 */ 154 206 std::list<ConfigFileEntry*>::iterator ConfigFileSection::getOrCreateEntryIterator(const std::string& name, unsigned int index, const std::string& fallback, bool bString) 155 207 { … … 178 230 const char* ConfigFile::DEFAULT_CONFIG_FOLDER = "defaultConfig"; 179 231 232 /** 233 @brief Constructor: Initializes the config file. 234 @param filename The file-name of this config file 235 @param bCopyFallbackFile If true, the default config file is copied into the config-directory before loading the file 236 */ 180 237 ConfigFile::ConfigFile(const std::string& filename, bool bCopyFallbackFile) 181 238 : filename_(filename) … … 185 242 } 186 243 244 /** 245 @brief Destructor: Deletes all sections and entries. 246 */ 187 247 ConfigFile::~ConfigFile() 188 248 { … … 190 250 } 191 251 252 /** 253 @brief Loads the config file from the hard-disk and reads the sections and their values. 254 */ 192 255 void ConfigFile::load() 193 256 { … … 318 381 } 319 382 383 /** 384 @brief Writes the sections and values to the hard-disk. 385 */ 320 386 void ConfigFile::save() const 321 387 { … … 323 389 } 324 390 391 /** 392 @brief Writes the sections and values to a given file on the hard-disk. 393 */ 325 394 void ConfigFile::saveAs(const std::string& filename) const 326 395 { … … 354 423 } 355 424 425 /** 426 @brief Deletes all sections (which again delete all their values) and clears the list of sections. 427 */ 356 428 void ConfigFile::clear() 357 429 { … … 361 433 } 362 434 363 const std::string& ConfigFile::getOrCreateValue(const std::string& section, const std::string& name, const std::string& fallback, bool bString) 364 { 365 const std::string& output = this->getOrCreateSection(section)->getOrCreateValue(name, fallback, bString); 366 this->saveIfUpdated(); 367 return output; 368 } 369 370 const std::string& ConfigFile::getOrCreateValue(const std::string& section, const std::string& name, unsigned int index, const std::string& fallback, bool bString) 371 { 372 const std::string& output = this->getOrCreateSection(section)->getOrCreateValue(name, index, fallback, bString); 373 this->saveIfUpdated(); 374 return output; 375 } 376 435 /** 436 @brief Deletes all elements of a config vector if their index is greater or equal to @a startindex. 437 438 @param section The name of the section 439 @param name The name of the vector 440 @param startindex The index of the first element that will be deleted 441 */ 377 442 void ConfigFile::deleteVectorEntries(const std::string& section, const std::string& name, unsigned int startindex) 378 443 { … … 384 449 } 385 450 451 /** 452 @brief Returns a pointer to the section with given name (or NULL if the section doesn't exist). 453 */ 386 454 ConfigFileSection* ConfigFile::getSection(const std::string& section) const 387 455 { … … 392 460 } 393 461 462 /** 463 @brief Returns a pointer to the section with given name. If it doesn't exist, the section is created. 464 */ 394 465 ConfigFileSection* ConfigFile::getOrCreateSection(const std::string& section) 395 466 { … … 403 474 } 404 475 476 /** 477 @brief Saves the config file if it was updated (or if any of its sections were updated). 478 */ 405 479 void ConfigFile::saveIfUpdated() 406 480 { … … 442 516 SettingsConfigFile* SettingsConfigFile::singletonPtr_s = 0; 443 517 518 /** 519 @brief Constructor: Activates the console commands. 520 */ 444 521 SettingsConfigFile::SettingsConfigFile(const std::string& filename) 445 522 : ConfigFile(filename) … … 452 529 } 453 530 531 /** 532 @brief Destructor: Deactivates the console commands. 533 */ 454 534 SettingsConfigFile::~SettingsConfigFile() 455 535 { … … 461 541 } 462 542 543 /** 544 @brief Loads the config file and updates the @ref ConfigValueContainer "config value containers". 545 */ 463 546 void SettingsConfigFile::load() 464 547 { … … 467 550 } 468 551 552 /** 553 @brief Changes the file-name. 554 */ 469 555 void SettingsConfigFile::setFilename(const std::string& filename) 470 556 { … … 472 558 } 473 559 560 /** 561 @brief Registers a new @ref ConfigValueContainer "config value container". 562 */ 474 563 void SettingsConfigFile::addConfigValueContainer(ConfigValueContainer* container) 475 564 { … … 481 570 } 482 571 572 /** 573 @brief Unregisters a @ref ConfigValueContainer "config value container". 574 */ 483 575 void SettingsConfigFile::removeConfigValueContainer(ConfigValueContainer* container) 484 576 { … … 500 592 } 501 593 594 /** 595 @brief Updates all @ref ConfigValueContainer "config value containers". 596 */ 502 597 void SettingsConfigFile::updateConfigValues() 503 598 { 599 // todo: can this be done more efficiently? looks like some identifiers will be updated multiple times. 600 504 601 for (ContainerMap::const_iterator it = this->containers_.begin(); it != this->containers_.end(); ++it) 505 602 { … … 509 606 } 510 607 608 /** 609 @brief Removes entries and sections from the file that don't exist anymore (i.e. if there's no corresponding @ref ConfigValueContainer "config value container"). 610 @param bCleanComments If true, comments are also removed from the file 611 */ 511 612 void SettingsConfigFile::clean(bool bCleanComments) 512 613 { … … 558 659 } 559 660 661 /** 662 @brief Console-command: Changes the value of an entry and stores it the file. 663 664 @param section The section of the config value 665 @param entry The name of the config value 666 @param value The new value 667 */ 560 668 void SettingsConfigFile::config(const std::string& section, const std::string& entry, const std::string& value) 561 669 { … … 564 672 } 565 673 674 /** 675 @brief Console-command: Changes the value of an entry, but doesn't store it in the file (it's only a temporary change). 676 677 @param section The section of the config value 678 @param entry The name of the config value 679 @param value The new value 680 */ 566 681 void SettingsConfigFile::tconfig(const std::string& section, const std::string& entry, const std::string& value) 567 682 { … … 570 685 } 571 686 687 /** 688 @brief Changes the value of an entry, depending on @a function, either by using "set" or "tset" 689 690 @param section The section of the config value 691 @param entry The name of the config value 692 @param value The new value 693 @param function The function ("set" or "tset") that will be used to change the value. 694 */ 572 695 bool SettingsConfigFile::configImpl(const std::string& section, const std::string& entry, const std::string& value, bool (ConfigValueContainer::*function)(const MultiType&)) 573 696 { … … 586 709 } 587 710 711 /** 712 @brief Console-command: Returns the value of a given entry. 713 714 @param section The section of the config value 715 @param entry The name of the config value 716 */ 588 717 std::string SettingsConfigFile::getConfig(const std::string& section, const std::string& entry) 589 718 { … … 611 740 ConfigFileManager* ConfigFileManager::singletonPtr_s = 0; 612 741 742 /// Constructor: Initializes the array of config files with NULL. 613 743 ConfigFileManager::ConfigFileManager() 614 744 { … … 616 746 } 617 747 748 /// Destructor: Deletes the config files. 618 749 ConfigFileManager::~ConfigFileManager() 619 750 { … … 623 754 } 624 755 756 /// Defines the file-name for the config file of a given type (settings, calibration, etc.). 625 757 void ConfigFileManager::setFilename(ConfigFileType::Value type, const std::string& filename) 626 758 { -
code/trunk/src/libraries/core/ConfigFileManager.h
r7284 r7401 27 27 */ 28 28 29 /** 30 @file 31 @ingroup Config ConfigFile 32 @brief Declaration of ConfigFileManager and its helper classes, used to load and save config files. 33 */ 34 29 35 #ifndef _ConfigFileManager_H__ 30 36 #define _ConfigFileManager_H__ … … 46 52 // ConfigFileEntry // 47 53 ///////////////////// 54 /** 55 @brief This class represents an entry in the config file. 56 57 This class is pure virtual. Use one of the derived classes to define the type of the entry. 58 */ 48 59 class _CoreExport ConfigFileEntry 49 60 { 50 61 public: 62 /// Destructor 51 63 virtual ~ConfigFileEntry() {}; 64 65 /// Changes the value of the entry. 52 66 virtual void setValue(const std::string& value) = 0; 67 /// Returns the value of the entry. 53 68 virtual const std::string& getValue() const = 0; 69 70 /// Returns the name of the entry 54 71 virtual const std::string& getName() const = 0; 72 73 /// Changes the comment of the entry (will be placed after the value) 55 74 virtual void setComment(const std::string& comment) = 0; 75 76 /// Returns the index of the entry in a vector (used only if it is a vector) 56 77 virtual unsigned int getIndex() const { return 0; } 78 79 /// Defines if this entry is treated as string which means some special treatment of special characters. 57 80 virtual void setString(bool bString) = 0; 81 82 /// Returns the line as it will be stored in the config file. 58 83 virtual const std::string& getFileEntry() const = 0; 59 84 }; … … 63 88 // ConfigFileEntryValue // 64 89 ////////////////////////// 90 /** 91 @brief This class represents a normal value in the config file. 92 */ 65 93 class _CoreExport ConfigFileEntryValue : public ConfigFileEntry 66 94 { 67 95 public: 96 /** 97 @brief Constructor: Initializes the entry. 98 99 @param name The name of the entry 100 @param value The value of the entry 101 @param bString If true, the value is treated as string which means some special treatment of special characters. 102 @param additionalComment An optional comment that will be placed behind the value in the config file 103 */ 68 104 inline ConfigFileEntryValue(const std::string& name, const std::string& value = "", bool bString = false, const std::string& additionalComment = "") 69 105 : name_(name) … … 73 109 { this->update(); } 74 110 111 /// Destructor 75 112 inline virtual ~ConfigFileEntryValue() {} 76 113 … … 92 129 { return this->fileEntry_; } 93 130 131 /// Returns the "key" of the value (in this case it's just the name of the entry, but for vectors it's different) 94 132 inline virtual const std::string& getKeyString() const 95 133 { return this->name_; } … … 98 136 virtual void update(); 99 137 100 const std::string name_; 101 std::string value_; 102 std::string additionalComment_; 103 std::string fileEntry_; 104 bool bString_; 138 const std::string name_; ///< The name of the value 139 std::string value_; ///< The value 140 std::string additionalComment_; ///< The additional comment 141 std::string fileEntry_; ///< The string as it will be stored in the config file 142 bool bString_; ///< If true, the value is treated as string which means some special treatment of special characters. 105 143 }; 106 144 … … 109 147 // ConfigFileEntryVectorValue // 110 148 //////////////////////////////// 149 /** 150 @brief Subclass of ConfigFileEntryValue, represents an element of a vector. 151 */ 111 152 class _CoreExport ConfigFileEntryVectorValue : public ConfigFileEntryValue 112 153 { 113 154 public: 155 /** 156 @brief Constructor: Initializes the entry. 157 158 @param name The name of the vector 159 @param index The index of the element in the vector 160 @param value The value of the element 161 @param bString If true, the value is treated as string which means some special treatment of special characters. 162 @param additionalComment An optional comment that will be placed behind the value in the config file 163 */ 114 164 inline ConfigFileEntryVectorValue(const std::string& name, unsigned int index, const std::string& value = "", bool bString = false, const std::string& additionalComment = "") 115 165 : ConfigFileEntryValue(name, value, bString, additionalComment) … … 117 167 { this->update(); /*No virtual calls in base class ctor*/ } 118 168 169 /// Destructor 119 170 inline ~ConfigFileEntryVectorValue() {} 120 171 … … 122 173 { return this->index_; } 123 174 175 /// Returns the "key" of the value (the name of the vector plus the index of the element) 124 176 inline const std::string& getKeyString() const 125 177 { return this->keyString_; } … … 128 180 void update(); 129 181 130 unsigned int index_; 131 std::string keyString_; 182 unsigned int index_; ///< The index of the element in the vector 183 std::string keyString_; ///< The full name of the entry (the name of the vector plus the index of the element) 132 184 }; 133 185 … … 136 188 // ConfigFileEntryComment // 137 189 //////////////////////////// 190 /** 191 @brief This class represents a line in the config file which contains only a comment. 192 */ 138 193 class _CoreExport ConfigFileEntryComment : public ConfigFileEntry 139 194 { 140 195 public: 196 /// Constructor: Initializes the object. 141 197 inline ConfigFileEntryComment(const std::string& comment) : comment_(comment) {} 198 199 /// Destructor 142 200 inline virtual ~ConfigFileEntryComment() {} 143 201 … … 159 217 { return this->comment_; } 160 218 161 inline virtual const std::string& getKeyString() const162 { return BLANKSTRING; }163 164 219 private: 165 std::string comment_; 220 std::string comment_; ///< The comment 166 221 }; 167 222 … … 170 225 // ConfigFileSection // 171 226 /////////////////////// 227 /** 228 @brief Represents a section in a config file. 229 230 A section has a name and a list of config values. 231 */ 172 232 class _CoreExport ConfigFileSection 173 233 { … … 176 236 177 237 public: 238 /** 239 @brief Constructor: Initializes the section. 240 241 @param name The name of the section 242 @param additionalComment An additional comment placed after the title of the section in the config file 243 */ 178 244 inline ConfigFileSection(const std::string& name, const std::string& additionalComment = "") 179 245 : name_(name) … … 183 249 ~ConfigFileSection(); 184 250 251 /// Returns the name of the section. 185 252 inline const std::string& getName() const 186 253 { return this->name_; } 187 254 255 /// Changes the comment which is placed after the title of the section in the config file. 188 256 inline void setComment(const std::string& comment) 189 257 { this->additionalComment_ = comment; } 190 258 259 /** 260 @brief Stores a value in the section. If the entry doesn't exist, it's created. 261 262 @param name The name of the entry 263 @param value The new value 264 @param bString If true, the value is treated as string which means some special treatment of special characters. 265 */ 191 266 inline void setValue(const std::string& name, const std::string& value, bool bString) 192 267 { this->getOrCreateEntry(name, value, bString)->setValue(value); } 268 /** 269 @brief Returns the value of a given entry in the section. Returns a blank string if the value doesn't exist. 270 271 @param name The name of the entry 272 @param bString If true, the value is treated as string which means some special treatment of special characters. 273 */ 193 274 inline const std::string& getValue(const std::string& name, bool bString) 194 275 { … … 196 277 if (entry) 197 278 { 198 entry->setString(bString); 279 entry->setString(bString); // if the entry was loaded from the config file, we have to tell it if it's a string 199 280 return entry->getValue(); 200 281 } 201 282 return BLANKSTRING; 202 283 } 284 /** 285 @brief Returns the value of a given entry in the section. If it doesn't exist, the entry is created using the fallback value. 286 287 @param name The name of the entry 288 @param fallback The value that will be used if the entry doesn't exist 289 @param bString If true, the value is treated as string which means some special treatment of special characters. 290 */ 203 291 inline const std::string& getOrCreateValue(const std::string& name, const std::string& fallback, bool bString) 204 292 { return this->getOrCreateEntry(name, fallback, bString)->getValue(); } 205 293 294 /** 295 @brief Stores the value of an element of a vector in the section. If the entry doesn't exist, it's created. 296 297 @param name The name of the vector 298 @param index The index of the element in the vector 299 @param value The new value 300 @param bString If true, the value is treated as string which means some special treatment of special characters. 301 */ 206 302 inline void setValue(const std::string& name, unsigned int index, const std::string& value, bool bString) 207 303 { this->getOrCreateEntry(name, index, value, bString)->setValue(value); } 304 /** 305 @brief Returns the value of a given element of a vector in the section. Returns a blank string if the value doesn't exist. 306 307 @param name The name of the vector 308 @param index The index of the element in the vector 309 @param bString If true, the value is treated as string which means some special treatment of special characters. 310 */ 208 311 inline const std::string& getValue(const std::string& name, unsigned int index, bool bString) 209 312 { … … 211 314 if (entry) 212 315 { 213 entry->setString(bString); 316 entry->setString(bString); // if the entry was loaded from the config file, we have to tell it if it's a string 214 317 return entry->getValue(); 215 318 } 216 319 return BLANKSTRING; 217 320 } 321 /** 322 @brief Returns the value of a given element of a vector in the section. If it doesn't exist, the entry is created using the fallback value. 323 324 @param name The name of the vector 325 @param index The index of the element in the vector 326 @param fallback The value that will be used if the entry doesn't exist 327 @param bString If true, the value is treated as string which means some special treatment of special characters. 328 */ 218 329 inline const std::string& getOrCreateValue(const std::string& name, unsigned int index, const std::string& fallback, bool bString) 219 330 { return this->getOrCreateEntry(name, index, fallback, bString)->getValue(); } … … 225 336 226 337 private: 338 /// Returns the list of entries in this section. 227 339 std::list<ConfigFileEntry*>& getEntries() 228 340 { return this->entries_; } 341 /// Returns the begin-iterator of the list of entries in this section. 229 342 std::list<ConfigFileEntry*>::const_iterator getEntriesBegin() const 230 343 { return this->entries_.begin(); } 344 /// Returns the end-iterator of the list of entries in this section. 231 345 std::list<ConfigFileEntry*>::const_iterator getEntriesEnd() const 232 346 { return this->entries_.end(); } … … 236 350 237 351 ConfigFileEntry* getEntry(const std::string& name) const; 352 /** 353 @brief Returns the entry with given name. If it doesn't exist, the entry is created using the fallback value. 354 355 @param name The name of the entry 356 @param fallback The value that will be used if the entry doesn't exist 357 @param bString If true, the value is treated as string which means some special treatment of special characters. 358 */ 238 359 inline ConfigFileEntry* getOrCreateEntry(const std::string& name, const std::string& fallback, bool bString) 239 360 { return (*this->getOrCreateEntryIterator(name, fallback, bString)); } 361 240 362 ConfigFileEntry* getEntry(const std::string& name, unsigned int index) const; 363 /** 364 @brief Returns the entry that contains an element of a vector with given name. If it doesn't exist, the entry is created using the fallback value. 365 366 @param name The name of the entry 367 @param index The index of the element in the vector 368 @param fallback The value that will be used if the entry doesn't exist 369 @param bString If true, the value is treated as string which means some special treatment of special characters. 370 */ 241 371 inline ConfigFileEntry* getOrCreateEntry(const std::string& name, unsigned int index, const std::string& fallback, bool bString) 242 372 { return (*this->getOrCreateEntryIterator(name, index, fallback, bString)); } 243 373 244 std::string name_; 245 std::string additionalComment_; 246 std::list<ConfigFileEntry*> entries_; 247 bool bUpdated_; 374 std::string name_; ///< The name of the section 375 std::string additionalComment_; ///< The additional comment which is placed after the title of the section in the config file 376 std::list<ConfigFileEntry*> entries_; ///< The list of entries in this section 377 bool bUpdated_; ///< True if an entry is created 248 378 }; 249 379 … … 252 382 // ConfigFile // 253 383 //////////////// 384 /** 385 @brief This class represents a config file, which is stored on the hard-disk and contains config values in different sections. 386 387 It provides an interface to manipulate the sections and values. 388 */ 254 389 class _CoreExport ConfigFile 255 390 { … … 263 398 virtual void clear(); 264 399 400 /// Returns the file-name of this config file 265 401 inline const std::string& getFilename() 266 402 { return this->filename_; } 267 403 404 /** 405 @brief Stores a value in the config file. If the entry or its section doesn't exist, it's created. 406 407 @param section The name of the section 408 @param name The name of the entry 409 @param value The new value 410 @param bString If true, the value is treated as string which means some special treatment of special characters. 411 */ 268 412 inline void setValue(const std::string& section, const std::string& name, const std::string& value, bool bString) 269 413 { … … 271 415 this->save(); 272 416 } 417 /** 418 @brief Returns the value of a given entry in the config file. Returns a blank string if the value doesn't exist. 419 420 @param section The name of the section 421 @param name The name of the entry 422 @param bString If true, the value is treated as string which means some special treatment of special characters. 423 */ 273 424 inline const std::string& getValue(const std::string& section, const std::string& name, bool bString) 274 425 { … … 276 427 return (sectionPtr ? sectionPtr->getValue(name, bString) : BLANKSTRING); 277 428 } 278 const std::string& getOrCreateValue(const std::string& section, const std::string& name, const std::string& fallback, bool bString); 279 429 /** 430 @brief Returns the value of a given entry in the config file. If it doesn't exist, the entry is created using the fallback value. 431 432 @param section The name of the section 433 @param name The name of the entry 434 @param fallback The value that will be used if the entry doesn't exist 435 @param bString If true, the value is treated as string which means some special treatment of special characters. 436 */ 437 inline const std::string& getOrCreateValue(const std::string& section, const std::string& name, const std::string& fallback, bool bString) 438 { 439 const std::string& output = this->getOrCreateSection(section)->getOrCreateValue(name, fallback, bString); 440 this->saveIfUpdated(); 441 return output; 442 } 443 444 /** 445 @brief Stores the value of an element of a vector in the config file. If the entry or its section doesn't exist, it's created. 446 447 @param section The name of the section 448 @param name The name of the vector 449 @param index The index of the element in the vector 450 @param value The new value 451 @param bString If true, the value is treated as string which means some special treatment of special characters. 452 */ 280 453 inline void setValue(const std::string& section, const std::string& name, unsigned int index, const std::string& value, bool bString) 281 454 { … … 283 456 this->save(); 284 457 } 458 /** 459 @brief Returns the value of a given element of a vector in the config file. Returns a blank string if the value doesn't exist. 460 461 @param section The name of the section 462 @param name The name of the vector 463 @param index The index of the element in the vector 464 @param bString If true, the value is treated as string which means some special treatment of special characters. 465 */ 285 466 inline const std::string& getValue(const std::string& section, const std::string& name, unsigned int index, bool bString) 286 467 { … … 288 469 return (sectionPtr ? sectionPtr->getValue(name, index, bString) : BLANKSTRING); 289 470 } 290 const std::string& getOrCreateValue(const std::string& section, const std::string& name, unsigned int index, const std::string& fallback, bool bString); 471 /** 472 @brief Returns the value of a given element of a vector in the config file. If it doesn't exist, the entry is created using the fallback value. 473 474 @param section The name of the section 475 @param name The name of the vector 476 @param index The index of the element in the vector 477 @param fallback The value that will be used if the entry doesn't exist 478 @param bString If true, the value is treated as string which means some special treatment of special characters. 479 */ 480 const std::string& getOrCreateValue(const std::string& section, const std::string& name, unsigned int index, const std::string& fallback, bool bString) 481 { 482 const std::string& output = this->getOrCreateSection(section)->getOrCreateValue(name, index, fallback, bString); 483 this->saveIfUpdated(); 484 return output; 485 } 291 486 292 487 void deleteVectorEntries(const std::string& section, const std::string& name, unsigned int startindex = 0); 488 /** 489 @brief Returns the size of a config vector. 490 @param section The section of the vector 491 @param name The name of the vector 492 */ 293 493 inline unsigned int getVectorSize(const std::string& section, const std::string& name) const 294 494 { … … 297 497 } 298 498 299 static const char* DEFAULT_CONFIG_FOLDER; 499 static const char* DEFAULT_CONFIG_FOLDER; ///< The folder where the default config files will be stored 300 500 301 501 protected: … … 303 503 ConfigFileSection* getOrCreateSection(const std::string& section); 304 504 305 std::list<ConfigFileSection*> sections_; 505 std::list<ConfigFileSection*> sections_; ///< A list of sections in this config file 306 506 307 507 private: 308 508 void saveIfUpdated(); 309 const std::string filename_; 310 const bool bCopyFallbackFile_; 311 bool bUpdated_; 509 510 const std::string filename_; ///< The filename of this config file 511 const bool bCopyFallbackFile_; ///< If true, the default config file is copied into the config-directory before loading the file 512 bool bUpdated_; ///< Becomes true if a section is added 312 513 }; 313 514 … … 316 517 // SettingsConfigFile // 317 518 //////////////////////// 519 /** 520 @brief Child class of ConfigFile, used to store the settings of the game. 521 522 In addition to ConfigFile, this class provides an interface to manipulate the settings 523 with console commands and to cache entries in instances of ConfigValueContainer. 524 525 SettingsConfigFile is a Singleton, meaning there's only one instance of this class 526 (and thus only one config file that stores settings). 527 */ 318 528 class _CoreExport SettingsConfigFile // tolua_export 319 529 : public ConfigFile, public Singleton<SettingsConfigFile> … … 338 548 void removeConfigValueContainer(ConfigValueContainer* container); 339 549 550 /// Returns a set containing the names of all sections in this config file. 340 551 inline const std::set<std::string>& getSectionNames() 341 552 { return this->sectionNames_; } 553 /// Returns the lower-bound-iterator of the @ref ConfigValueContainer "config value containers" for the given section. 342 554 inline ContainerMap::const_iterator getContainerLowerBound(const std::string section) 343 555 { return this->containers_.lower_bound(section); } 556 /// Returns the upper-bound-iterator of the @ref ConfigValueContainer "config value containers" for the given section. 344 557 inline ContainerMap::const_iterator getContainerUpperBound(const std::string section) 345 558 { return this->containers_.upper_bound(section); } … … 351 564 bool configImpl(const std::string& section, const std::string& entry, const std::string& value, bool (ConfigValueContainer::*function)(const MultiType&)); 352 565 353 ContainerMap containers_; 354 std::set<std::string> sectionNames_; 355 static SettingsConfigFile* singletonPtr_s; 566 ContainerMap containers_; ///< Stores all @ref ConfigValueContainer "config value containers" 567 std::set<std::string> sectionNames_; ///< Stores all section names 568 static SettingsConfigFile* singletonPtr_s; ///< The singleton pointer 356 569 }; // tolua_export 357 570 … … 360 573 // ConfigFileManager // 361 574 /////////////////////// 575 /** 576 @brief Manages the different config files (settings, calibration, etc). Implemented as Singleton. 577 */ 362 578 class _CoreExport ConfigFileManager : public Singleton<ConfigFileManager> 363 579 { … … 369 585 void setFilename(ConfigFileType::Value type, const std::string& filename); 370 586 587 /// Returns the config file of a given type (settings, calibration, etc.) 371 588 inline ConfigFile* getConfigFile(ConfigFileType::Value type) 372 589 { … … 376 593 377 594 private: 378 ConfigFileManager(const ConfigFileManager&); 379 380 boost::array<ConfigFile*, 3> configFiles_; 381 static ConfigFileManager* singletonPtr_s; 595 ConfigFileManager(const ConfigFileManager&); ///< Copy-constructor: not implemented 596 597 boost::array<ConfigFile*, 3> configFiles_; ///< Stores the config files for each type in an array (must have the same size like ConfigFileType::Value) 598 static ConfigFileManager* singletonPtr_s; ///< Stores the singleton-pointer 382 599 }; 383 600 } // tolua_export -
code/trunk/src/libraries/core/ConfigValueContainer.h
r6536 r7401 29 29 /** 30 30 @file 31 @brief Definition of the ConfigValueContainer class. 31 @ingroup Config ConfigFile 32 @brief Declaration of the ConfigValueContainer class, caches a config-value. 32 33 33 34 The ConfigValueContainer class contains all needed information about a configurable variable: … … 78 79 79 80 80 //! The ConfigValuecontainer contains all needed information about a configurable variable.81 81 /** 82 @brief The ConfigValuecontainer contains all needed information about a configurable variable. 83 82 84 The ConfigValueContainer class contains all needed information about a configurable variable: 83 85 - the name of the variable … … 117 119 @param type The type of the corresponding config-file 118 120 @param identifier The identifier of the class the variable belongs to 121 @param sectionname Name of the section the configValue should be put in. 119 122 @param varname The name of the variable 120 123 @param defvalue The default-value 124 @param value Only needed do determine the right type. 121 125 */ 122 126 template <class D, class V> … … 213 217 } 214 218 215 / ** @brief Returns the name of this container. */219 /// Returns the name of this container. 216 220 inline const std::string& getName() const 217 221 { return this->varname_; } 218 / ** @brief Returns the name of the section this config value is in. */222 /// Returns the name of the section this config value is in. 219 223 inline const std::string& getSectionName() const 220 224 { return this->sectionname_; } 221 / ** @brief Returns the associated identifier (can be NULL). */225 /// Returns the associated identifier (can be NULL). 222 226 inline Identifier* getIdentifier() const 223 227 { return this->identifier_; } 224 / ** @brief Returns true if this config-value is a vector */228 /// Returns true if this config-value is a vector. 225 229 inline bool isVector() const 226 230 { return this->bIsVector_; } 227 / ** @brief Returns the vectors size (or zero if it's not a vector). */231 /// Returns the vectors size (or zero if it's not a vector). 228 232 inline unsigned int getVectorSize() const 229 233 { return this->valueVector_.size(); } … … 265 269 void update(); 266 270 267 / ** @brief Converts the config-value to a string. @return The string */271 /// Converts the config-value to a string. 268 272 inline std::string toString() const 269 273 { return this->value_; } 270 / ** @brief Returns the typename of the assigned config-value. @return The typename */274 /// Returns the typename of the assigned config-value. 271 275 inline std::string getTypename() const 272 276 { return this->value_.getTypename(); } -
code/trunk/src/libraries/core/ConfigValueIncludes.h
r7166 r7401 28 28 29 29 /** 30 @file 31 @brief 32 Definition of macros and functions for config-values. 30 @defgroup ConfigFile Config file 31 @ingroup Config 32 */ 33 34 /** 35 @file 36 @ingroup Config ConfigFile 37 @brief Definition of macros and functions for config-values. 38 39 An example of how to use SetConfigValue(): 40 41 Definition of a class in the header-file: 42 @code 43 class MyClass : public BaseObject 44 { 45 public: 46 MyClass(); // Constructor 47 void setConfigValues(); // Inherited function 48 49 const std::string& getName() 50 { return this->name_; } 51 52 float getVersion() 53 { return this->version_; } 54 55 private: 56 std::string name_; 57 float version_; 58 }; 59 @endcode 60 61 Implementation of the class source-file: 62 @code 63 MyClass::MyClass() 64 { 65 // Macro-call to create an Identifier 66 RegisterObject(MyClass); 67 68 // Function-call to assign the config-values to the new object 69 this->setConfigValues(); 70 } 71 72 void MyClass::setConfigValues() 73 { 74 SetConfigValue(name_, "Orxonox").description("The name of the game"); 75 SetConfigValue(version_, "1.0").description("The version-number"); 76 } 77 @endcode 78 79 Extract of orxonox.ini: 80 @code 81 [MyClass] 82 name_ = "Orxonox" 83 version_ = 1.1 // We have changed this value from 1.0 to 1.1 84 @endcode 85 86 Some other code: 87 @code 88 MyObject orxonoxobject; 89 std::cout << "Name: " << orxonoxobject.getName() << std::endl; 90 std::cout << "Version: " << orxonoxobject.getVersion() << std::endl; 91 @endcode 92 93 Output: 94 @code 95 Name: Orxonox 96 Version: 1.1 97 @endcode 33 98 */ 34 99 -
code/trunk/src/libraries/core/Core.cc
r7284 r7401 37 37 38 38 #include <cassert> 39 #include <fstream> 39 40 #include <vector> 40 41 … … 171 172 // Create singletons that always exist (in other libraries) 172 173 this->rootScope_.reset(new Scope<ScopeID::Root>()); 174 175 // Generate documentation instead of normal run? 176 std::string docFilename; 177 CommandLineParser::getValue("generateDoc", &docFilename); 178 if (!docFilename.empty()) 179 { 180 std::ofstream docFile(docFilename.c_str()); 181 if (docFile.is_open()) 182 { 183 CommandLineParser::generateDoc(docFile); 184 docFile.close(); 185 } 186 else 187 COUT(0) << "Error: Could not open file for documentation writing" << endl; 188 } 173 189 } 174 190 -
code/trunk/src/libraries/core/Core.h
r7266 r7401 28 28 */ 29 29 30 /** 31 @defgroup CoreGame Core and Game 32 @ingroup Management 33 */ 34 35 /** 36 @file 37 @ingroup Management CoreGame 38 @brief Declaration of the Core singleton which is used to configure the program basics. 39 */ 40 30 41 #ifndef _Core_H__ 31 42 #define _Core_H__ … … 33 44 #include "CorePrereqs.h" 34 45 35 #include <cassert>36 46 #include <string> 37 47 #include <boost/scoped_ptr.hpp> -
code/trunk/src/libraries/core/CoreIncludes.h
r6423 r7401 28 28 29 29 /** 30 @defgroup Factory RegisterObject() and CreateFactory() 31 @ingroup Object 32 */ 33 34 /** 30 35 @file 31 @brief Definition of macros for Identifiers 36 @ingroup Object Factory 37 @brief Defines several very important macros used to register objects, create factories, and to work with identifiers. 32 38 33 Every class needs the RegisterObject(class) macro in its constructor. If the class is an interface34 or the BaseObject itself, it needs the macroRegisterRootObject(class) instead.39 Every class needs the @c RegisterObject(class) macro in its constructor. If the class is an interface 40 or the @c BaseObject itself, it needs the macro @c RegisterRootObject(class) instead. 35 41 36 To allow the object being created through the factory, use the CreateFactory(class) macro outside 37 the of the class implementation, so it gets executed before main(). 42 To allow the object being created through the factory, use the @c CreateFactory(class) macro outside 43 of the class implementation, so it gets executed statically before @c main(). This will at the same time 44 register @a class in the class-hierarchy. If you don't want @a class to be loadable, but still 45 register it, call @c CreateUnloadableFactory(class). 46 47 Example: 48 @code 49 // Create the factory for MyClass 50 CreateFactory(MyClass); 51 52 // Constructor: 53 MyClass::MyClass() 54 { 55 // Register the object in the Identifier of MyClass 56 RegisterObject(MyClass); 57 } 58 @endcode 59 60 This file also defines a number of other useful macros, like, for example, @c Class(class) which 61 returns the @ref orxonox::Identifier "Identifier" of @a class, or @c ClassByString("class") which 62 returns the Identifier of a class with name @a "class". 63 64 Example: 65 @code 66 // Assigns the Identifier of MyClass 67 Identifier* identifier = Class(MyClass); 68 @endcode 69 @code 70 // Assigns the Identifier of a class named "MyClass" 71 Identifier* identifier = ClassByString("MyClass"); 72 @endcode 38 73 */ 39 74 … … 51 86 52 87 /** 53 @brief Intern macro, containing the common parts of RegisterObject andRegisterRootObject.88 @brief Intern macro, containing the common parts of @c RegisterObject and @c RegisterRootObject. 54 89 @param ClassName The name of the class 55 @param bRootClass True if the class is directly derived from OrxonoxClass90 @param bRootClass True if the class is directly derived from orxonox::OrxonoxClass 56 91 */ 57 92 #define InternRegisterObject(ClassName, bRootClass) \ … … 62 97 63 98 /** 64 @brief Register Object - with and without debug output.99 @brief Registers a newly created object in the core. Has to be called at the beginning of the constructor of @a ClassName. 65 100 @param ClassName The name of the class 66 101 */ … … 69 104 70 105 /** 71 @brief Register RootObject - with and without debug output.106 @brief Registers a newly created object in the core. Has to be called at the beginning of the constructor of @a ClassName. 72 107 @param ClassName The name of the class 108 109 In contrast to RegisterObject, this is used for classes that inherit directly from 110 orxonox::OrxonoxClass, namely all interfaces and orxonox::BaseObject. 73 111 */ 74 112 #define RegisterRootObject(ClassName) \ … … 101 139 /** 102 140 @brief Returns the Identifier with a given name. 103 @param StringThe name of the class141 @param name The name of the class 104 142 */ 105 143 inline Identifier* ClassByString(const std::string& name) … … 110 148 /** 111 149 @brief Returns the Identifier with a given lowercase name. 112 @param StringThe lowercase name of the class150 @param name The lowercase name of the class 113 151 */ 114 152 inline Identifier* ClassByLowercaseString(const std::string& name) … … 119 157 /** 120 158 @brief Returns the Identifier with a given network ID. 121 @param networkIDThe network ID of the class159 @param id The network ID of the class 122 160 */ 123 161 inline Identifier* ClassByID(uint32_t id) … … 130 168 @note This of course only works with OrxonoxClasses. 131 169 The only use is in conjunction with macros that don't know the class type. 132 @param Pointer to an OrxonoxClass170 @param object Pointer to an OrxonoxClass 133 171 */ 134 172 template <class T> -
code/trunk/src/libraries/core/DynLib.h
r6073 r7401 29 29 30 30 // 08/11/2009: Small adjustments for Orxonox by Fabian 'x3n' Landau 31 32 /** 33 @file 34 @ingroup Management CoreGame 35 @brief Declaration of DynLib which represents a dynamically loaded module. 36 */ 31 37 32 38 #ifndef _Core_DynLib_H__ … … 61 67 namespace orxonox 62 68 { 63 /** Resource holding data about a dynamic library.69 /** %Resource holding data about a dynamic library. 64 70 @remarks 65 71 This class holds the data required to get symbols from … … 69 75 @since 70 76 27 January 2002 71 @see72 Resource73 77 */ 74 78 class _CoreExport DynLib -
code/trunk/src/libraries/core/DynLibManager.h
r5738 r7401 30 30 // 08/11/2009: Small adjustments for Orxonox by Fabian 'x3n' Landau 31 31 32 /** 33 @file 34 @ingroup Management CoreGame 35 @brief Declaration of DynLibManager, used to load modules at runtime. 36 */ 37 32 38 #ifndef _Core_DynLibManager_H__ 33 39 #define _Core_DynLibManager_H__ … … 56 62 57 63 public: 58 /** Default constructor. 59 @note 60 <br>Should never be called as the singleton is automatically 61 created during the creation of the Root object. 62 @see 63 Root::Root 64 /** 65 @brief 66 Default constructor. 67 @note 68 Should never be called as the singleton is automatically 69 created during the creation of the Root object. 70 @see 71 Root::Root 64 72 */ 65 73 DynLibManager(); 66 74 67 /** Default destructor. 68 @see 69 Root::~Root 75 /** 76 @brief 77 Default destructor. 78 @see 79 Root::~Root 70 80 */ 71 81 virtual ~DynLibManager(); 72 82 73 /** Loads the passed library. 74 @param 75 filename The name of the library. The extension can be omitted 83 /** 84 @brief 85 Loads the passed library. 86 @param filename 87 The name of the library. The extension can be omitted 76 88 */ 77 89 DynLib* load(const std::string& filename); 78 90 79 /** Unloads the passed library. 80 @param 81 filename The name of the library. The extension can be omitted 91 /** 92 @brief 93 Unloads the passed library. 94 @param lib 95 A pointer to the library object 82 96 */ 83 97 void unload(DynLib* lib); -
code/trunk/src/libraries/core/Event.cc
r7284 r7401 26 26 * 27 27 */ 28 29 /** 30 @file 31 @brief Implementation of the classes Event and EventState. 32 */ 28 33 29 34 #include "Event.h" -
code/trunk/src/libraries/core/Event.h
r7284 r7401 27 27 */ 28 28 29 /** 30 @defgroup Event Events 31 @ingroup Core 32 */ 33 34 /** 35 @file 36 @ingroup Event 37 @brief Declaration of the classes Event and EventState. 38 */ 39 29 40 #ifndef _Event_H__ 30 41 #define _Event_H__ … … 54 65 An event state is a state of an object, which can be changed by events. 55 66 Event states are changed through functions. Possible functions headers for set event states are: 56 - memoryless state: function()57 - boolean state: function(bool state)58 - individual state: function(bool state, SomeClass originator)67 - memoryless state: <tt>function()</tt> 68 - boolean state: <tt>function(bool state)</tt> 69 - individual state: <tt>function(bool state, SomeClass originator)</tt> 59 70 60 71 Note that SomeClass may be any class deriving from BaseObject. You will not receive events from originators of other classes. 61 The actual class for SomeClass must be specified as the second argument of the XMLPortEventState macro.72 The actual class for SomeClass must be specified as the second argument of the XMLPortEventState() macro. 62 73 63 74 The this pointer of the affected object is hidden in the functors, because the events are processed in the BaseObject, but some -
code/trunk/src/libraries/core/EventIncludes.h
r7301 r7401 26 26 * 27 27 */ 28 29 /** 30 @file 31 @ingroup Event 32 @brief Definition of the XMLPortEventState() macro, as well as some more useful macros. 33 */ 28 34 29 35 #ifndef _EventIncludes_H__ -
code/trunk/src/libraries/core/GUIManager.cc
r7284 r7401 110 110 After Lua setup tolua++-elements are linked to Lua-state to give Lua access to C++-code. 111 111 Finally initial Lua code is executed (maybe we can do this with the CEGUI startup script automatically). 112 @param renderWindow113 Ogre's render window. Without this, the GUI cannot be displayed.114 112 @return true if success, otherwise false 115 113 */ … … 237 235 @param name 238 236 The name of the GUI 237 @param bHidePrevious 238 If true all displayed GUIs on the stack, that are below this GUI are hidden. 239 239 240 240 The function executes the Lua function with the same name in case the GUIManager is ready. -
code/trunk/src/libraries/core/GUIManager.h
r7163 r7401 27 27 * 28 28 */ 29 30 /** 31 @file 32 @ingroup Graphics 33 */ 29 34 30 35 #ifndef _GUIManager_H__ -
code/trunk/src/libraries/core/Game.h
r7266 r7401 29 29 /** 30 30 @file 31 @ingroup Management CoreGame 31 32 @brief 32 Declaration of Game Singleton .33 Declaration of Game Singleton which is responsible for running the game. 33 34 */ 34 35 … … 53 54 54 55 /** 55 @ def56 @brief 56 57 Adds a new GameState to the Game. The second parameter is the name as string 57 58 and every following paramter is a constructor argument (which is usually non existent) -
code/trunk/src/libraries/core/GameMode.cc
r5929 r7401 33 33 bool GameMode::bShowsGraphics_s = false; 34 34 bool GameMode::bPlaysSound_s = false; 35 bool GameMode::b HasServer_s= false;35 bool GameMode::bIsServer_s = false; 36 36 bool GameMode::bIsClient_s = false; 37 37 bool GameMode::bIsStandalone_s = false; -
code/trunk/src/libraries/core/GameMode.h
r6417 r7401 29 29 /** 30 30 @file 31 @brief Declaration of the GameMode class. 31 @ingroup Management CoreGame 32 @brief Declaration of the GameMode class which stores and returns the current mode of the game. 32 33 */ 33 34 … … 40 41 namespace orxonox 41 42 { 43 /// Helper class, stores and returns the current mode of the game. 42 44 class _CoreExport GameMode 43 45 { … … 47 49 public: 48 50 // tolua_begin 49 static bool showsGraphics() { return bShowsGraphics_s; } 50 static bool playsSound() { return bPlaysSound_s; } 51 static bool hasServer() { return bHasServer_s; }52 static bool isClient() { return bIsClient_s; } 53 static bool isStandalone() { return bIsStandalone_s; } 54 static bool isMaster() { return bIsMaster_s; } 51 static bool showsGraphics() { return bShowsGraphics_s; } ///< Returns true if the game shows graphics, false if it is in text-console mode 52 static bool playsSound() { return bPlaysSound_s; } ///< Returns true if the game is able to play sounds 53 static bool isServer() { return bIsServer_s; } ///< Returns true if we're currently a server (online) 54 static bool isClient() { return bIsClient_s; } ///< Returns true if we're currently a client (online) 55 static bool isStandalone() { return bIsStandalone_s; } ///< Returns true if we're in standalone mode (offline) 56 static bool isMaster() { return bIsMaster_s; } ///< Returns true if we're in control of the game (either standalone or server) 55 57 // tolua_end 56 58 57 static void setPlaysSound (bool val) { bPlaysSound_s = val; } 58 static void set HasServer (bool val) { bHasServer_s = val; updateIsMaster(); }59 static void setIsClient (bool val) { bIsClient_s = val; updateIsMaster(); } 60 static void setIsStandalone (bool val) { bIsStandalone_s = val; updateIsMaster(); } 59 static void setPlaysSound (bool val) { bPlaysSound_s = val; } ///< Defines if the game can play sounds 60 static void setIsServer (bool val) { bIsServer_s = val; updateIsMaster(); } ///< Defines if the program is in server mode (online) 61 static void setIsClient (bool val) { bIsClient_s = val; updateIsMaster(); } ///< Defines if the program is in client mode (online) 62 static void setIsStandalone (bool val) { bIsStandalone_s = val; updateIsMaster(); } ///< Defines if the program is in standalone mode (offline) 61 63 62 64 private: … … 65 67 ~GameMode(); 66 68 69 /// Checks if we're in control of the game (either standalone or server). 67 70 static void updateIsMaster() 68 71 { 69 bIsMaster_s = (b HasServer_s || bIsStandalone_s);72 bIsMaster_s = (bIsServer_s || bIsStandalone_s); 70 73 } 71 74 72 75 static bool bShowsGraphics_s; //!< global variable that tells whether to show graphics 73 76 static bool bPlaysSound_s; //!< global variable that tells whether to sound works 74 static bool b HasServer_s; //!< global variable that tells whether this is a server75 static bool bIsClient_s; 76 static bool bIsStandalone_s; 77 static bool bIsMaster_s; 77 static bool bIsServer_s; //!< global variable that tells whether this is a server (online) 78 static bool bIsClient_s; //!< global variable that tells whether this is a client (online) 79 static bool bIsStandalone_s; //!< global variable that tells whether the game is running in standalone mode (offline) 80 static bool bIsMaster_s; //!< global variable that tells whether we're in control of the game (standalone or server) 78 81 }; // tolua_export 79 82 } // tolua_export -
code/trunk/src/libraries/core/GameState.h
r5929 r7401 29 29 /** 30 30 @file 31 @ingroup Management CoreGame 31 32 @brief 32 33 Definition of GameState class. -
code/trunk/src/libraries/core/GraphicsManager.h
r7284 r7401 29 29 30 30 /** 31 @defgroup Graphics Graphics and GUI 32 @ingroup Core 33 */ 34 35 /** 31 36 @file 37 @ingroup Graphics 32 38 @brief 33 39 Declaration of GraphicsManager Singleton. -
code/trunk/src/libraries/core/Identifier.cc
r7284 r7401 217 217 /** 218 218 @brief Sets the name of the class. 219 @param name The name220 219 */ 221 220 void Identifier::setName(const std::string& name) … … 253 252 /** 254 253 @brief Sets the network ID to a new value and changes the entry in the ID-Identifier-map. 255 @param id The new network ID256 254 */ 257 255 void Identifier::setNetworkID(uint32_t id) -
code/trunk/src/libraries/core/Identifier.h
r7284 r7401 28 28 29 29 /** 30 @defgroup Identifier Identifier 31 @ingroup Class 32 */ 33 34 /** 30 35 @file 31 @brief Definition of the Identifier class, definition and implementation of the ClassIdentifier class. 32 33 The Identifier contains all needed information about the class it belongs to: 34 - the name 35 - a list with all objects 36 - parents and children 37 - the factory (if available) 38 - the networkID that can be synchronised with the server 39 - all configurable variables (if available) 40 41 Every object has a pointer to the Identifier of its class. This allows the use isA(...), 42 isExactlyA(...), isChildOf(...) and isParentOf(...). 43 44 To create the class-hierarchy, the Identifier has some intern functions and variables. 45 46 Every Identifier is in fact a ClassIdentifier, but they are derived from Identifier. 36 @ingroup Class Identifier 37 @brief Declaration of Identifier, definition of ClassIdentifier<T>; used to identify the class of an object. 38 39 @anchor IdentifierExample 40 41 An Identifier "identifies" the class of an object. It contains different information about 42 the class: Its name and ID, a list of all instances of this class, a factory to create new 43 instances of this class, and more. 44 45 It also contains information about the inheritance of this class: It stores a list of the 46 Identifiers of all parent-classes as well as a list of all child-classes. These relationships 47 can be tested using functions like @c isA(), @c isChildOf(), @c isParentOf(), and more. 48 49 Every Identifier is in fact a ClassIdentifier<T> (where T is the class that is identified 50 by the Identifier), Identifier is just the common base-class. 51 52 Example: 53 @code 54 MyClass* object = new MyClass(); // create an instance of MyClass 55 56 object->getIdentifier()->getName(); // returns "MyClass" 57 58 BaseObject* other = object->getIdentifier()->fabricate(0); // fabricates a new instance of MyClass 59 60 61 // iterate through all objects of type MyClass: 62 ObjectListBase* objects = object->getIdentifier()->getObjects(); // get a pointer to the object-list 63 int count; 64 for (Iterator<BaseObject> it = objects.begin(); it != objects.end(); ++it) // iterate through the objects 65 ++count; 66 COUT(0) << count << std::endl; // prints "2" because we created 2 instances of MyClass so far 67 68 69 // test the class hierarchy 70 object->getIdentifier()->isA(Class(MyClass)); // returns true 71 object->isA(Class(MyClass)); // returns true (short version) 72 73 object->isA(Class(BaseClass)); // returns true if MyClass is a child of BaseClass 74 75 Class(ChildClass)->isChildOf(object->getIdentifier()); // returns true if ChildClass is a child of MyClass 76 @endcode 47 77 */ 48 78 … … 70 100 // ### Identifier ### 71 101 // ############################### 72 //! The Identifier is used to identify the class of an object and to store information about the class. 73 /** 74 The Identifier contains all needed information about the class it belongs to: 75 - the name 76 - a list with all objects 77 - parents and children 78 - the factory (if available) 79 - the networkID that can be synchronised with the server 80 - all configurable variables (if available) 81 82 Every object has a pointer to the Identifier of its class. This allows the use isA(...), 83 isExactlyA(...), isChildOf(...) and isParentOf(...). 84 85 You can't directly create an Identifier, it's just the base-class for ClassIdentifier. 102 /** 103 @brief The Identifier is used to identify the class of an object and to store information about the class. 104 105 Each Identifier stores information about one class. The Identifier can then be used to identify 106 this class. On the other hand it's also possible to get the corresponding Identifier of a class, 107 for example by using the macro Class(). 108 109 @see See @ref IdentifierExample "Identifier.h" for more information and some examples. 110 111 @note You can't directly create an Identifier, it's just the base-class of ClassIdentifier<T>. 86 112 */ 87 113 class _CoreExport Identifier 88 114 { 89 115 public: 90 / ** @brief Returns the name of the class the Identifier belongs to. @return The name */116 /// Returns the name of the class the Identifier belongs to. 91 117 inline const std::string& getName() const { return this->name_; } 92 118 void setName(const std::string& name); 93 119 94 / ** @brief Returns the network ID to identify a class through the network. @return the network ID */120 /// Returns the network ID to identify a class through the network. 95 121 inline const uint32_t getNetworkID() const { return this->networkID_; } 96 122 void setNetworkID(uint32_t id); 97 123 98 / ** @brief Returns the unique ID of the class */124 /// Returns the unique ID of the class. 99 125 FORCEINLINE unsigned int getClassID() const { return this->classID_; } 100 126 101 / ** @brief Returns the list of all existing objects of this class. @return The list */127 /// Returns the list of all existing objects of this class. 102 128 inline ObjectListBase* getObjects() const { return this->objects_; } 103 129 104 / ** @brief Sets the Factory. @param factory The factory to assign */130 /// Sets the Factory. 105 131 inline void addFactory(Factory* factory) { this->factory_ = factory; } 106 / ** @brief Returns true if the Identifier has a Factory. */132 /// Returns true if the Identifier has a Factory. 107 133 inline bool hasFactory() const { return (this->factory_ != 0); } 108 134 109 135 BaseObject* fabricate(BaseObject* creator); 110 136 111 / ** @brief Returns true if the class can be loaded through XML. */137 /// Returns true if the class can be loaded through XML. 112 138 inline bool isLoadable() const { return this->bLoadable_; } 113 / ** @brief Set the class to be loadable through XML or not. */139 /// Set the class to be loadable through XML or not. 114 140 inline void setLoadable(bool bLoadable) { this->bLoadable_ = bLoadable; } 115 141 … … 127 153 static void createClassHierarchy(); 128 154 129 / ** @brief Returns true, if a branch of the class-hierarchy is being created, causing all new objects to store their parents. @return The status of the class-hierarchy creation */155 /// Returns true, if a branch of the class-hierarchy is being created, causing all new objects to store their parents. 130 156 inline static bool isCreatingHierarchy() { return (hierarchyCreatingCounter_s > 0); } 131 157 132 / ** @brief Returns the parents of the class the Identifier belongs to. @return The list of all parents */158 /// Returns the parents of the class the Identifier belongs to. 133 159 inline const std::set<const Identifier*>& getParents() const { return this->parents_; } 134 / ** @brief Returns the begin-iterator of the parents-list. @return The begin-iterator */160 /// Returns the begin-iterator of the parents-list. 135 161 inline std::set<const Identifier*>::const_iterator getParentsBegin() const { return this->parents_.begin(); } 136 / ** @brief Returns the end-iterator of the parents-list. @return The end-iterator */162 /// Returns the end-iterator of the parents-list. 137 163 inline std::set<const Identifier*>::const_iterator getParentsEnd() const { return this->parents_.end(); } 138 164 139 / ** @brief Returns the children of the class the Identifier belongs to. @return The list of all children */165 /// Returns the children of the class the Identifier belongs to. 140 166 inline const std::set<const Identifier*>& getChildren() const { return this->children_; } 141 / ** @brief Returns the begin-iterator of the children-list. @return The begin-iterator */167 /// Returns the begin-iterator of the children-list. 142 168 inline std::set<const Identifier*>::const_iterator getChildrenBegin() const { return this->children_.begin(); } 143 / ** @brief Returns the end-iterator of the children-list. @return The end-iterator */169 /// Returns the end-iterator of the children-list. 144 170 inline std::set<const Identifier*>::const_iterator getChildrenEnd() const { return this->children_.end(); } 145 171 146 / ** @brief Returns the direct parents of the class the Identifier belongs to. @return The list of all direct parents */172 /// Returns the direct parents of the class the Identifier belongs to. 147 173 inline const std::set<const Identifier*>& getDirectParents() const { return this->directParents_; } 148 / ** @brief Returns the begin-iterator of the direct-parents-list. @return The begin-iterator */174 /// Returns the begin-iterator of the direct-parents-list. 149 175 inline std::set<const Identifier*>::const_iterator getDirectParentsBegin() const { return this->directParents_.begin(); } 150 / ** @brief Returns the end-iterator of the direct-parents-list. @return The end-iterator */176 /// Returns the end-iterator of the direct-parents-list. 151 177 inline std::set<const Identifier*>::const_iterator getDirectParentsEnd() const { return this->directParents_.end(); } 152 178 153 / ** @brief Returns the direct children the class the Identifier belongs to. @return The list of all direct children */179 /// Returns the direct children the class the Identifier belongs to. 154 180 inline const std::set<const Identifier*>& getDirectChildren() const { return this->directChildren_; } 155 / ** @brief Returns the begin-iterator of the direct-children-list. @return The begin-iterator */181 /// Returns the begin-iterator of the direct-children-list. 156 182 inline std::set<const Identifier*>::const_iterator getDirectChildrenBegin() const { return this->directChildren_.begin(); } 157 / ** @brief Returns the end-iterator of the direct-children-list. @return The end-iterator */183 /// Returns the end-iterator of the direct-children-list. 158 184 inline std::set<const Identifier*>::const_iterator getDirectChildrenEnd() const { return this->directChildren_.end(); } 159 185 … … 170 196 static void clearNetworkIDs(); 171 197 172 / ** @brief Returns the map that stores all Identifiers with their names. @return The map */198 /// Returns the map that stores all Identifiers with their names. 173 199 static inline const std::map<std::string, Identifier*>& getStringIdentifierMap() { return Identifier::getStringIdentifierMapIntern(); } 174 / ** @brief Returns a const_iterator to the beginning of the map that stores all Identifiers with their names. @return The const_iterator */200 /// Returns a const_iterator to the beginning of the map that stores all Identifiers with their names. 175 201 static inline std::map<std::string, Identifier*>::const_iterator getStringIdentifierMapBegin() { return Identifier::getStringIdentifierMap().begin(); } 176 / ** @brief Returns a const_iterator to the end of the map that stores all Identifiers with their names. @return The const_iterator */202 /// Returns a const_iterator to the end of the map that stores all Identifiers with their names. 177 203 static inline std::map<std::string, Identifier*>::const_iterator getStringIdentifierMapEnd() { return Identifier::getStringIdentifierMap().end(); } 178 204 179 / ** @brief Returns the map that stores all Identifiers with their names in lowercase. @return The map */205 /// Returns the map that stores all Identifiers with their names in lowercase. 180 206 static inline const std::map<std::string, Identifier*>& getLowercaseStringIdentifierMap() { return Identifier::getLowercaseStringIdentifierMapIntern(); } 181 / ** @brief Returns a const_iterator to the beginning of the map that stores all Identifiers with their names in lowercase. @return The const_iterator */207 /// Returns a const_iterator to the beginning of the map that stores all Identifiers with their names in lowercase. 182 208 static inline std::map<std::string, Identifier*>::const_iterator getLowercaseStringIdentifierMapBegin() { return Identifier::getLowercaseStringIdentifierMap().begin(); } 183 / ** @brief Returns a const_iterator to the end of the map that stores all Identifiers with their names in lowercase. @return The const_iterator */209 /// Returns a const_iterator to the end of the map that stores all Identifiers with their names in lowercase. 184 210 static inline std::map<std::string, Identifier*>::const_iterator getLowercaseStringIdentifierMapEnd() { return Identifier::getLowercaseStringIdentifierMap().end(); } 185 211 186 / ** @brief Returns the map that stores all Identifiers with their IDs. @return The map */212 /// Returns the map that stores all Identifiers with their IDs. 187 213 static inline const std::map<uint32_t, Identifier*>& getIDIdentifierMap() { return Identifier::getIDIdentifierMapIntern(); } 188 / ** @brief Returns a const_iterator to the beginning of the map that stores all Identifiers with their IDs. @return The const_iterator */214 /// Returns a const_iterator to the beginning of the map that stores all Identifiers with their IDs. 189 215 static inline std::map<uint32_t, Identifier*>::const_iterator getIDIdentifierMapBegin() { return Identifier::getIDIdentifierMap().begin(); } 190 / ** @brief Returns a const_iterator to the end of the map that stores all Identifiers with their IDs. @return The const_iterator */216 /// Returns a const_iterator to the end of the map that stores all Identifiers with their IDs. 191 217 static inline std::map<uint32_t, Identifier*>::const_iterator getIDIdentifierMapEnd() { return Identifier::getIDIdentifierMap().end(); } 192 218 … … 197 223 virtual void updateConfigValues(bool updateChildren = true) const = 0; 198 224 199 / ** @brief Returns true if this class has at least one config value. @return True if this class has at least one config value */225 /// Returns true if this class has at least one config value. 200 226 inline bool hasConfigValues() const { return this->bHasConfigValues_; } 201 227 … … 207 233 ///// XMLPort ///// 208 234 /////////////////// 209 / ** @brief Returns the map that stores all XMLPort params. @return The const_iterator */235 /// Returns the map that stores all XMLPort params. 210 236 inline const std::map<std::string, XMLPortParamContainer*>& getXMLPortParamMap() const { return this->xmlportParamContainers_; } 211 / ** @brief Returns a const_iterator to the beginning of the map that stores all XMLPort params. @return The const_iterator */237 /// Returns a const_iterator to the beginning of the map that stores all XMLPort params. 212 238 inline std::map<std::string, XMLPortParamContainer*>::const_iterator getXMLPortParamMapBegin() const { return this->xmlportParamContainers_.begin(); } 213 / ** @brief Returns a const_iterator to the end of the map that stores all XMLPort params. @return The const_iterator */239 /// Returns a const_iterator to the end of the map that stores all XMLPort params. 214 240 inline std::map<std::string, XMLPortParamContainer*>::const_iterator getXMLPortParamMapEnd() const { return this->xmlportParamContainers_.end(); } 215 241 216 / ** @brief Returns the map that stores all XMLPort objects. @return The const_iterator */242 /// Returns the map that stores all XMLPort objects. 217 243 inline const std::map<std::string, XMLPortObjectContainer*>& getXMLPortObjectMap() const { return this->xmlportObjectContainers_; } 218 / ** @brief Returns a const_iterator to the beginning of the map that stores all XMLPort objects. @return The const_iterator */244 /// Returns a const_iterator to the beginning of the map that stores all XMLPort objects. 219 245 inline std::map<std::string, XMLPortObjectContainer*>::const_iterator getXMLPortObjectMapBegin() const { return this->xmlportObjectContainers_.begin(); } 220 / ** @brief Returns a const_iterator to the end of the map that stores all XMLPort objects. @return The const_iterator */246 /// Returns a const_iterator to the end of the map that stores all XMLPort objects. 221 247 inline std::map<std::string, XMLPortObjectContainer*>::const_iterator getXMLPortObjectMapEnd() const { return this->xmlportObjectContainers_.end(); } 222 248 … … 238 264 void initializeClassHierarchy(std::set<const Identifier*>* parents, bool bRootClass); 239 265 240 / ** @brief Returns the map that stores all Identifiers with their names. @return The map */266 /// Returns the map that stores all Identifiers with their names. 241 267 static std::map<std::string, Identifier*>& getStringIdentifierMapIntern(); 242 / ** @brief Returns the map that stores all Identifiers with their names in lowercase. @return The map */268 /// Returns the map that stores all Identifiers with their names in lowercase. 243 269 static std::map<std::string, Identifier*>& getLowercaseStringIdentifierMapIntern(); 244 / ** @brief Returns the map that stores all Identifiers with their network IDs. @return The map */270 /// Returns the map that stores all Identifiers with their network IDs. 245 271 static std::map<uint32_t, Identifier*>& getIDIdentifierMapIntern(); 246 272 247 / ** @brief Returns the children of the class the Identifier belongs to. @return The list of all children */273 /// Returns the children of the class the Identifier belongs to. 248 274 inline std::set<const Identifier*>& getChildrenIntern() const { return this->children_; } 249 / ** @brief Returns the direct children of the class the Identifier belongs to. @return The list of all direct children */275 /// Returns the direct children of the class the Identifier belongs to. 250 276 inline std::set<const Identifier*>& getDirectChildrenIntern() const { return this->directChildren_; } 251 277 … … 253 279 254 280 private: 255 / ** @brief Increases the hierarchyCreatingCounter_s variable, causing all new objects to store their parents. */281 /// Increases the hierarchyCreatingCounter_s variable, causing all new objects to store their parents. 256 282 inline static void startCreatingHierarchy() { hierarchyCreatingCounter_s++; } 257 / ** @brief Decreases the hierarchyCreatingCounter_s variable, causing the objects to stop storing their parents. */283 /// Decreases the hierarchyCreatingCounter_s variable, causing the objects to stop storing their parents. 258 284 inline static void stopCreatingHierarchy() { hierarchyCreatingCounter_s--; } 259 285 … … 291 317 // ### ClassIdentifier ### 292 318 // ############################### 293 //! The ClassIdentifier is derived from Identifier and holds all class-specific functions and variables the Identifier cannot have. 294 /** 295 ClassIdentifier is a Singleton, which means that only one object of a given type T exists. 319 /** 320 @brief The ClassIdentifier is derived from Identifier and holds all class-specific functions and variables the Identifier cannot have. 321 322 ClassIdentifier is a Singleton, which means that only one ClassIdentifier for a given type T exists. 296 323 This makes it possible to store information about a class, sharing them with all 297 324 objects of that class without defining static variables in every class. 298 325 299 326 To be really sure that not more than exactly one object exists (even with libraries), 300 ClassIdentifiers are stored in the Identifier Singleton.327 ClassIdentifiers are stored in a static map in Identifier. 301 328 */ 302 329 template <class T> 303 330 class ClassIdentifier : public Identifier 304 331 { 305 #define SUPER_INTRUSIVE_DECLARATION_INCLUDE 306 #include "Super.h" 332 #ifndef DOXYGEN_SHOULD_SKIP_THIS 333 #define SUPER_INTRUSIVE_DECLARATION_INCLUDE 334 #include "Super.h" 335 #endif 307 336 308 337 public: … … 387 416 @brief Adds an object of the given type to the ObjectList. 388 417 @param object The object to add 418 @param className The name of the class T 419 @param bRootClass True if this is a root class (i.e. it inherits directly from OrxonoxClass) 389 420 */ 390 421 template <class T> -
code/trunk/src/libraries/core/Iterator.h
r7271 r7401 29 29 /** 30 30 @file 31 @brief Definition and implementation of the Iterator class. 32 33 The Iterator of a given class allows to iterate through an ObjectList. Objects in 34 this list are cast to the template argument of the Iterator. 31 @ingroup Object ObjectList 32 @brief Definition of the Iterator class, used to iterate through object-lists. 33 34 @anchor IteratorExample 35 36 @ref orxonox::Iterator "Iterator" allows to iterate through an @ref orxonox::ObjectListBase 37 "ObjectListBase". Objects in this list are cast to the template argument @a T of Iterator<T> using 38 @c dynamic_cast. In contrast to @ref orxonox::ObjectListIterator "ObjectListIterator<T>", 39 @ref orxonox::Iterator "Iterator<T>" can iterate through every object-list. In practice though it 40 is limited to objects of type @a T and its subclasses. Because of the @c dynamic_cast, this iterator 41 is much slower than ObjectListIterator. 35 42 36 43 Usage: 44 @code 37 45 for (Iterator<myClass> it = anyidentifier->getObjects()->begin(); it != anyidentifier->getObjects()->end(); ++it) 38 46 { … … 40 48 myClass* myObject = *it; 41 49 } 50 @endcode 42 51 */ 43 52 … … 52 61 namespace orxonox 53 62 { 54 //! The Iterator allows to iterate through a given ObjectList 63 /** 64 @brief The Iterator allows to iterate through a given ObjectList. 65 66 Independent of the object-list's type, the objects in the list are always casted 67 to @a T using @c dynamic_cast. 68 69 @see See @ref IteratorExample "Iterator.h" for more information an example. 70 */ 55 71 template <class T = OrxonoxClass> 56 72 class Iterator … … 200 216 @return The Iterator itself 201 217 */ 202 inline Iterator<T> operator++(int i)218 inline Iterator<T> operator++(int) 203 219 { 204 220 Iterator<T> copy = *this; -
code/trunk/src/libraries/core/Language.cc
r7284 r7401 168 168 @brief Returns the localisation of a given entry. 169 169 @param label The label of the entry 170 @param bError If true, an error is printed if the label doesn't exist and the default localisation is returned. If false, no error is printed and an empty string is returned. 170 171 @return The localisation 171 172 */ -
code/trunk/src/libraries/core/Language.h
r7284 r7401 28 28 29 29 /** 30 @defgroup Language Language 31 @ingroup Core 32 */ 33 34 /** 30 35 @file 31 @brief Definition of the Language and the LanguageEntry class. 36 @ingroup Language 37 @brief Declaration of the Language and the LanguageEntry class, as well as some helper functions. 38 39 @anchor LanguageExample 32 40 33 41 The Language class is used, to get a localisation of a string in the configured language. … … 37 45 Usage: 38 46 - Set the entry with the default string: 47 @code 39 48 Language::getInstance()->addEntry("label of the entry", "the string to translate"); 49 @endcode 40 50 41 51 - Get the localisation of the entry in the configured language: 52 @code 42 53 std::cout << Language::getInstance()->getLocalisation("name of the entry") << std::endl; 54 @endcode 55 56 Example: 57 @code 58 int age = 20; 59 AddLanguageEntry("user_age", "Age"); 60 std::cout << GetLocalisation("user_age") << ": " << age << std::endl; 61 @endcode 62 63 Resulting output: 64 @code 65 Age: 20 66 @endcode 67 68 The language entry is now defined in @a translation_default.lang: 69 @code 70 user_age=Age 71 @endcode 72 73 We can add a translation for another language, for example @a translation_german.lang: 74 @code 75 user_age=Alter 76 @endcode 77 78 Now change the language in @a orxonox.ini to "german": 79 @code 80 language_ = "german" 81 @endcode 82 83 Now you will see the translated language entry in the resulting output of the above code: 84 @code 85 Alter: 20 86 @endcode 43 87 */ 44 88 … … 58 102 // ### LanguageEntry ### 59 103 // ############################### 60 //! The LanguageEntry class stores the default- and the translated string of a given entry in the language file. 104 /** 105 @brief The LanguageEntry class stores the default- and the translated string of a given entry in the language file. 106 107 This class belongs to the Language class. 108 */ 61 109 class _CoreExport LanguageEntry 62 110 { … … 105 153 // ### Language ### 106 154 // ############################### 107 //! The Language class manges the language files and entries and stores the LanguageEntry objects in a map. 155 /** 156 @brief The Language class manges the language files and entries and stores the LanguageEntry objects in a map. 157 158 @see See @ref LanguageExample "Language.h" for some examples. 159 */ 108 160 class _CoreExport Language : public Singleton<Language> 109 161 { … … 134 186 }; 135 187 136 // !Shortcut function for Language::addEntry188 /// Shortcut function for Language::addEntry 137 189 inline void AddLanguageEntry(const LanguageEntryLabel& label, const std::string& fallbackString) 138 190 { … … 140 192 } 141 193 142 // !Shortcut function for Language::getLocalisation194 /// Shortcut function for Language::getLocalisation 143 195 inline const std::string& GetLocalisation(const LanguageEntryLabel& label) 144 196 { … … 146 198 } 147 199 148 // !Shortcut function for Language::getLocalisation without printing an error in case the label doesn't exist200 /// Shortcut function for Language::getLocalisation without printing an error in case the label doesn't exist 149 201 inline const std::string& GetLocalisation_noerror(const LanguageEntryLabel& label) 150 202 { -
code/trunk/src/libraries/core/Loader.h
r5781 r7401 26 26 * 27 27 */ 28 29 /** 30 @defgroup Loader Loader 31 @ingroup XML 32 */ 33 34 /** 35 @file 36 @ingroup XML Loader 37 */ 28 38 29 39 #ifndef _Loader_H__ -
code/trunk/src/libraries/core/LuaState.h
r7284 r7401 27 27 * 28 28 */ 29 30 /** 31 @defgroup Lua Lua 32 @ingroup Core 33 */ 34 35 /** 36 @file 37 @ingroup Lua 38 */ 29 39 30 40 #ifndef _LuaState_H__ -
code/trunk/src/libraries/core/MemoryArchive.cc
r6417 r7401 54 54 } 55 55 56 DataStreamPtr MemoryArchive::open(const String& filename) const56 DataStreamPtr MemoryArchive::open(const Ogre::String& filename) const 57 57 { 58 58 const FileMap& files = archives_s[this->getName()]; … … 64 64 } 65 65 66 void MemoryArchive::findFiles(const String& pattern, bool bRecursive,67 bool bDirs, StringVector* simpleList,FileInfoList* detailList)66 void MemoryArchive::findFiles(const Ogre::String& pattern, bool bRecursive, 67 bool bDirs, Ogre::StringVector* simpleList, Ogre::FileInfoList* detailList) 68 68 { 69 69 const FileMap& files = archives_s[this->getName()]; … … 110 110 } 111 111 112 StringVectorPtr MemoryArchive::find(const String& pattern,112 StringVectorPtr MemoryArchive::find(const Ogre::String& pattern, 113 113 bool recursive, bool dirs) 114 114 { … … 118 118 } 119 119 120 FileInfoListPtr MemoryArchive::findFileInfo(const String& pattern,120 FileInfoListPtr MemoryArchive::findFileInfo(const Ogre::String& pattern, 121 121 bool recursive, bool dirs) 122 122 { … … 126 126 } 127 127 128 bool MemoryArchive::exists(const String& filename)128 bool MemoryArchive::exists(const Ogre::String& filename) 129 129 { 130 130 const FileMap& files = archives_s[this->getName()]; -
code/trunk/src/libraries/core/MemoryArchive.h
r6417 r7401 26 26 * 27 27 */ 28 29 /** 30 @file 31 @ingroup Management Resources 32 */ 28 33 29 34 #ifndef _MemoryArchive_H__ -
code/trunk/src/libraries/core/MetaObjectList.h
r5738 r7401 29 29 /** 30 30 @file 31 @brief Definition of the MetaObjectList class. 31 @ingroup Object ObjectList 32 @brief Declaration of the MetaObjectList class. 32 33 33 34 The MetaObjectList is a single-linked list, containing all list-elements and their … … 46 47 // ### MetaObjectListElement ### 47 48 // ############################### 48 // !The list-element of the MetaObjectList49 /// The list-element of the MetaObjectList 49 50 class _CoreExport MetaObjectListElement 50 51 { … … 65 66 // ### MetaObjectList ### 66 67 // ############################### 67 //! The MetaObjectList contains ObjectListBaseElements and their ObjectListBases.68 68 /** 69 @brief The MetaObjectList contains ObjectListBaseElements and their ObjectListBases. 70 69 71 The MetaObjectList is a single-linked list, containing all list-elements and their 70 72 lists wherein the object that owns the MetaObjectList is registered. -
code/trunk/src/libraries/core/Namespace.cc
r6417 r7401 55 55 } 56 56 57 /**58 @brief XML loading and saving.59 @param xmlelement The XML-element60 @param loading Loading (true) or saving (false)61 @return The XML-element62 */63 57 void Namespace::XMLPort(Element& xmlelement, XMLPort::Mode mode) 64 58 { -
code/trunk/src/libraries/core/Namespace.h
r5781 r7401 26 26 * 27 27 */ 28 29 /** 30 @file 31 @ingroup XML Loader 32 */ 28 33 29 34 #ifndef _Namespace_H__ -
code/trunk/src/libraries/core/NamespaceNode.h
r5781 r7401 26 26 * 27 27 */ 28 29 /** 30 @file 31 @ingroup XML Loader 32 */ 28 33 29 34 #ifndef _NamespaceNode_H__ -
code/trunk/src/libraries/core/ObjectList.h
r7278 r7401 28 28 29 29 /** 30 @defgroup ObjectList Object-lists and iterators 31 @ingroup Object 32 */ 33 34 /** 30 35 @file 31 @brief Definition and implementation of the ObjectList class. 36 @ingroup Object ObjectList 37 @brief Definition of the ObjectList class, a wrapper of ObjectListBase. 32 38 33 The ObjectList is a wrapper of an ObjectListBase of a given class. 34 Use Iterator<class> to iterate through all objects of the class. 39 @ref orxonox::ObjectList "ObjectList<T>" is a wrapper of an @ref orxonox::ObjectListBase 40 "ObjectListBase" of class @a T. Use @ref orxonox::ObjectListIterator "ObjectListIterator<T>" 41 to iterate through the list. 35 42 */ 36 43 … … 49 56 // ### ObjectList ### 50 57 // ############################### 51 //! The ObjectList contains all objects of the given class.52 58 /** 53 Wraps the ObjectListBase of the corresponding Identifier. 54 Use ObjectListIterator<class> to iterate through all objects in the list. 59 @brief The ObjectList contains all objects of the given class. 60 61 Wraps the ObjectListBase which contains all objects of type @a T. Use @ref ObjectListIterator 62 "ObjectListIterator<T>" or its typedef ObjectList<T>::iterator to iterate through all objects 63 in the list. 55 64 */ 56 65 template <class T> … … 60 69 typedef ObjectListIterator<T> iterator; 61 70 62 / ** @brief Returns an Iterator to the first element in the list. @return The Iterator */71 /// Returns an Iterator to the first element in the list. 63 72 inline static ObjectListElement<T>* begin() 64 73 { … … 67 76 } 68 77 69 / ** @brief Returns an Iterator to the element after the last element in the list. @return The Iterator */78 /// Returns an Iterator to the element after the last element in the list. 70 79 inline static ObjectListElement<T>* end() 71 80 { … … 74 83 } 75 84 76 / ** @brief Returns an Iterator to the last element in the list. @return The Iterator */85 /// Returns an Iterator to the last element in the list. 77 86 inline static ObjectListElement<T>* rbegin() 78 87 { … … 81 90 } 82 91 83 / ** @brief Returns an Iterator to the element before the first element in the list. @return The Iterator */92 /// Returns an Iterator to the element before the first element in the list. 84 93 inline static ObjectListElement<T>* rend() 85 94 { -
code/trunk/src/libraries/core/ObjectListBase.cc
r5738 r7401 30 30 @file 31 31 @brief Implementation of the ObjectListBase class. 32 33 The ObjectListBase is a double-linked list, used by Identifiers to store all objects of a given class.34 Newly created objects are added through the RegisterObject-macro in its constructor.35 32 */ 36 33 … … 70 67 /** 71 68 @brief Increases all Iterators that currently point on the given element (because it gets removed). 72 @param element The element that gets removed69 @param object The object that gets removed 73 70 */ 74 71 void ObjectListBase::notifyIterators(OrxonoxClass* object) const … … 82 79 /** 83 80 @brief Adds a new object to the end of the list. 84 @param object The object to add81 @param element The element to add 85 82 @return The pointer to the new ObjectListBaseElement, needed by the MetaObjectList of the added object 86 83 */ -
code/trunk/src/libraries/core/ObjectListBase.h
r5738 r7401 29 29 /** 30 30 @file 31 @brief Definition of the ObjectListBase class. 31 @ingroup Object ObjectList 32 @brief Declaration of the ObjectListBase class which stores all objects of each class. 32 33 33 The ObjectListBase is a double-linked list, used by Identifiers to store all objects of a given class. 34 Newly created objects are added through the RegisterObject-macro in its constructor. 34 orxonox::ObjectListBase is a double-linked list, used by @ref orxonox::Identifier "Identifiers" 35 to store all objects of a given class. Newly created objects are added to the list through the 36 @c RegisterObject() macro in the constructor. 35 37 */ 36 38 … … 48 50 // ### ObjectListBaseElement ### 49 51 // ############################### 50 // !The list-element of the ObjectListBase52 /// The list-element of the ObjectListBase 51 53 class _CoreExport ObjectListBaseElement 52 54 { … … 54 56 /** 55 57 @brief Constructor: Creates the list-element with an object. 56 @param object The object to store58 @param objectBase The object to store 57 59 */ 58 60 ObjectListBaseElement(OrxonoxClass* objectBase) : next_(0), prev_(0), objectBase_(objectBase) {} … … 67 69 // ### ObjectListElement ### 68 70 // ############################### 69 // !The list-element that actually contains the object71 /// The list-element that actually contains the object 70 72 template <class T> 71 73 class ObjectListElement : public ObjectListBaseElement … … 80 82 // ### ObjectListBase ### 81 83 // ############################### 82 //! The ObjectListBase contains all objects of a given class.83 84 /** 84 The ObjectListBase is used by Identifiers to store all objects of their given class. 85 Use ObjectList<T> to get the list of all T's and Iterator<T> to iterate through them. 85 @brief The ObjectListBase contains all objects of a given class. 86 87 The ObjectListBase is used by Identifiers to store all objects of their class. 88 You can use Identifier::getObjects() to get the object-list from an Identifier. 89 Use @ref Iterator "Iterator<T>" to iterate through them. 90 91 Alternatively you can also use the static helper class @ref orxonox::ObjectList "ObjectList<T>" 92 to get the list of all objects of type @a T. Use @ref ObjectListIterator "ObjectListIterator<T>" 93 or @ref Iterator "Iterator<T>" to iterate through them. 86 94 */ 87 95 class _CoreExport ObjectListBase … … 95 103 ObjectListBaseElement* add(ObjectListBaseElement* element); 96 104 105 /// Helper struct, used to export an element and the list to an instance of Iterator. 97 106 struct Export 98 107 { … … 102 111 }; 103 112 104 / ** @brief Returns a pointer to the first element in the list. @return The element */113 /// Returns a pointer to the first element in the list. Works only with Iterator. 105 114 inline Export begin() { return ObjectListBase::Export(this, this->first_); } 106 / ** @brief Returns a pointer to the element after the last element in the list. @return The element */115 /// Returns a pointer to the element after the last element in the list. Works only with Iterator. 107 116 inline Export end() { return ObjectListBase::Export(this, 0); } 108 / ** @brief Returns a pointer to the last element in the list. @return The element */117 /// Returns a pointer to the last element in the list. Works only with Iterator. 109 118 inline Export rbegin() { return ObjectListBase::Export(this, this->last_); } 110 / ** @brief Returns a pointer to the element in front of the first element in the list. @return The element */119 /// Returns a pointer to the element in front of the first element in the list. Works only with Iterator. 111 120 inline Export rend() { return ObjectListBase::Export(this, 0); } 112 121 -
code/trunk/src/libraries/core/ObjectListIterator.h
r7268 r7401 29 29 /** 30 30 @file 31 @brief Definition and implementation of the Iterator class. 32 33 The ObjectListIterator of a given class allows to iterate through the 34 ObjectList of this class, containing all objects of that type. 35 This is the only way to access the objects stored in an ObjectList. 31 @ingroup Object ObjectList 32 @brief Definition of the ObjectListIterator class, used to iterate through object-lists. 33 34 @anchor ObjectListIteratorExample 35 36 @ref orxonox::ObjectListIterator "ObjectListIterator<T>" allows to iterate through 37 @ref orxonox::ObjectList "ObjectList<T>", containing all objects of type @a T. In contrast to 38 @ref orxonox::Iterator "Iterator<T>", this iterator is limited to the object-list of type @a T. 39 It is, however, much faster as it doesn't need a @c dynamic_cast. 36 40 37 41 Usage: 42 @code 38 43 for (ObjectListIterator<myClass> it = ObjectList<myClass>::begin(); it != ObjectList<myClass>::end(); ++it) 39 44 { … … 41 46 myClass* myObject = *it; 42 47 } 48 @endcode 49 50 @note @ref orxonox::ObjectList::iterator "ObjectList<T>::iterator" is identical to 51 @ref orxonox::ObjectListIterator "ObjectListIterator<T>" (it's just a typedef). 43 52 */ 44 53 … … 52 61 namespace orxonox 53 62 { 54 //! The Iterator allows to iterate through the ObjectList of a given class. 63 /** 64 @brief ObjectListIterator<T> allows to iterate through the ObjectList of class @a T. 65 66 @see See @ref ObjectListIteratorExample "ObjectListIterator.h" for more information an example. 67 */ 55 68 template <class T> 56 69 class ObjectListIterator … … 109 122 /** 110 123 @brief Assigns the element of another ObjectListIterator. 111 @param elementThe other ObjectListIterator124 @param other The other ObjectListIterator 112 125 */ 113 126 inline ObjectListIterator<T>& operator=(const ObjectListIterator<T>& other) … … 131 144 @return The ObjectListIterator itself 132 145 */ 133 inline ObjectListIterator<T> operator++(int i)146 inline ObjectListIterator<T> operator++(int) 134 147 { 135 148 ObjectListIterator<T> copy = *this; … … 217 230 218 231 private: 219 ObjectListElement<T>* element_; //!< The element the Iterator points at232 ObjectListElement<T>* element_; //!< The element the iterator points at 220 233 }; 221 234 } -
code/trunk/src/libraries/core/OrxonoxClass.cc
r6417 r7401 29 29 /** 30 30 @file 31 @brief Implementation of the OrxonoxClassClass.31 @brief Implementation of OrxonoxClass. 32 32 */ 33 33 … … 41 41 namespace orxonox 42 42 { 43 /** @brief Constructor: Sets the default values. */ 43 /** 44 @brief Constructor: Sets the default values. 45 */ 44 46 OrxonoxClass::OrxonoxClass() 45 47 { … … 53 55 } 54 56 55 /** @brief Destructor: Deletes, if existing, the list of the parents. */ 57 /** 58 @brief Destructor: Removes the object from the object-lists, notifies all @ref WeakPtr "weak pointers" that this object is being deleted. 59 */ 56 60 OrxonoxClass::~OrxonoxClass() 57 61 { … … 72 76 } 73 77 74 /** @brief Deletes the object if no smart pointers point to this object. Otherwise schedules the object to be deleted as soon as possible. */ 78 /** 79 @brief Deletes the object if no @ref orxonox::SmartPtr "smart pointers" point to this object. Otherwise schedules the object to be deleted as soon as possible. 80 */ 75 81 void OrxonoxClass::destroy() 76 82 { … … 85 91 } 86 92 93 /** 94 @brief Removes this object from the object-lists. 95 */ 87 96 void OrxonoxClass::unregisterObject() 88 97 { … … 92 101 } 93 102 94 / ** @brief Returns true if the objects class is of the given type or a derivative. */103 /// Returns true if the object's class is of the given type or a derivative. 95 104 bool OrxonoxClass::isA(const Identifier* identifier) 96 105 { return this->getIdentifier()->isA(identifier); } 97 / ** @brief Returns true if the objects class is exactly of the given type. */106 /// Returns true if the object's class is exactly of the given type. 98 107 bool OrxonoxClass::isExactlyA(const Identifier* identifier) 99 108 { return this->getIdentifier()->isExactlyA(identifier); } 100 / ** @brief Returns true if the objects class is a child of the given type. */109 /// Returns true if the object's class is a child of the given type. 101 110 bool OrxonoxClass::isChildOf(const Identifier* identifier) 102 111 { return this->getIdentifier()->isChildOf(identifier); } 103 / ** @brief Returns true if the objects class is a direct child of the given type. */112 /// Returns true if the object's class is a direct child of the given type. 104 113 bool OrxonoxClass::isDirectChildOf(const Identifier* identifier) 105 114 { return this->getIdentifier()->isDirectChildOf(identifier); } 106 / ** @brief Returns true if the objects class is a parent of the given type. */115 /// Returns true if the object's class is a parent of the given type. 107 116 bool OrxonoxClass::isParentOf(const Identifier* identifier) 108 117 { return this->getIdentifier()->isParentOf(identifier); } 109 / ** @brief Returns true if the objects class is a direct parent of the given type. */118 /// Returns true if the object's class is a direct parent of the given type. 110 119 bool OrxonoxClass::isDirectParentOf(const Identifier* identifier) 111 120 { return this->getIdentifier()->isDirectParentOf(identifier); } 112 121 113 122 114 / ** @brief Returns true if the objects class is of the given type or a derivative. */123 /// Returns true if the object's class is of the given type or a derivative. 115 124 bool OrxonoxClass::isA(const OrxonoxClass* object) 116 125 { return this->getIdentifier()->isA(object->getIdentifier()); } 117 / ** @brief Returns true if the objects class is exactly of the given type. */126 /// Returns true if the object's class is exactly of the given type. 118 127 bool OrxonoxClass::isExactlyA(const OrxonoxClass* object) 119 128 { return this->getIdentifier()->isExactlyA(object->getIdentifier()); } 120 / ** @brief Returns true if the objects class is a child of the given type. */129 /// Returns true if the object's class is a child of the given type. 121 130 bool OrxonoxClass::isChildOf(const OrxonoxClass* object) 122 131 { return this->getIdentifier()->isChildOf(object->getIdentifier()); } 123 / ** @brief Returns true if the objects class is a direct child of the given type. */132 /// Returns true if the object's class is a direct child of the given type. 124 133 bool OrxonoxClass::isDirectChildOf(const OrxonoxClass* object) 125 134 { return this->getIdentifier()->isDirectChildOf(object->getIdentifier()); } 126 / ** @brief Returns true if the objects class is a parent of the given type. */135 /// Returns true if the object's class is a parent of the given type. 127 136 bool OrxonoxClass::isParentOf(const OrxonoxClass* object) 128 137 { return this->getIdentifier()->isParentOf(object->getIdentifier()); } 129 / ** @brief Returns true if the objects class is a direct child of the given type. */138 /// Returns true if the object's class is a direct child of the given type. 130 139 bool OrxonoxClass::isDirectParentOf(const OrxonoxClass* object) 131 140 { return this->getIdentifier()->isDirectParentOf(object->getIdentifier()); } -
code/trunk/src/libraries/core/OrxonoxClass.h
r7163 r7401 28 28 29 29 /** 30 @defgroup OrxonoxClass OrxonoxClass 31 @ingroup Class 32 */ 33 34 /** 30 35 @file 31 @brief Declaration of the OrxonoxClass Class. 36 @ingroup Class OrxonoxClass 37 @brief Declaration of OrxonoxClass, the base class of all objects and interfaces in Orxonox. 32 38 33 39 All objects and interfaces of the game-logic (not the engine) are derived from OrxonoxClass. … … 53 59 namespace orxonox 54 60 { 55 //! The class all objects and interfaces of the game-logic (not the engine) are derived from.56 61 /** 57 The BaseObject and Interfaces are derived with 'virtual public OrxonoxClass' from OrxonoxClass. 58 OrxonoxClass is needed to create the class-hierarchy at startup and to store the Identifier and the MetaObjectList. 62 @brief The class all objects and interfaces of the game-logic (not the engine) are derived from. 63 64 The BaseObject and Interfaces are derived with @c virtual @c public @c OrxonoxClass from OrxonoxClass. 65 OrxonoxClass is needed to create the class-hierarchy at startup and to store the Identifier and the 66 MetaObjectList, as well as to provide an interface for SmartPtr and WeakPtr. 59 67 */ 60 68 class _CoreExport OrxonoxClass … … 76 84 void unregisterObject(); 77 85 78 / ** @brief Function to collect the SetConfigValue-macro calls. */86 /// Function to collect the SetConfigValue-macro calls. 79 87 void setConfigValues() {}; 80 88 81 / ** @brief Returns the Identifier of the object. @return The Identifier */89 /// Returns the Identifier of the object. 82 90 inline Identifier* getIdentifier() const { return this->identifier_; } 83 91 … … 89 97 bool isDirectParentOf(const Identifier* identifier); 90 98 99 /// Returns true if the object's class is of the given type or a derivative. 91 100 template <class B> inline bool isA(const SubclassIdentifier<B>* identifier) 92 101 { return this->isA(*identifier); } 102 /// Returns true if the object's class is exactly of the given type. 93 103 template <class B> inline bool isExactlyA(const SubclassIdentifier<B>* identifier) 94 104 { return this->isExactlyA(*identifier); } 105 /// Returns true if the object's class is a child of the given type. 95 106 template <class B> inline bool isChildOf(const SubclassIdentifier<B>* identifier) 96 107 { return this->isChildOf(*identifier); } 108 /// Returns true if the object's class is a direct child of the given type. 97 109 template <class B> inline bool isDirectChildOf(const SubclassIdentifier<B>* identifier) 98 110 { return this->isDirectChildOf(*identifier); } 111 /// Returns true if the object's class is a parent of the given type. 99 112 template <class B> inline bool isParentOf(const SubclassIdentifier<B>* identifier) 100 113 { return this->isParentOf(*identifier); } 114 /// Returns true if the object's class is a direct parent of the given type. 101 115 template <class B> inline bool isDirectParentOf(const SubclassIdentifier<B>* identifier) 102 116 { return this->isDirectParentOf(*identifier); } … … 111 125 virtual void clone(OrxonoxClass*& item) {} 112 126 127 /// Returns the number of @ref orxonox::SmartPtr "smart pointers" that point to this object. 113 128 inline unsigned int getReferenceCount() const 114 129 { return this->referenceCount_; } … … 131 146 } 132 147 133 // !Version of getDerivedPointer with template148 /// Version of getDerivedPointer with template 134 149 template <class T> FORCEINLINE T* getDerivedPointer(unsigned int classID) 135 150 { return static_cast<T*>(this->getDerivedPointer(classID)); } 136 // !Const version of getDerivedPointer with template151 /// Const version of getDerivedPointer with template 137 152 template <class T> FORCEINLINE const T* getDerivedPointer(unsigned int classID) const 138 153 { return const_cast<OrxonoxClass*>(this)->getDerivedPointer<T>(classID); } 139 154 140 155 protected: 156 /// This virtual function is called if destroy() is called and no SmartPtr points to this object. Used in some cases to create a new SmartPtr to prevent destruction. 141 157 virtual void preDestroy() {} 142 158 143 159 private: 144 / ** @brief Increments the reference counter (for smart pointers). */160 /// Increments the reference counter (for smart pointers). 145 161 inline void incrementReferenceCount() 146 162 { ++this->referenceCount_; } 147 / ** @brief Decrements the reference counter (for smart pointers). */163 /// Decrements the reference counter (for smart pointers). 148 164 inline void decrementReferenceCount() 149 165 { … … 153 169 } 154 170 155 / ** @brief Register a weak pointer which points to this object. */171 /// Register a weak pointer which points to this object. 156 172 template <class T> 157 173 inline void registerWeakPtr(WeakPtr<T>* pointer) 158 174 { this->weakPointers_.insert(reinterpret_cast<WeakPtr<OrxonoxClass>*>(pointer)); } 159 / ** @brief Unegister a weak pointer which pointed to this object before. */175 /// Unegister a weak pointer which pointed to this object before. 160 176 template <class T> 161 177 inline void unregisterWeakPtr(WeakPtr<T>* pointer) 162 178 { this->weakPointers_.erase(reinterpret_cast<WeakPtr<OrxonoxClass>*>(pointer)); } 163 179 164 Identifier* identifier_; //!< The Identifier of the object165 std::set<const Identifier*>* parents_; //!< List of all parents of the object166 MetaObjectList* metaList_; //!< MetaObjectList, containing all ObjectLists and ObjectListElements the object is registered in167 int referenceCount_; //!< Counts the references from smart pointers to this object168 bool requestedDestruction_; //!< Becomes true after someone called delete on this object169 std::set<WeakPtr<OrxonoxClass>*> weakPointers_; //!< All weak pointers which point to this object (and like to get notified if it dies)180 Identifier* identifier_; //!< The Identifier of the object 181 std::set<const Identifier*>* parents_; //!< List of all parents of the object 182 MetaObjectList* metaList_; //!< MetaObjectList, containing all ObjectLists and ObjectListElements the object is registered in 183 int referenceCount_; //!< Counts the references from smart pointers to this object 184 bool requestedDestruction_; //!< Becomes true after someone called delete on this object 185 std::set<WeakPtr<OrxonoxClass>*> weakPointers_; //!< All weak pointers which point to this object (and like to get notified if it dies) 170 186 171 // !'Fast map' that holds this-pointers of all derived types187 /// 'Fast map' that holds this-pointers of all derived types 172 188 std::vector<std::pair<unsigned int, void*> > objectPointers_; 173 189 }; -
code/trunk/src/libraries/core/PathConfig.h
r6417 r7401 26 26 * 27 27 */ 28 29 /** 30 @file 31 @ingroup Management Resources 32 */ 28 33 29 34 #ifndef _PathConfig_H__ -
code/trunk/src/libraries/core/Resource.h
r6746 r7401 26 26 * 27 27 */ 28 29 /** 30 @defgroup Resources Resources 31 @ingroup Management 32 */ 33 34 /** 35 @file 36 @ingroup Management Resources 37 */ 28 38 29 39 #ifndef _Core_Resource_H__ … … 105 115 /** 106 116 Find out if the named file exists. 107 @param filename117 @param name 108 118 Fully qualified name of the file to test for 109 119 */ … … 112 122 /** 113 123 Get struct with information about path and size. 114 @param filename124 @param name 115 125 Fully qualified name of the file to test for 116 126 */ -
code/trunk/src/libraries/core/SmartPtr.h
r7268 r7401 29 29 // Inspired by boost::intrusive_ptr by Peter Dimov 30 30 31 /** 32 @defgroup SmartPtr SmartPtr<T> and WeakPtr<T> 33 @ingroup Object 34 */ 35 36 /** 37 @file 38 @ingroup Object SmartPtr 39 @brief Definition of SmartPtr<T>, wraps a pointer to an object and keeps it alive. 40 41 @anchor SmartPtrExample 42 43 orxonox::SmartPtr is an implementation of a smart pointer - it wraps a pointer to an 44 object and keeps this object alive until no SmartPtr points to this object anymore. 45 In contrast to orxonox::SharedPtr, SmartPtr works only with classes that are derived 46 from orxonox::OrxonoxClass, because it's an intrusive implementation, meaning the 47 reference counter is stored in the object itself. 48 49 It's possible to use normal pointers and smart pointers to an object simultaneously. 50 You don't have to use SmartPtr all the time, you can create a SmartPtr for an object 51 at any time and also convert it back to a normal pointer if you like. This is possible 52 because the reference counter is stored in the object itself and not in SmartPtr (in 53 contrast to SharedPtr). 54 55 @b Important: If you want to delete an object, you must not use @c delete @c object but 56 rather @c object->destroy(). This function will check if there are smart pointers 57 pointing to the object. If yes, the object will be kept alive until all smart pointes 58 are destroyed. If no, the object is deleted instantly. 59 60 If all smart pointers that point to an object are destroyed, but you never called 61 @c object->destroy() before, the object will not be deleted! All a SmartPtr will do 62 is to really just keep an object alive, but it will not delete it automatically 63 unless you tried to destroy it before. 64 65 Example: 66 @code 67 class MyClass // class declaration 68 { 69 public: 70 void setObject(OtherClass* object) // passes a normal pointer which will be stored in a SmartPtr 71 { this->object_ = object; } 72 73 OtherClass* getObject() const // converts the SmartPtr to a normal pointer and returns it 74 { return this->object_; } 75 76 private: 77 SmartPtr<OtherClass> object_; // a pointer to an instance of OtherClass is stored in a SmartPtr 78 }; 79 @endcode 80 In this example we assume that OtherClass is a child of OrxonoxClass. We don't care 81 about the inheritance of MyClass though. 82 83 Now we create an instance of MyClass and assign a pointer to an instance of OtherClass: 84 @code 85 MyClass* myclass = new MyClass(); // create an instance of MyClass 86 OtherClass* object = new OtherClass(); // create an instance of OtherClass 87 myclass->setObject(object); // the object is now stored in a SmartPtr inside myclass 88 89 object->destroy(); // we try to destroy object, but there's still a SmartPtr pointing at it. 90 91 # object still exists at this point (because a SmartPtr points at it) 92 93 delete myclass; // now we delete myclass, which also destroys the SmartPtr 94 95 # object doesn't exist anymore (because the SmartPtr is now destroyed) 96 @endcode 97 98 Now we look at the same example, but we first delete myclass, then destroy object: 99 @code 100 MyClass* myclass = new MyClass(); // create an instance of MyClass 101 OtherClass* object = new OtherClass(); // create an instance of OtherClass 102 myclass->setObject(object); // the object is now stored in a SmartPtr inside myclass 103 104 delete myclass; // we delete myclass, which also destroys the SmartPtr 105 106 # object still exists at this point (because destroy() was not called yet) 107 108 object->destroy(); // now we try to destroy object, which works instantly 109 110 # object doesn't exist anymore (because we just destroyed it) 111 @endcode 112 113 Note that in any case @c object->destroy() has to be called to delete the object. 114 However if a SmartPtr points at it, the destruction is delayed until all SmartPtr 115 are destroyed. 116 */ 117 31 118 #ifndef _SmartPtr_H__ 32 119 #define _SmartPtr_H__ … … 42 129 namespace orxonox 43 130 { 131 /** 132 @brief A smart pointer which wraps a pointer to an object and keeps this object alive as long as the smart pointer exists. 133 134 @see See @ref SmartPtrExample "this description" for more information and an example. 135 */ 44 136 template <class T> 45 137 class SmartPtr 46 138 { 47 139 public: 140 /// Constructor: Initializes the smart pointer with a null pointer. 48 141 inline SmartPtr() : pointer_(0), base_(0) 49 142 { 50 143 } 51 144 145 /// Constructor: Used to explicitly initialize the smart pointer with a null pointer 52 146 inline SmartPtr(int) : pointer_(0), base_(0) 53 147 { 54 148 } 55 149 150 /// Constructor: Initializes the smart pointer with a pointer to an object. @param pointer The pointer @param bAddRef If true, the reference counter is increased. Don't set this to false unless you know exactly what you're doing! (for example to avoid circular references if the @c this pointer of the possessing object is stored) 56 151 inline SmartPtr(T* pointer, bool bAddRef = true) : pointer_(pointer), base_(pointer) 57 152 { … … 60 155 } 61 156 157 /// Copy-constructor 62 158 inline SmartPtr(const SmartPtr& other) : pointer_(other.pointer_), base_(other.base_) 63 159 { … … 66 162 } 67 163 164 /// Copy-constructor for smart pointers to objects of another class. 68 165 template <class O> 69 166 inline SmartPtr(const SmartPtr<O>& other) : pointer_(other.get()), base_(other.base_) … … 73 170 } 74 171 172 /// Constructor: Initializes the smart pointer with the pointer that is stored in a WeakPtr. 75 173 template <class O> 76 174 inline SmartPtr(const WeakPtr<O>& other) : pointer_(other.get()), base_(other.getBase()) … … 80 178 } 81 179 180 /// Destructor: Decrements the reference counter. 82 181 inline ~SmartPtr() 83 182 { … … 86 185 } 87 186 187 /// Used to assign a null pointer. 88 188 inline SmartPtr& operator=(int) 89 189 { … … 92 192 } 93 193 194 /// Assigns a new pointer. 94 195 inline SmartPtr& operator=(T* pointer) 95 196 { … … 98 199 } 99 200 201 /// Assigns the wrapped pointer of another SmartPtr. 100 202 inline SmartPtr& operator=(const SmartPtr& other) 101 203 { … … 104 206 } 105 207 208 /// Assigns the wrapped pointer of a SmartPtr of another class 106 209 template <class O> 107 210 inline SmartPtr& operator=(const SmartPtr<O>& other) … … 111 214 } 112 215 216 /// Assigns the wrapped pointer of a WeakPtr. 113 217 template <class O> 114 218 inline SmartPtr& operator=(const WeakPtr<O>& other) … … 118 222 } 119 223 224 /// Returns the wrapped pointer as @c T* 120 225 inline T* get() const 121 226 { … … 123 228 } 124 229 230 /// Returns the wrapped pointer as @c OrxonoxClass* 125 231 inline OrxonoxClass* getBase() const 126 232 { … … 128 234 } 129 235 236 /// Implicitly converts the SmartPtr to a pointer of type @c T* 130 237 inline operator T*() const 131 238 { … … 133 240 } 134 241 242 /// Overloaded operator, returns a pointer to the stored object. 135 243 inline T* operator->() const 136 244 { … … 139 247 } 140 248 249 /// Overloaded operator, returns a reference to the stored object. 141 250 inline T& operator*() const 142 251 { … … 145 254 } 146 255 256 /// Returns true if the wrapped pointer is NULL. 147 257 inline bool operator!() const 148 258 { … … 150 260 } 151 261 262 /// Swaps the contents of two smart pointers. 152 263 inline void swap(SmartPtr& other) 153 264 { … … 164 275 } 165 276 277 /// Resets the smart pointer (equivalent to assigning a NULL pointer). 166 278 inline void reset() 167 279 { … … 170 282 171 283 private: 172 T* pointer_; 173 OrxonoxClass* base_; 284 T* pointer_; ///< The wrapped pointer to an object of type @a T 285 OrxonoxClass* base_; ///< The wrapped pointer, casted up to OrxonoxClass (this is needed because with just a T* pointer, SmartPtr couln't be used with forward declarations) 174 286 }; 175 287 288 /// Swaps the contents of two smart pointers. 176 289 template <class T> 177 290 void swap(SmartPtr<T>& a, SmartPtr<T>& b) … … 180 293 } 181 294 295 /// Uses a static_cast to cast a pointer of type U* to a pointer of type T* and returns it in a new SmartPtr<T>. 182 296 template <class T, class U> 183 297 SmartPtr<T> static_pointer_cast(const SmartPtr<U>& p) … … 186 300 } 187 301 302 /// Uses a const_cast to cast a pointer of type U* to a pointer of type T* and returns it in a new SmartPtr<T>. 188 303 template <class T, class U> 189 304 SmartPtr<T> const_pointer_cast(const SmartPtr<U>& p) … … 192 307 } 193 308 309 /// Uses a dynamic_cast to cast a pointer of type U* to a pointer of type T* and returns it in a new SmartPtr<T>. 194 310 template <class T, class U> 195 311 SmartPtr<T> dynamic_pointer_cast(const SmartPtr<U>& p) -
code/trunk/src/libraries/core/SubclassIdentifier.h
r7268 r7401 29 29 /** 30 30 @file 31 @ingroup Class Identifier 31 32 @brief Definition of SubclassIdentifier. 33 34 @anchor SubclassIdentifierExample 32 35 33 36 SubclassIdentifier is a separated class, acting like an Identifier, but has a given class. 34 37 You can only assign Identifiers of exactly the given class or of a derivative to a SubclassIdentifier. 38 39 Example: 40 41 You can assign an Identifier either through the constructor or by using the assignment @c operator=: 42 @code 43 SubclassIdentifier<BaseClass> identifier = Class(SubClass); 44 @endcode 45 46 The @c operator-> is overloaded an returns the assigned Identifier. That way you can just call 47 functions of the assigned Identifier by using @c ->function(): 48 @code 49 SubclassIdentifier<BaseClass> identifier = Class(SubClass); 50 identifier->getName(); // returns "SubClass" 51 @endcode 52 53 There are two possibilities to create an object out of a SubclassIdentifier: Either you just use 54 the @c fabricate() function of the assigned Identifier through the overloaded @c operator->, which 55 returns a @c BaseObject* pointer, or you use the function of SubclassIdentifier, this time by using 56 @c operator., which returns a @c BaseClass* pointer (@a BaseClass is the baseclass specified by the 57 template argument): 58 @code 59 identifier->fabricate(); // calls Identifier::fabricate(), creates a SubClass, returns a BaseObject* pointer 60 61 identifier.fabricate(); // calls SubclassIdentifier::fabricate(), creates a SubClass, returns a BaseClass* pointer 62 @endcode 35 63 */ 36 64 … … 49 77 // ### SubclassIdentifier ### 50 78 // ############################### 51 //! The SubclassIdentifier acts almost like an Identifier, but has some prerequisites.52 79 /** 80 @brief The SubclassIdentifier acts almost like an Identifier, but has some prerequisites. 81 53 82 You can only assign an Identifier that belongs to a class T (or derived) to a SubclassIdentifier<T>. 54 If you assign something else, the program aborts. 55 Because we know the minimum type, a dynamic_cast is done, which makes it easier to create a new object. 83 If you assign something else, the program prints an error. 84 85 Because we know the base-type, a @c dynamic_cast is done, which makes it easier to create a new object. 86 87 @see See @ref SubclassIdentifierExample "SubclassIdentifier.h" for some examples. 56 88 */ 57 89 template <class T> … … 59 91 { 60 92 public: 61 /** 62 @brief Constructor: Automaticaly assigns the Identifier of the given class. 63 */ 93 /// Constructor: Automaticaly assigns the Identifier of the given class. 64 94 SubclassIdentifier() 65 95 { … … 67 97 } 68 98 69 /** 70 @brief Constructor: Assigns the given Identifier. 71 @param identifier The Identifier 72 */ 99 /// Constructor: Assigns the given Identifier. 73 100 SubclassIdentifier(Identifier* identifier) 74 101 { … … 76 103 } 77 104 78 /** 79 @brief Copyconstructor: Assigns the identifier of the other SubclassIdentifier. 80 @param identifier The other SublcassIdentifier 81 */ 105 /// Copyconstructor: Assigns the identifier of another SubclassIdentifier. 82 106 template <class O> 83 107 SubclassIdentifier(const SubclassIdentifier<O>& identifier) … … 113 137 } 114 138 115 /** 116 @brief Overloading of the = operator: assigns the identifier of the other SubclassIdentifier. 117 @param identifier The other SublcassIdentifier 118 */ 139 /// Overloading of the = operator: assigns the identifier of another SubclassIdentifier. 119 140 template <class O> 120 141 SubclassIdentifier<T>& operator=(const SubclassIdentifier<O>& identifier) … … 123 144 } 124 145 125 /** 126 @brief Overloading of the * operator: returns the assigned identifier. 127 */ 146 /// Overloading of the * operator: returns the assigned identifier. 128 147 inline Identifier* operator*() const 129 148 { … … 131 150 } 132 151 133 /** 134 @brief Overloading of the -> operator: returns the assigned identifier. 135 */ 152 /// Overloading of the -> operator: returns the assigned identifier. 136 153 inline Identifier* operator->() const 137 154 { … … 139 156 } 140 157 141 /** 142 @brief Returns the assigned identifier. This allows you to assign a SubclassIdentifier to a normal Identifier*. 143 */ 158 /// Returns the assigned identifier. This allows you to assign a SubclassIdentifier to a normal Identifier*. 144 159 inline operator Identifier*() const 145 160 { … … 147 162 } 148 163 149 /** 150 @brief Creates a new object of the type of the assigned Identifier and dynamic_casts it to the minimal type given by T. 151 @return The new object 152 */ 164 /// Creates a new object of the type of the assigned Identifier and dynamic_casts it to the minimal type given by T. 153 165 T* fabricate(BaseObject* creator) const 154 166 { … … 181 193 } 182 194 183 / ** @brief Returns the assigned identifier. @return The identifier */195 /// Returns the assigned identifier. 184 196 inline Identifier* getIdentifier() const 185 197 { return this->identifier_; } -
code/trunk/src/libraries/core/Super.h
r7163 r7401 28 28 29 29 /** 30 @defgroup Super Super 31 @ingroup Class 32 */ 33 34 /** 30 35 @file 31 @ brief Definition of all super-function related macros.32 33 This file defines all macros needed to add a new "super-function". 34 If you add a super-function, you can call SUPER(myclass, functionname) inside your35 code and the function of the parentclass gets called. This is comparable with36 super.functionname() in Java or other languages.37 38 This works only with virtual functions that return nothing (void) and belong to 39 classes that have an Identifier. Arguments however are supported.40 41 To add a new super-function, you have process 4 steps:42 43 1) Add a new SUPER macro 44 This allows you to call the super-function in your code.45 Location: This file (Super.h), marked with --> HERE <-- comments (1/3) 46 47 2) Call the SUPER_FUNCTION_GLOBAL_DECLARATION_PART1/2 macros.48 This defines some global classes and templates, needed to create and call the super-functions.49 Location: This file (Super.h), marked with --> HERE <-- comments (2/3)50 51 3) Call the SUPER_INTRUSIVE_DECLARATION macro.52 This will be included into the declaration of ClassIdentifier<T>.53 Location: This file (Super.h), marked with --> HERE <-- comments (3/3)54 55 4) Call the SUPER_FUNCTION macro.36 @ingroup Class Super 37 @brief Definition of all super-function related macros, used to call functions of the base class. 38 39 This file defines all macros needed to add a new "super-function". If you add 40 a super-function, you can call <tt>SUPER(myclass, functionname, arguments)</tt> 41 inside your code and the function of the parent-class gets called. This is comparable 42 to <tt>super.functionname(arguments)</tt> in Java or other languages. 43 44 This works only with virtual functions that return nothing (@c void) and belong to 45 classes that have an @ref orxonox::Identifier "Identifier". Arguments however are 46 supported, there's no limitation for their number and type, except that the type has 47 to be known in Super.h. 48 49 To add a new super-function, you have to process 4 steps: 50 51 -# Add a new @c SUPER macro <br /> 52 This allows you to call the super-function in your code. <br /> 53 Location: This file (Super.h), marked with "--> HERE <--" comments (1/3) 54 -# Call the @c SUPER_FUNCTION_GLOBAL_DECLARATION_PART1/2 macros. <br /> 55 This defines some global classes and templates, needed to create and call the super-functions. <br /> 56 Location: This file (Super.h), marked with "--> HERE <--" comments (2/3) 57 -# Call the @c SUPER_INTRUSIVE_DECLARATION macro. <br /> 58 This will be included into the declaration of @c ClassIdentifier<T>. <br /> 59 Location: This file (Super.h), marked with "--> HERE <--" comments (3/3) 60 -# Call the @c SUPER_FUNCTION macro. <br /> 56 61 This defines a partially specialized template that will decide if a class is "super" to another class. 57 If the check returns true, a SuperFunctionCaller gets created, which will be used by theSUPER macro.62 If the check returns true, a @c SuperFunctionCaller gets created, which will be used by the @c SUPER macro. 58 63 You have to add this into the header-file of the baseclass of the super-function (the class that first 59 64 implements the function), below the class declaration. You can't call it directly in this file, because 60 otherwise you had to include the headerfile right here, which would cause some ugly back dependencies,61 include loops and slower compilation. 62 Dont forget to include Super.h in the header-file. 65 otherwise you had to include the headerfile right here, which would cause some ugly back-dependencies, 66 include loops and slower compilation. <br /> 67 Dont forget to include Super.h in the header-file. <br /> 63 68 Location: The header-file of the baseclass (Baseclass.h), below the class declaration 64 69 */ … … 205 210 */ 206 211 207 // SUPER-macro: Calls Parent::functionname() where Parent is the direct parent ofclassname212 /// SUPER-macro: Calls Parent::functionname(...) where Parent is the direct parent of @a classname 208 213 #ifdef ORXONOX_COMPILER_MSVC 209 214 #define SUPER(classname, functionname, ...) \ -
code/trunk/src/libraries/core/Template.h
r7163 r7401 26 26 * 27 27 */ 28 29 /** 30 @defgroup Template Template 31 @ingroup XML 32 */ 33 34 /** 35 @file 36 @ingroup XML Template 37 */ 28 38 29 39 #ifndef _Template_H__ -
code/trunk/src/libraries/core/Thread.h
r7284 r7401 26 26 * 27 27 */ 28 29 /** 30 @file 31 @ingroup ThreadPool 32 */ 28 33 29 34 #ifndef _Thread_H__ -
code/trunk/src/libraries/core/ThreadPool.h
r7284 r7401 26 26 * 27 27 */ 28 29 /** 30 @defgroup ThreadPool Thread pool 31 @ingroup Core 32 */ 33 34 /** 35 @file 36 @ingroup ThreadPool 37 */ 28 38 29 39 #ifndef _ThreadPool_H__ -
code/trunk/src/libraries/core/ToluaInterface.h
r5738 r7401 29 29 /** 30 30 @file 31 @ingroup Lua 32 @brief 31 33 This is required because tolua would parse this macro in LuaState.h and fail 32 34 */ -
code/trunk/src/libraries/core/WeakPtr.h
r7284 r7401 29 29 // Inspired by boost::intrusive_ptr by Peter Dimov 30 30 31 /** 32 @file 33 @ingroup Object SmartPtr 34 @brief Definition of WeakPtr<T>, wraps a pointer to an object. 35 36 @anchor WeakPtrExample 37 38 A WeakPtr wraps a pointer to an object. If the object gets deleted, the WeakPtr becomes 39 NULL. This can be used to store pointers to objects without knowing when they will be 40 destroyed. 41 42 WeakPtr works only with objects that are derived from orxonox::OrxonoxClass, because 43 WeakPtr is intrusive and registers itself in the stored object, to get a notification if 44 the object is being deleted. 45 46 Example: 47 @code 48 MyClass* object = new MyClass(); // create an instance of MyClass 49 50 WeakPtr<MyClass> pointer = object; // create a WeakPtr and assign the object 51 52 if (pointer) // checks if pointer is not NULL (which is true) 53 pointer->someFunction(); // calls MyClass::someFunction() 54 55 object->destroy(); // calls destroy() which deletes the object 56 57 if (pointer) // checks if pointer is not NULL (which is now false) 58 pointer->someFunction(); // this will not be executed 59 @endcode 60 In this example we assumed that MyClass is derived of OrxonoxClass (otherwise it couldn't 61 be used with a WeakPtr). 62 63 A callback can be registerd with the WeakPtr that will be called if the object gets deleted. 64 @code 65 void myCallback() // definition of the callback function 66 { 67 COUT(0) << "Object destroyed" << std::endl; 68 } 69 70 MyClass* object = new MyClass(); // create an instance of MyClass 71 72 WeakPtr<MyClass> pointer = object; // create a WeakPtr and assign the object 73 74 pointer.setCallback(createFunctor(&myCallback)); // defines a callback 75 76 object->destroy(); // calls destroy() which deletes the object. prints "Object destroyed" to the console 77 @endcode 78 */ 79 31 80 #ifndef _WeakPtr_H__ 32 81 #define _WeakPtr_H__ … … 41 90 namespace orxonox 42 91 { 92 /** 93 @brief WeakPtr wraps a pointer to an object, which becomes NULL if the object is deleted. 94 95 @see See @ref WeakPtrExample "this description" for more information and an example. 96 */ 43 97 template <class T> 44 98 class WeakPtr … … 47 101 48 102 public: 103 /// Constructor: Initializes the weak pointer with a null pointer. 49 104 inline WeakPtr() : pointer_(0), base_(0), callback_(0) 50 105 { 51 106 } 52 107 108 /// Constructor: Used to explicitly initialize the weak pointer with a null pointer 53 109 inline WeakPtr(int) : pointer_(0), base_(0), callback_(0) 54 110 { 55 111 } 56 112 113 /// Constructor: Initializes the weak pointer with a pointer to an object. 57 114 inline WeakPtr(T* pointer) : pointer_(pointer), base_(pointer), callback_(0) 58 115 { … … 61 118 } 62 119 120 /// Copy-constructor 63 121 inline WeakPtr(const WeakPtr& other) : pointer_(other.pointer_), base_(other.base_), callback_(0) 64 122 { … … 67 125 } 68 126 127 /// Copy-constructor for weak pointers to objects of another class. 69 128 template <class O> 70 129 inline WeakPtr(const WeakPtr<O>& other) : pointer_(other.get()), base_(other.base_), callback_(0) … … 74 133 } 75 134 135 /// Destructor 76 136 inline ~WeakPtr() 77 137 { … … 81 141 } 82 142 143 /// Used to assign a null pointer. 83 144 inline WeakPtr& operator=(int) 84 145 { … … 87 148 } 88 149 150 /// Assigns a new pointer. 89 151 inline WeakPtr& operator=(T* pointer) 90 152 { … … 93 155 } 94 156 157 /// Assigns the wrapped pointer of another WeakPtr. 95 158 inline WeakPtr& operator=(const WeakPtr& other) 96 159 { … … 99 162 } 100 163 164 /// Assigns the wrapped pointer of a WeakPtr of another class 101 165 template <class O> 102 166 inline WeakPtr& operator=(const WeakPtr<O>& other) … … 106 170 } 107 171 172 /// Returns the wrapped pointer as @c T* 108 173 inline T* get() const 109 174 { … … 111 176 } 112 177 178 /// Returns the wrapped pointer as @c OrxonoxClass* 113 179 inline OrxonoxClass* getBase() const 114 180 { … … 116 182 } 117 183 184 /// Implicitly converts the WeakPtr to a pointer of type @c T* 118 185 inline operator T*() const 119 186 { … … 121 188 } 122 189 190 /// Overloaded operator, returns a pointer to the stored object. 123 191 inline T* operator->() const 124 192 { … … 127 195 } 128 196 197 /// Overloaded operator, returns a reference to the stored object. 129 198 inline T& operator*() const 130 199 { … … 133 202 } 134 203 204 /// Returns true if the wrapped pointer is NULL. 135 205 inline bool operator!() const 136 206 { … … 138 208 } 139 209 210 /// Swaps the contents of two weak pointers. 140 211 inline void swap(WeakPtr& other) 141 212 { … … 162 233 } 163 234 235 /// Resets the weak pointer (equivalent to assigning a NULL pointer). 164 236 inline void reset() 165 237 { … … 167 239 } 168 240 241 /// Registers a callback that will be executed if the stored object is destroyed. 169 242 inline void setCallback(const FunctorPtr& callback) 170 243 { … … 172 245 } 173 246 247 /// Returns the registered callback. 174 248 inline const FunctorPtr& getCallback() const 175 249 { … … 178 252 179 253 private: 254 /// Will be called by OrxonoxClass::~OrxonoxClass() if the stored object is deleted. Resets the wrapped pointer and executes the callback. 180 255 inline void objectDeleted() 181 256 { … … 186 261 } 187 262 188 T* pointer_; 189 OrxonoxClass* base_; 190 FunctorPtr callback_; 263 T* pointer_; ///< The wrapped pointer to an object of type @a T 264 OrxonoxClass* base_; ///< The wrapped pointer, casted up to OrxonoxClass (this is needed because with just a T* pointer, WeakPtr couln't be used with forward declarations) 265 FunctorPtr callback_; ///< This callback will be executed if the stored object is deleted 191 266 }; 192 267 268 /// Swaps the contents of two weak pointers. 193 269 template <class T> 194 270 void swap(WeakPtr<T>& a, WeakPtr<T>& b) … … 197 273 } 198 274 275 /// Uses a static_cast to cast a pointer of type U* to a pointer of type T* and returns it in a new WeakPtr<T>. 199 276 template <class T, class U> 200 277 WeakPtr<T> static_pointer_cast(const WeakPtr<U>& p) … … 203 280 } 204 281 282 /// Uses a const_cast to cast a pointer of type U* to a pointer of type T* and returns it in a new WeakPtr<T>. 205 283 template <class T, class U> 206 284 WeakPtr<T> const_pointer_cast(const WeakPtr<U>& p) … … 209 287 } 210 288 289 /// Uses a dynamic_cast to cast a pointer of type U* to a pointer of type T* and returns it in a new WeakPtr<T>. 211 290 template <class T, class U> 212 291 WeakPtr<T> dynamic_pointer_cast(const WeakPtr<U>& p) -
code/trunk/src/libraries/core/WindowEventListener.h
r5781 r7401 26 26 * 27 27 */ 28 29 /** 30 @file 31 @ingroup Graphics 32 */ 28 33 29 34 #ifndef _WindowEventListener_H__ -
code/trunk/src/libraries/core/XMLFile.h
r6417 r7401 26 26 * 27 27 */ 28 29 /** 30 @file 31 @ingroup XML XMLPort 32 */ 28 33 29 34 #ifndef _XMLFile_H__ -
code/trunk/src/libraries/core/XMLNameListener.h
r5781 r7401 27 27 */ 28 28 29 /** 30 @file 31 @ingroup XML XMLPort 32 */ 33 29 34 #ifndef _XMLNameListener_H__ 30 35 #define _XMLNameListener_H__ -
code/trunk/src/libraries/core/XMLPort.h
r7284 r7401 28 28 29 29 /** 30 @defgroup XMLPort XMLPort 31 @ingroup XML 32 */ 33 34 /** 30 35 @file 36 @ingroup XML XMLPort 31 37 @brief Declaration of the XMLPort helper classes and macros. 32 38 … … 69 75 70 76 In the XML file, a param or attribute will be set like this: 77 @code 71 78 <classname paramname="value" /> 79 @endcode 72 80 73 81 The macro will then call loadfunction(value) to set the given value (or call savefunction() to … … 88 96 89 97 In the XML file, a param or attribute will be set like this: 98 @code 90 99 <classname paramname="value" /> 100 @endcode 91 101 92 102 The macro will then store "value" in the variable or read it when saving. … … 148 158 @param paramname The name of the attribute 149 159 @param loadfunction The function to set the attribute inside of the member object. 150 @param loadfunction The function to get the attribute from the member object 160 @param savefunction The function to get the attribute from the member object 161 @param xmlelement The XML-element that is parsed by this macro 162 @param mode Loading or saving 151 163 152 164 Sometimes you'll have a member object in your class, which has it's own load- and savefunctions. 153 165 With this macro, you can simply use them instead of writing your own functions. 154 166 155 @example167 Example: 156 168 Your class is called SpaceShip and this class has an object (myPilot_) of class Pilot. Pilot has a name 157 169 and two functions, setName(name) and getName(). Now you want an attribute "pilotname" in your … … 196 208 @param sectionname The name of the subsection in the XML file that encloses the sub-objects ("" means no subsection) 197 209 @param loadfunction The function to add a new object to the class 198 @param loadfunction The function to get all added objects from the class210 @param savefunction The function to get all added objects from the class 199 211 @param xmlelement The XMLElement (received through the XMLPort function) 200 212 @param mode The mode (load/save) (received through the XMLPort function) … … 210 222 likely the best option, so this is usually true. 211 223 212 @ note224 @details 213 225 The load- and savefunctions have to follow an exactly defined protocol. 214 226 Loadfunction: 215 227 The loadfunction gets a pointer to the object. 216 > void loadfunction(objectclass* pointer); 228 @code 229 void loadfunction(objectclass* pointer); 230 @endcode 217 231 218 232 Savefunction: … … 220 234 gets called again, but with index + 1. It's the functions responsibility to do something smart 221 235 with the index and to return 0 if all objects were returned. 222 > objectclass* savefunction(unsigned int index) const; 236 @code 237 objectclass* savefunction(unsigned int index) const; 238 @endcode 223 239 224 240 Possible implementation: 241 @code 225 242 objectclass* savefunction(unsigned int index) const 226 243 { … … 230 247 return 0; 231 248 } 232 233 @example 249 @endcode 250 251 Example: 234 252 Possible usage of the macro: 235 > XMLPortObject(SpaceShip, Weapon, "weapons", addWeapon, getWeapon, xmlelement, mode, false, true); 253 @code 254 XMLPortObject(SpaceShip, Weapon, "weapons", addWeapon, getWeapon, xmlelement, mode, false, true); 255 @endcode 236 256 237 257 Now you can add weapons through the XML file: 258 @code 238 259 <SpaceShip someattribute="..." ...> 239 260 <weapons> … … 243 264 </weapons> 244 265 </SpaceShip> 266 @endcode 245 267 246 268 Note that "weapons" is the subsection. This allows you to add more types of sub-objects. In our example, -
code/trunk/src/libraries/core/command/ArgumentCompleter.h
r7284 r7401 27 27 */ 28 28 29 /** 30 @defgroup ArgumentCompletion Argument completion 31 @ingroup Command 32 */ 33 34 /** 35 @file 36 @ingroup Command ArgumentCompletion 37 @brief Definition of the orxonox::ArgumentCompleter class that is used to execute @ref ArgumentCompletionFunctions.h "argument completion functions". 38 39 An ArgumentCompleter can be assigned to an orxonox::ConsoleCommand using 40 @ref orxonox::ConsoleCommand::argumentCompleter "argumentCompleter()". 41 The ArgumentCompleter calls an argument completion function that is defined 42 in ArgumentCompletionFunctions.h. This can be used to list possible arguments 43 for console commands and to allow auto-completion. 44 45 Instances of ArgumentCompleter are usually not created manually but rather 46 by the macros defined in ArgumentCompletionFunctions.h. There you'll also 47 find some examples. 48 49 @see See the @ref ArgumentCompletionExample "examples". 50 */ 51 29 52 #ifndef _ArgumentCompleter_H__ 30 53 #define _ArgumentCompleter_H__ … … 35 58 namespace orxonox 36 59 { 60 /** 61 @brief This class executes an argument completion function and returns a list of the possible arguments. 62 63 ArgumentCompleter is used to wrap argument completion functions as defined 64 in ArgumentCompletionFunctions.h and can be assigned to a ConsoleCommand to 65 create a list of possible arguments. 66 67 @see See ArgumentCompleter.h for more information. 68 @see See @ref ArgumentCompletionExample "ArgumentCompletionFunctions.h" for an example. 69 */ 37 70 class _CoreExport ArgumentCompleter 38 71 { 39 72 public: 40 ArgumentCompleter(ArgumentCompletionList (*function) (void), bool bUseMultipleWords) : bUseMultipleWords_(bUseMultipleWords), paramCount_(0), function_0_(function) {} 41 ArgumentCompleter(ArgumentCompletionList (*function) (const std::string& param1), bool bUseMultipleWords) : bUseMultipleWords_(bUseMultipleWords), paramCount_(1), function_1_(function) {} 42 ArgumentCompleter(ArgumentCompletionList (*function) (const std::string& param1, const std::string& param2), bool bUseMultipleWords) : bUseMultipleWords_(bUseMultipleWords), paramCount_(2), function_2_(function) {} 43 ArgumentCompleter(ArgumentCompletionList (*function) (const std::string& param1, const std::string& param2, const std::string& param3), bool bUseMultipleWords) : bUseMultipleWords_(bUseMultipleWords), paramCount_(3), function_3_(function) {} 44 ArgumentCompleter(ArgumentCompletionList (*function) (const std::string& param1, const std::string& param2, const std::string& param3, const std::string& param4), bool bUseMultipleWords) : bUseMultipleWords_(bUseMultipleWords), paramCount_(4), function_4_(function) {} 45 ArgumentCompleter(ArgumentCompletionList (*function) (const std::string& param1, const std::string& param2, const std::string& param3, const std::string& param4, const std::string& param5), bool bUseMultipleWords) : bUseMultipleWords_(bUseMultipleWords), paramCount_(5), function_5_(function) {} 73 ArgumentCompleter(ArgumentCompletionList (*function) (void), bool bUseMultipleWords) : bUseMultipleWords_(bUseMultipleWords), paramCount_(0), function_0_(function) {} ///< Constructor, assigns a function-pointer with no arguments. 74 ArgumentCompleter(ArgumentCompletionList (*function) (const std::string& param1), bool bUseMultipleWords) : bUseMultipleWords_(bUseMultipleWords), paramCount_(1), function_1_(function) {} ///< Constructor, assigns a function-pointer with one argument. 75 ArgumentCompleter(ArgumentCompletionList (*function) (const std::string& param1, const std::string& param2), bool bUseMultipleWords) : bUseMultipleWords_(bUseMultipleWords), paramCount_(2), function_2_(function) {} ///< Constructor, assigns a function-pointer with two arguments. 76 ArgumentCompleter(ArgumentCompletionList (*function) (const std::string& param1, const std::string& param2, const std::string& param3), bool bUseMultipleWords) : bUseMultipleWords_(bUseMultipleWords), paramCount_(3), function_3_(function) {} ///< Constructor, assigns a function-pointer with three arguments. 77 ArgumentCompleter(ArgumentCompletionList (*function) (const std::string& param1, const std::string& param2, const std::string& param3, const std::string& param4), bool bUseMultipleWords) : bUseMultipleWords_(bUseMultipleWords), paramCount_(4), function_4_(function) {} ///< Constructor, assigns a function-pointer with four arguments. 78 ArgumentCompleter(ArgumentCompletionList (*function) (const std::string& param1, const std::string& param2, const std::string& param3, const std::string& param4, const std::string& param5), bool bUseMultipleWords) : bUseMultipleWords_(bUseMultipleWords), paramCount_(5), function_5_(function) {} ///< Constructor, assigns a function-pointer with five arguments. 46 79 80 /** 81 @brief Calls the argument completion function with a maximum of five parameters. 82 @return Returns the list of possible arguments, created by the argument completion function 83 */ 47 84 ArgumentCompletionList operator()(const std::string& param1 = "", const std::string& param2 = "", const std::string& param3 = "", const std::string& param4 = "", const std::string& param5 = "") 48 85 { … … 66 103 } 67 104 105 /// Returns true if the argument completion list supports multiple words. 68 106 inline bool useMultipleWords() const 69 107 { return this->bUseMultipleWords_; } 70 108 71 109 private: 72 bool bUseMultipleWords_; 73 unsigned char paramCount_; 74 ArgumentCompletionList (*function_0_) (void); 75 ArgumentCompletionList (*function_1_) (const std::string& param1); 76 ArgumentCompletionList (*function_2_) (const std::string& param1, const std::string& param2); 77 ArgumentCompletionList (*function_3_) (const std::string& param1, const std::string& param2, const std::string& param3); 78 ArgumentCompletionList (*function_4_) (const std::string& param1, const std::string& param2, const std::string& param3, const std::string& param4); 79 ArgumentCompletionList (*function_5_) (const std::string& param1, const std::string& param2, const std::string& param3, const std::string& param4, const std::string& param5); 110 bool bUseMultipleWords_; ///< If true, the argument completion list supports multiple words 111 unsigned char paramCount_; ///< The number of parameters of the argument completion function 112 ArgumentCompletionList (*function_0_) (void); ///< Function-pointer for an argument completion function with no arguments 113 ArgumentCompletionList (*function_1_) (const std::string& param1); ///< Function-pointer for an argument completion function with one argument 114 ArgumentCompletionList (*function_2_) (const std::string& param1, const std::string& param2); ///< Function-pointer for an argument completion function with two arguments 115 ArgumentCompletionList (*function_3_) (const std::string& param1, const std::string& param2, const std::string& param3); ///< Function-pointer for an argument completion function with three arguments 116 ArgumentCompletionList (*function_4_) (const std::string& param1, const std::string& param2, const std::string& param3, const std::string& param4); ///< Function-pointer for an argument completion function with four arguments 117 ArgumentCompletionList (*function_5_) (const std::string& param1, const std::string& param2, const std::string& param3, const std::string& param4, const std::string& param5); ///< Function-pointer for an argument completion function with five arguments 80 118 }; 81 119 } -
code/trunk/src/libraries/core/command/ArgumentCompletionFunctions.cc
r7284 r7401 26 26 * 27 27 */ 28 29 /** 30 @file 31 @brief Implementation of all argument completion functions 32 */ 28 33 29 34 #include "ArgumentCompletionFunctions.h" … … 53 58 namespace autocompletion 54 59 { 60 /** 61 @brief Fallback implementation, returns an empty list. 62 */ 55 63 ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(fallback)() 56 64 { … … 60 68 namespace detail 61 69 { 70 /** 71 @brief Returns true if a group of console commands is visible (i.e. if at least one command in this group is visible). 72 */ 62 73 bool groupIsVisible(const std::map<std::string, ConsoleCommand*>& group, bool bOnlyShowHidden) 63 74 { … … 69 80 } 70 81 82 /** 83 @brief Returns a list of all console command groups AND all console command shortcuts. 84 @param fragment The last argument 85 @param bOnlyShowHidden If true, only hidden groups and commands are returned 86 */ 71 87 ArgumentCompletionList _groupsandcommands(const std::string& fragment, bool bOnlyShowHidden) 72 88 { 89 // note: this function returns only arguments that begin with "fragment", which would't be necessary for the 90 // auto-completion, but it's necessary to place the line-break "\n" between groups and commands 91 // only if both groups AND commands are in the list. 92 73 93 ArgumentCompletionList groupList; 74 94 std::string fragmentLC = getLowercase(fragment); 75 95 96 // get all the groups that are visible (except the shortcut group "") 76 97 const std::map<std::string, std::map<std::string, ConsoleCommand*> >& commands = ConsoleCommand::getCommands(); 77 98 for (std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = commands.begin(); it_group != commands.end(); ++it_group) … … 79 100 groupList.push_back(ArgumentCompletionListElement(it_group->first, getLowercase(it_group->first))); 80 101 102 // now add all shortcuts (in group "") 81 103 std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = commands.find(""); 82 104 if (it_group != commands.end()) 83 105 { 106 // add a line-break if the list isn't empty 84 107 if (!groupList.empty()) 85 108 groupList.push_back(ArgumentCompletionListElement("", "", "\n")); 86 109 110 // add the shortcuts 87 111 for (std::map<std::string, ConsoleCommand*>::const_iterator it_command = it_group->second.begin(); it_command != it_group->second.end(); ++it_command) 88 112 if (it_command->second->isActive() && it_command->second->hasAccess() && (!it_command->second->isHidden())^bOnlyShowHidden && (fragmentLC == "" || getLowercase(it_command->first).find_first_of(fragmentLC) == 0)) … … 90 114 } 91 115 116 // if no shortcut was added, remove the line-break again 92 117 if (!groupList.empty() && groupList.back().getDisplay() == "\n") 93 118 groupList.pop_back(); … … 96 121 } 97 122 123 /** 124 @brief Returns a list of all console commands in a given group. 125 @param fragment The last argument 126 @param group The group's name 127 @param bOnlyShowHidden If true, only hidden console commands are returned 128 */ 98 129 ArgumentCompletionList _subcommands(const std::string& fragment, const std::string& group, bool bOnlyShowHidden) 99 130 { … … 102 133 std::string groupLC = getLowercase(group); 103 134 135 // find the iterator of the given group 104 136 std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = ConsoleCommand::getCommands().begin(); 105 137 for ( ; it_group != ConsoleCommand::getCommands().end(); ++it_group) … … 107 139 break; 108 140 141 // add all commands in the group to the list 109 142 if (it_group != ConsoleCommand::getCommands().end()) 110 143 { … … 118 151 } 119 152 153 /** 154 @brief Returns a list of all console command groups AND all console command shortcuts. 155 */ 120 156 ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(groupsandcommands)(const std::string& fragment) 121 157 { … … 123 159 } 124 160 161 /** 162 @brief Returns a list of all console commands in a given group. 163 */ 125 164 ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(subcommands)(const std::string& fragment, const std::string& group) 126 165 { … … 128 167 } 129 168 169 /** 170 @brief Returns a list of commands and groups and also supports auto-completion of the arguments of these commands. 171 172 This is a multi-word function, because commands are composed of 1-2 words and additional arguments. 173 */ 130 174 ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION_MULTI(command)(const std::string& fragment) 131 175 { … … 145 189 } 146 190 191 /** 192 @brief Returns a list of hidden commands and groups and also supports auto-completion of the arguments of these commands. 193 194 This is a multi-word function, because commands are composed of 1-2 words and additional arguments. 195 196 This function makes commands visible that would usually be hidden. 197 */ 147 198 ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION_MULTI(hiddencommand)(const std::string& fragment) 148 199 { … … 170 221 } 171 222 223 /** 224 @brief Returns possible files and directories and also supports files in arbitrary deeply nested subdirectories. 225 226 This function returns files and directories in the given path. This allows to 227 navigate iteratively through the file system. The first argument @a fragment 228 is used to get the current path. 229 */ 172 230 ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(files)(const std::string& fragment) 173 231 { … … 211 269 } 212 270 271 /** 272 @brief Returns the sections of the config file. 273 */ 213 274 ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(settingssections)() 214 275 { … … 222 283 } 223 284 285 /** 286 @brief Returns the entries in a given section of the config file. 287 */ 224 288 ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(settingsentries)(const std::string& fragment, const std::string& section) 225 289 { … … 235 299 } 236 300 301 /** 302 @brief Returns the current value of a given value in a given section of the config file. 303 */ 237 304 ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(settingsvalue)(const std::string& fragment, const std::string& entry, const std::string& section) 238 305 { … … 255 322 } 256 323 324 /** 325 @brief Returns a list of indexes of the available Tcl threads (see TclThreadManager). 326 */ 257 327 ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(tclthreads)() 258 328 { -
code/trunk/src/libraries/core/command/ArgumentCompletionFunctions.h
r7284 r7401 27 27 */ 28 28 29 /** 30 @file 31 @ingroup Command ArgumentCompletion 32 @brief Declaration of all argument completion functions and macros used to define them. 33 34 @anchor ArgumentCompletionExample 35 36 Argument completion functions are used to create a list of possible arguments 37 for an orxonox::ConsoleCommand. These functions are usually wrapped by an instance 38 of orxonox::ArgumentCompleter. 39 40 Argument completion functions can be declared and implemented by using the macros 41 ARGUMENT_COMPLETION_FUNCTION_DECLARATION() and ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION() 42 respectively. They are necessary because they don't simply define the function, but they also 43 create a static helper function that returns an instance of orxonox::ArgumentCompleter which 44 wraps the defined function. This allows easier referencing of argument completion functions 45 by simply calling autocompletion::functionname(). 46 47 Argument completion functions can take up to 5 arguments, all of type std::string. 48 The first argument is always the current argument which is being entered by the user 49 in the shell. The second argument is the argument before, so in fact arguments from 50 the shell are sent in reversed order to the argument completion function. This is 51 necessary because the number of arguments can be variable 52 53 Example: The user types the following into the shell: 54 @code 55 $ commandname argument1 argument2 argum 56 @endcode 57 Then he presses the @a tab key to print the possible arguments. Now the argument 58 completion function for the @a third argument of @a commandname will be called in 59 the following way: 60 @code 61 list = argcompfunction3("argum", "argument2", "argument1"); 62 @endcode 63 64 Usually each argument is one word (without whitespaces in it), but some argument completion 65 functions need more than one word. This can be achieved by using ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION_MULTI(). 66 In this case all supernumerous words are passed to the first (!) argument. 67 68 An example to show how to declare, implement, and use an argument completion function: 69 @code 70 // ArgumentCompletionFunctions.h: 71 // ------------------------------ 72 73 // Declaration of the function: 74 ARGUMENT_COMPLETION_FUNCTION_DECLARATION(month)(const std::string& fragment); 75 76 // ArgumentCompletionFunctions.cc: 77 // ------------------------------- 78 79 // Implementation of the function 80 ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(month)(const std::string& fragment) 81 { 82 ArgumentCompletionList list; 83 84 // check if the first part of the argument is a number - if yes, the user likely wants to enter the month as a number 85 if (isNumber(fragment)) 86 { 87 for (int month = 1; month <= 12; ++month) 88 list.push_back(ArgumentCompletionListElement(multi_cast<std::string>(month))); 89 } 90 else 91 { 92 list.push_back(ArgumentCompletionListElement("January", "january")); 93 list.push_back(ArgumentCompletionListElement("February", "february")); 94 list.push_back(ArgumentCompletionListElement("March", "march")); 95 list.push_back(ArgumentCompletionListElement("April", "april")); 96 list.push_back(ArgumentCompletionListElement("May", "may")); 97 list.push_back(ArgumentCompletionListElement("June", "june")); 98 list.push_back(ArgumentCompletionListElement("July", "july")); 99 list.push_back(ArgumentCompletionListElement("August", "august")); 100 list.push_back(ArgumentCompletionListElement("September", "september")); 101 list.push_back(ArgumentCompletionListElement("October", "october")); 102 list.push_back(ArgumentCompletionListElement("November", "november")); 103 list.push_back(ArgumentCompletionListElement("December", "december")); 104 } 105 106 return list; 107 } 108 109 // SomeFile: 110 // --------- 111 112 // A class to manage the date: 113 class Date 114 { 115 public: 116 static void setDate(int day, const std::string& month, int year); 117 }; 118 119 // Define a console command that needs a date. Add argument completion for the month: 120 SetConsoleCommand("setDate", &Date::setDate).argumentCompleter(1, autocompletion::month()); 121 @endcode 122 123 This example defines an argument completion function that returns a list of possible 124 months. If the first part of the argument is a number, it returns the numbers 1-12, 125 otherwise the name of the months are returned. Note how the list is composed by 126 instances of orxonox::ArgumentCompletionListElement. For the name of the months, 127 two strings are provided, one in normal case and one in lower case. See the documentation 128 of orxonox::ArgumentCompletionListElement for more information about this. 129 130 Also note that the argument completion list is assigned to the console command by using 131 @ref orxonox::ConsoleCommand::argumentCompleter "argumentCompleter()". The first argument 132 is the index of the argument: 133 - 0 is the first argument (@a day) 134 - 1 is the second argument (@a month) 135 - 2 is the third argument (@a year) 136 137 @a day and @a year don't need an argument completion function as they are just integers. 138 139 The function @c autocompletion::month() is automatically created by the macros 140 ARGUMENT_COMPLETION_FUNCTION_DECLARATION() and ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION() 141 and returns an orxonox::ArgumentCompleter that wraps the defined argument completion function. 142 143 The implemented argument completion function uses only one argument, the fragment of the 144 currently entered argument. More complex functions can also use the previous arguments 145 to return different arguments depending on the other arguments (for example to list the 146 members of a class, where the class-name is the first argument and the member the second). 147 */ 148 29 149 #ifndef _ArgumentCompletionFunctions_H__ 30 150 #define _ArgumentCompletionFunctions_H__ … … 33 153 #include "ArgumentCompleter.h" 34 154 35 155 /** 156 @brief Used to declare an argument completion function with name @a functionname. 157 @param functionname The name of the function, will also be used for the implementation of the function. 158 159 The macro also defines a static function that returns an orxonox::ArgumentCompleter 160 which wraps the defined function. This can be accessed by calling autocompletion::functionname(); 161 */ 36 162 #define ARGUMENT_COMPLETION_FUNCTION_DECLARATION(functionname) \ 37 163 _CoreExport ArgumentCompleter* functionname(); \ 38 164 _CoreExport ArgumentCompletionList acf_##functionname 39 165 166 /** 167 @brief Used to implement an argument completion function. 168 @param functionname The name of the function 169 */ 40 170 #define ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(functionname) \ 41 171 _ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION_INTERNAL(functionname, false) 172 173 /** 174 @brief Used to implement an argument completion function which allows multiple words. 175 @param functionname The name of the function 176 */ 42 177 #define ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION_MULTI(functionname) \ 43 178 _ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION_INTERNAL(functionname, true) 44 179 180 /// Internal macro 45 181 #define _ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION_INTERNAL(functionname, bUseMultipleWords) \ 46 182 ArgumentCompleter* functionname() \ … … 52 188 ArgumentCompletionList acf_##functionname 53 189 190 /// Calls an argument completion function. Used for functions that return the results of another argument completion function. 54 191 #define ARGUMENT_COMPLETION_FUNCTION_CALL(functionname) acf_##functionname 55 192 -
code/trunk/src/libraries/core/command/ArgumentCompletionListElement.h
r7284 r7401 27 27 */ 28 28 29 /** 30 @file 31 @ingroup Command ArgumentCompletion 32 @brief Definition of ArgumentCompletionList, which is used in @ref ArgumentCompletionFunctions.h "argument completion functions", and its element. 33 */ 34 29 35 #ifndef _ArgumentCompletionListElement_H__ 30 36 #define _ArgumentCompletionListElement_H__ … … 37 43 namespace orxonox 38 44 { 39 const int ACL_MODE_NORMAL = 1;40 const int ACL_MODE_COMPARABLE = 2; 41 const int ACL_MODE_DISPLAY = 4;45 const int ACL_MODE_NORMAL = 1; ///< A flag, used if there's a normal string 46 const int ACL_MODE_COMPARABLE = 2; ///< A flag, used if there's a different string used to compare 47 const int ACL_MODE_DISPLAY = 4; ///< A flag, used if there's a different string used to be displayed 42 48 43 49 typedef std::list<ArgumentCompletionListElement> ArgumentCompletionList; 44 50 51 /** 52 @brief This class is used in argument completion lists and contains up to three different strings, used in different situations. 53 54 A list containing elements of type ArgumentCompletionListElement is returned by 55 an @ref ArgumentCompletionFunctions.h "argument completion function". These elements 56 are composed of up to three strings with different usage: 57 - normal: What is used as the actual argument 58 - comparable: What is used to compere the argument to the input of the user (usually lowercase, except for case-sensitive arguments) 59 - display: This is displayed in the list of possible arguments - can differ from what is actually used for better readability 60 61 @remarks An element with an empty ("") 'comparable' string will be ignored by the argument 62 completion algorithms, but it's 'display' string will still be printed in the list. This 63 can be used to add additional information, whitespaces, linebreaks or whatever is needed 64 to format the output. 65 */ 45 66 class _CoreExport ArgumentCompletionListElement 46 67 { 47 68 public: 69 /// Constructor: Normal, comparable, and display string are all the same. 48 70 ArgumentCompletionListElement(const std::string& normalcase) : mode_(ACL_MODE_NORMAL), normal_(normalcase) {} 71 /// Constructor: Normal and display string are the same, a different (usually lowercase) string is used for comparison. 49 72 ArgumentCompletionListElement(const std::string& normalcase, const std::string& lowercase) : mode_(ACL_MODE_NORMAL | ACL_MODE_COMPARABLE), normal_(normalcase), comparable_(lowercase) {} 73 /// Constructor: Normal, comparable, and display are all different strings. 50 74 ArgumentCompletionListElement(const std::string& normalcase, const std::string& lowercase, const std::string& display) : mode_(ACL_MODE_NORMAL | ACL_MODE_COMPARABLE | ACL_MODE_DISPLAY), normal_(normalcase), comparable_(lowercase), display_(display) {} 51 75 76 /// Returns the normal string which is used as the actual argument. 52 77 const std::string& getString() const 53 78 { return this->normal_; } 79 /// Returns the comparable string which is used to compare arguments and user input 54 80 const std::string& getComparable() const 55 81 { return (this->mode_ & ACL_MODE_COMPARABLE) ? this->comparable_ : this->normal_; } 82 /// Returns the display string which is used in the displayed list of possible arguments 56 83 const std::string& getDisplay() const 57 84 { return (this->mode_ & ACL_MODE_DISPLAY) ? this->display_ : this->normal_; } 58 85 86 /// Returns true if there's a different string for comparison. 59 87 bool hasComparable() const 60 88 { return (this->mode_ & ACL_MODE_COMPARABLE); } 89 /// Returns true if there's a different string to display. 61 90 bool hasDisplay() const 62 91 { return (this->mode_ & ACL_MODE_DISPLAY); } 63 92 93 /// Overloaded operator for usage in maps and sets. 64 94 bool operator<(const ArgumentCompletionListElement& other) const 65 95 { return (this->getComparable() < other.getComparable()); } 66 96 67 97 private: 68 unsigned char mode_; 69 std::string normal_; 70 std::string comparable_; 71 std::string display_; 98 unsigned char mode_; ///< The flags 99 std::string normal_; ///< The normal string 100 std::string comparable_; ///< The comparable (usually lowercase) string 101 std::string display_; ///< The string to display 72 102 }; 73 103 } -
code/trunk/src/libraries/core/command/CommandEvaluation.cc
r7286 r7401 27 27 */ 28 28 29 /** 30 @file 31 @brief Implementation of CommandEvaluation 32 */ 33 29 34 #include "CommandEvaluation.h" 30 35 … … 35 40 namespace orxonox 36 41 { 42 /** 43 @brief Constructor: Initializes the command evaluation with an empty command. 44 */ 37 45 CommandEvaluation::CommandEvaluation() 38 46 { … … 40 48 } 41 49 50 /** 51 @brief Initializes all values. 52 */ 42 53 void CommandEvaluation::initialize(const std::string& command) 43 54 { … … 49 60 this->bPossibleArgumentsRetrieved_ = false; 50 61 this->possibleArguments_.clear(); 51 this->bEvaluatedParams_ = false; 52 this->bTriedToEvaluatedParams_ = false; 53 this->numberOfEvaluatedParams_ = 0; 54 62 this->bEvaluatedArguments_ = false; 63 this->bTriedToEvaluatedArguments_ = false; 64 this->numberOfEvaluatedArguments_ = 0; 65 66 // split the command into tokens 55 67 this->tokens_.split(command, " ", SubString::WhiteSpaces, false, '\\', true, '"', true, '{', '}', true, '\0'); 56 68 } 57 69 70 /** 71 @brief Returns the number of tokens according to the definition of CommandExecutor (which counts also an empty argument at the end of the string). 72 */ 58 73 unsigned int CommandEvaluation::getNumberOfArguments() const 59 74 { 60 75 unsigned int count = this->tokens_.size(); 61 if (count > 0 && this->string_[this->string_.size() - 1] != ' ') 76 77 // If the last char in the string is a space character (or the string is empty), add +1 to the number of tokens, because this counts as an additional (but empty) argument 78 if (count == 0 || this->string_[this->string_.size() - 1] == ' ') 79 return count + 1; 80 else 62 81 return count; 82 } 83 84 /** 85 @brief Returns the last argument (which is the one the user currently enters into the shell). 86 */ 87 const std::string& CommandEvaluation::getLastArgument() const 88 { 89 // the string is empty or ends with a space character, the user is just about to enter a new argument (but its still empty). return a blank string in this case. 90 if (this->tokens_.size() == 0 || this->string_[this->string_.size() - 1] == ' ') 91 return BLANKSTRING; 63 92 else 64 return count + 1;65 }66 67 const std::string& CommandEvaluation::getLastArgument() const68 {69 if (this->tokens_.size() > 0 && this->string_[this->string_.size() - 1] != ' ')70 93 return this->tokens_.back(); 71 else 72 return BLANKSTRING; 73 } 74 94 } 95 96 /** 97 @brief Returns the token with the given index (or a blank string if it doesn't exist). 98 */ 75 99 const std::string& CommandEvaluation::getToken(unsigned int i) const 76 100 { … … 81 105 } 82 106 107 /** 108 @brief Executes the command which was evaluated by this object. 109 @return Returns the error code (see @ref CommandExecutorErrorCodes "CommandExecutor error codes") 110 */ 83 111 int CommandEvaluation::execute() 84 112 { … … 88 116 } 89 117 118 /** 119 @brief Executes the command which was evaluated by this object and returns its return-value. 120 @param error A pointer to an integer (or NULL) which will be used to write error codes to (see @ref CommandExecutorErrorCodes "CommandExecutor error codes") 121 @return Returns the result of the command (or MT_Type::Null if there is no return value) 122 */ 90 123 MultiType CommandEvaluation::query(int* error) 91 124 { 125 // check if an error value was passed by reference 92 126 if (error) 93 127 { 128 // Determine the error-code and return if it is not Success 129 94 130 *error = CommandExecutor::Success; 95 131 … … 105 141 } 106 142 143 // check if it's possible to execute the command 107 144 if (this->execCommand_ && this->execCommand_->isActive() && this->execCommand_->hasAccess()) 108 145 { 109 if (!this->bTriedToEvaluatedParams_) 110 this->evaluateParams(false); 111 112 if (this->bEvaluatedParams_) 113 { 114 COUT(6) << "CE_execute (evaluation): " << this->execCommand_->getName() << " with " << this->numberOfEvaluatedParams_ << " params: " << this->param_[0] << ' ' << this->param_[1] << ' ' << this->param_[2] << ' ' << this->param_[3] << ' ' << this->param_[4] << std::endl; 115 switch (this->numberOfEvaluatedParams_) 146 // if the arguments weren't evaluated yet, do it now. 147 if (!this->bTriedToEvaluatedArguments_) 148 this->evaluateArguments(false); 149 150 // check if the argument evaluation succeded 151 if (this->bEvaluatedArguments_) 152 { 153 COUT(6) << "CE_execute (evaluation): " << this->execCommand_->getName() << " with " << this->numberOfEvaluatedArguments_ << " arguments: " << this->arguments_[0] << ' ' << this->arguments_[1] << ' ' << this->arguments_[2] << ' ' << this->arguments_[3] << ' ' << this->arguments_[4] << std::endl; 154 155 // pass as many arguments to the executor as were evaluated (thus the executor can still use additional default values) 156 switch (this->numberOfEvaluatedArguments_) 116 157 { 117 158 case 0: return (*this->execCommand_->getExecutor())(); 118 case 1: return (*this->execCommand_->getExecutor())(this-> param_[0]);119 case 2: return (*this->execCommand_->getExecutor())(this-> param_[0], this->param_[1]);120 case 3: return (*this->execCommand_->getExecutor())(this-> param_[0], this->param_[1], this->param_[2]);121 case 4: return (*this->execCommand_->getExecutor())(this-> param_[0], this->param_[1], this->param_[2], this->param_[3]);159 case 1: return (*this->execCommand_->getExecutor())(this->arguments_[0]); 160 case 2: return (*this->execCommand_->getExecutor())(this->arguments_[0], this->arguments_[1]); 161 case 3: return (*this->execCommand_->getExecutor())(this->arguments_[0], this->arguments_[1], this->arguments_[2]); 162 case 4: return (*this->execCommand_->getExecutor())(this->arguments_[0], this->arguments_[1], this->arguments_[2], this->arguments_[3]); 122 163 case 5: 123 default: return (*this->execCommand_->getExecutor())(this-> param_[0], this->param_[1], this->param_[2], this->param_[3], this->param_[4]);164 default: return (*this->execCommand_->getExecutor())(this->arguments_[0], this->arguments_[1], this->arguments_[2], this->arguments_[3], this->arguments_[4]); 124 165 } 125 166 } … … 128 169 } 129 170 171 // return a null value in case of an error 130 172 return MT_Type::Null; 131 173 } 132 174 133 int CommandEvaluation::evaluateParams(bool bPrintError) 134 { 135 this->bTriedToEvaluatedParams_ = true; 136 175 /** 176 @brief Evaluates the arguments of the command. 177 @param bPrintError If true, the function prints an error message if it doesn't succeed 178 @return Returns the error code (see @ref CommandExecutorErrorCodes "CommandExecutor error codes") 179 */ 180 int CommandEvaluation::evaluateArguments(bool bPrintError) 181 { 182 this->bTriedToEvaluatedArguments_ = true; 183 184 // check if there's a command to execute 137 185 if (!this->execCommand_) 138 186 { 139 187 if (bPrintError) 140 COUT(1) << "Error: Can't evaluate params, no console command assigned." << std::endl;188 COUT(1) << "Error: Can't evaluate arguments, no console command assigned." << std::endl; 141 189 return CommandExecutor::Error; 142 190 } 143 191 144 192 int error; 145 this->numberOfEvaluatedParams_ = this->execCommand_->getExecutor()->evaluateParams(this->tokens_.subSet(this->execArgumentsOffset_), this->param_, &error, " "); 193 194 // try to evaluate the arguments using the executor of the evaluated command. 195 // the arguments are currently stored as strings in token_, but afterwards they will be converted to the right type and stored in arguments_ 196 this->numberOfEvaluatedArguments_ = this->execCommand_->getExecutor()->evaluateArguments(this->tokens_.subSet(this->execArgumentsOffset_), this->arguments_, &error, " "); 197 198 // check if an error occurred 146 199 if (!error) 147 this->bEvaluated Params_ = true;200 this->bEvaluatedArguments_ = true; 148 201 else if (bPrintError) 149 COUT(1) << "Error: Can't evaluate params, not enough arguments given." << std::endl;202 COUT(1) << "Error: Can't evaluate arguments, not enough arguments given." << std::endl; 150 203 151 204 return error; 152 205 } 153 206 154 void CommandEvaluation::setEvaluatedParameter(unsigned int index, const MultiType& param) 207 /** 208 @brief Replaces an evaluated argument with a new value. 209 @param index The index of the parameter (the first argument has index 0) 210 @param arg The new value of the parameter 211 */ 212 void CommandEvaluation::setEvaluatedArgument(unsigned int index, const MultiType& arg) 155 213 { 156 214 if (index < MAX_FUNCTOR_ARGUMENTS) 157 this->param_[index] = param; 158 } 159 160 MultiType CommandEvaluation::getEvaluatedParameter(unsigned int index) const 215 this->arguments_[index] = arg; 216 } 217 218 /** 219 @brief Returns the evaluated argument with given index. 220 @param index The index of the argument (the first argument has index 0) 221 */ 222 MultiType CommandEvaluation::getEvaluatedArgument(unsigned int index) const 161 223 { 162 224 if (index < MAX_FUNCTOR_ARGUMENTS) 163 return this-> param_[index];225 return this->arguments_[index]; 164 226 165 227 return MT_Type::Null; 166 228 } 167 229 230 /** 231 @brief Completes the given command string using the list of possible arguments. 232 @return Returns the completed command string 233 234 This is called by the shell if the user presses the @a tab key. The currently entered 235 argument will be completed as good as possible by using the argument completion list 236 of the evaluated command. 237 */ 168 238 std::string CommandEvaluation::complete() 169 239 { 240 // check if it's possible to complete the command 170 241 if (!this->hintCommand_ || !this->hintCommand_->isActive()) 171 242 return this->string_; 172 243 244 // get the list of possible arguments 173 245 if (!this->bPossibleArgumentsRetrieved_) 174 246 this->retrievePossibleArguments(); 175 247 248 // if the list is empty, return the current command string 176 249 if (CommandEvaluation::getSize(this->possibleArguments_) == 0) 177 250 { … … 180 253 else 181 254 { 255 // get the first part of the command string from the beginning up to the last space character 182 256 std::string output = this->string_.substr(0, this->string_.find_last_of(' ') + 1); 257 258 // add the common begin of all possible arguments 183 259 output += CommandEvaluation::getCommonBegin(this->possibleArguments_); 260 261 // return the resulting string 184 262 return output; 185 263 } 186 264 } 187 265 266 /** 267 @brief Returns a string containing hints or possible arguments for the evaluated command. 268 269 This is called by the shell if the user presses the @a tab key. It prints a list of 270 possible arguments or other hints, returned by the argument completion list of the 271 evaluated command. If there's no such list, the syntax of the command is returned. 272 */ 188 273 std::string CommandEvaluation::hint() 189 274 { 275 // check if it's possible to get hints for this command 190 276 if (!this->hintCommand_ || !this->hintCommand_->isActive()) 191 277 return ""; 192 278 279 // get the list of possible arguments 193 280 if (!this->bPossibleArgumentsRetrieved_) 194 281 this->retrievePossibleArguments(); 195 282 283 // return the list of possible arguments if: 284 // a) it contains at least one non-empty argument 285 // b) it contains an entry that may be empty (not an actual argument, just a helping text) AND the command is valid 196 286 if (CommandEvaluation::getSize(this->possibleArguments_) > 0 || (!this->possibleArguments_.empty() && this->isValid())) 197 287 return CommandEvaluation::dump(this->possibleArguments_); 198 288 289 // at this point there's no valid argument in the list, so check if the command is actually valid 199 290 if (this->isValid()) 200 291 { 292 // yes it is - return the syntax of the command 201 293 return CommandEvaluation::dump(this->hintCommand_); 202 294 } 203 295 else 204 296 { 297 // no the command is not valid 205 298 if (this->getNumberOfArguments() > 2) 206 299 { 300 // the user typed 2+ arguments, but they don't name a command - print an error 207 301 return std::string("Error: There is no command with name \"") + this->getToken(0) + " " + this->getToken(1) + "\"."; 208 302 } 209 303 else 210 304 { 305 // the user typed 1-2 arguments, check what he tried to type and print a suitable error 211 306 std::string groupLC = getLowercase(this->getToken(0)); 212 307 for (std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = ConsoleCommand::getCommandsLC().begin(); it_group != ConsoleCommand::getCommandsLC().end(); ++it_group) … … 219 314 } 220 315 316 /** 317 @brief If the command couln't be evaluated because it doesn't exist, print a suggestion for 318 a command that looks close to the entered command (useful if the user mistyped the command). 319 */ 221 320 std::string CommandEvaluation::getCommandSuggestion() const 222 321 { … … 227 326 unsigned int nearestDistance = (unsigned int)-1; 228 327 328 // iterate through all groups and their commands and calculate the distance to the current command. keep the best. 229 329 for (std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = ConsoleCommand::getCommandsLC().begin(); it_group != ConsoleCommand::getCommandsLC().end(); ++it_group) 230 330 { … … 244 344 } 245 345 346 // now also iterate through all shortcuts and keep the best if it's better than the one found above. 246 347 std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = ConsoleCommand::getCommandsLC().find(""); 247 348 if (it_group != ConsoleCommand::getCommandsLC().end()) … … 259 360 } 260 361 362 // return the command that's closest to the current one. 261 363 return nearestCommand; 262 364 } 263 365 366 /** 367 @brief Gets the possible arguments for the command in its current state. 368 */ 264 369 void CommandEvaluation::retrievePossibleArguments() 265 370 { 266 371 this->bPossibleArgumentsRetrieved_ = true; 372 373 // we use the hintCommand_ to get possible arguments. get the index of the last argument. limit the index if its greater than the number of arguments supported by the command. 267 374 unsigned int argumentID = std::min(this->getNumberOfArguments() - this->hintArgumentsOffset_, this->hintCommand_->getExecutor()->getParamCount()); 375 376 // get the argument completer for the given argument index 268 377 ArgumentCompleter* ac = this->hintCommand_->getArgumentCompleter(argumentID - 1); 269 378 379 // check if an argument completer exists 270 380 if (ac) 271 381 { 272 MultiType param[MAX_FUNCTOR_ARGUMENTS]; 273 382 MultiType arg[MAX_FUNCTOR_ARGUMENTS]; 383 384 // the index of the last argument in the command string that is supported by this argument completer 274 385 size_t max = this->hintArgumentsOffset_ + this->hintCommand_->getExecutor()->getParamCount(); 275 386 387 // write the argument strings to the argument array (in reversed order, as required by the argument completion function) 276 388 for (size_t i = 0; i < argumentID; ++i) 277 param[i] = this->getToken(std::min(this->getNumberOfArguments(), (unsigned int)max) - i - 1); 278 389 arg[i] = this->getToken(std::min(this->getNumberOfArguments(), (unsigned int)max) - i - 1); 390 391 // check if there are more arguments given by the user than supported 279 392 if (this->getNumberOfArguments() > max) 280 393 { 394 // yes - now check if multiple words are supported by the argument completer 281 395 if (ac->useMultipleWords()) 282 396 { 397 // yes - join the surplus arguments 283 398 std::string surplusArguments = this->tokens_.subSet(max - 1).join(); 284 399 if (this->string_[this->string_.size() - 1] == ' ') 285 400 surplusArguments += ' '; 286 401 287 this->possibleArguments_ = (*ac)(surplusArguments, param[1], param[2], param[3], param[4]); 402 // pass all surplus arguments as the first argument to the argument completer 403 this->possibleArguments_ = (*ac)(surplusArguments, arg[1], arg[2], arg[3], arg[4]); 404 405 // strip the list using the last argument 288 406 CommandEvaluation::strip(this->possibleArguments_, this->getToken(this->getNumberOfArguments() - 1)); 289 407 } 408 else 409 { 410 // no - the user typed more arguments than supported, no action 411 } 290 412 } 291 413 else 292 414 { 293 this->possibleArguments_ = (*ac)(param[0], param[1], param[2], param[3], param[4]); 294 CommandEvaluation::strip(this->possibleArguments_, param[0]); 295 } 296 } 297 } 298 415 // no - so simply call the argument completer and get the list of arguments 416 this->possibleArguments_ = (*ac)(arg[0], arg[1], arg[2], arg[3], arg[4]); 417 418 // strip the list using the last argument (stored arg[0]) 419 CommandEvaluation::strip(this->possibleArguments_, arg[0]); 420 } 421 } 422 } 423 424 /** 425 @brief Returns the size of an argument completion list - empty ("") arguments are not counted. 426 */ 299 427 /* static */ size_t CommandEvaluation::getSize(const ArgumentCompletionList& list) 300 428 { … … 306 434 } 307 435 436 /** 437 @brief Removes all elements from the list that don't start with @a fragment. 438 @param list The argument completion list 439 @param fragment The argument that is currently entered by the user and that needs to be completed 440 */ 308 441 /* static */ void CommandEvaluation::strip(ArgumentCompletionList& list, const std::string& fragment) 309 442 { 310 443 std::string fragmentLC = getLowercase(fragment); 311 444 445 // iterate through the list 312 446 for (ArgumentCompletionList::iterator it = list.begin(); it != list.end(); ) 313 447 { 314 448 const std::string& entry = it->getComparable(); 315 449 450 // check if the argument is empty - if yes, keep it always in the list 316 451 if (entry == "") 317 452 { … … 320 455 } 321 456 457 // check the length of the argument - arguments smaller than 'fragment' are always erased 322 458 if (entry.size() < fragmentLC.size()) 323 459 { … … 326 462 else 327 463 { 464 // compare the argument char by char with 'fragment' 328 465 bool bErase = false; 329 466 for (size_t i = 0; i < fragmentLC.size(); ++i) … … 344 481 } 345 482 483 /** 484 @brief Returns the commond begin of all arguments in the list. 485 */ 346 486 /* static */ std::string CommandEvaluation::getCommonBegin(const ArgumentCompletionList& list) 347 487 { 348 488 if (CommandEvaluation::getSize(list) == 0) 349 489 { 490 // no (non-empty) values in the list, return an empty string 350 491 return ""; 351 492 } 352 493 else if (CommandEvaluation::getSize(list) == 1) 353 494 { 495 // only one (non-empty) value in the list - search it and return it 354 496 for (ArgumentCompletionList::const_iterator it = list.begin(); it != list.end(); ++it) 355 497 { 356 498 if (it->getComparable() != "") 357 499 { 500 // arguments that have a separate string to be displayed need a little more care - just return them without modification. add a space character to the others. 358 501 if (it->hasDisplay()) 359 502 return (it->getString()); … … 367 510 else 368 511 { 512 // multiple arguments in the list - iterate through it and find the common begin of all arguments 369 513 std::string output; 370 514 for (unsigned int i = 0; true; i++) 371 515 { 372 char tempComparable = 0;373 char temp = 0;516 char tempComparable = '\0'; 517 char temp = '\0'; 374 518 for (ArgumentCompletionList::const_iterator it = list.begin(); it != list.end(); ++it) 375 519 { … … 377 521 const std::string& argument = it->getString(); 378 522 523 // ignore empty arguments 379 524 if (argumentComparable == "") 380 525 continue; … … 382 527 if (argument.size() > i) 383 528 { 384 if (tempComparable == 0)529 if (tempComparable == '\0') 385 530 { 531 // the first entry is always taken 386 532 tempComparable = argumentComparable[i]; 387 533 temp = argument[i]; … … 389 535 else 390 536 { 537 // all other entries need comparison to the first entry 391 538 if (tempComparable != argumentComparable[i]) 392 539 return output; 393 else if (temp != argument[i]) 540 else if (temp != argument[i]) // the comparables match, but the normal chars don't - switch to comparable only 394 541 temp = tempComparable; 395 542 } … … 406 553 } 407 554 555 /** 556 @brief Joins the elements of the given list to a string. 557 */ 408 558 /* static */ std::string CommandEvaluation::dump(const ArgumentCompletionList& list) 409 559 { … … 413 563 output += it->getDisplay(); 414 564 565 // add a space character between two elements for all non-empty arguments 415 566 if (it->getComparable() != "") 416 567 output += ' '; … … 419 570 } 420 571 572 /** 573 @brief Returns a string that explains the syntax of the given command. 574 */ 421 575 /* static */ std::string CommandEvaluation::dump(const ConsoleCommand* command) 422 576 { 577 // get the name of the command 423 578 std::string output = command->getName(); 579 580 // check if there are parameters 424 581 if (command->getExecutor()->getParamCount() > 0) 425 582 output += ": "; 426 583 584 // iterate through the parameters 427 585 for (unsigned int i = 0; i < command->getExecutor()->getParamCount(); i++) 428 586 { 587 // separate the parameters with a space character 429 588 if (i != 0) 430 589 output += ' '; 431 590 591 // print default values in [], others in {} braces 432 592 if (command->getExecutor()->defaultValueSet(i)) 433 593 output += '['; … … 435 595 output += '{'; 436 596 597 // add the type-name of the parameter 437 598 output += command->getExecutor()->getTypenameParam(i); 438 599 600 // print the default value if available 439 601 if (command->getExecutor()->defaultValueSet(i)) 440 602 output += '=' + command->getExecutor()->getDefaultValue(i).getString() + ']'; -
code/trunk/src/libraries/core/command/CommandEvaluation.h
r7284 r7401 27 27 */ 28 28 29 /** 30 @defgroup CommandExecEval Command execution and evaluation 31 @ingroup Command 32 */ 33 34 /** 35 @file 36 @ingroup Command CommandExecEval 37 @brief Declaration of the orxonox::CommandEvaluation class which is returned by orxonox::CommandExecutor::evaluate(). 38 39 The orxonox::CommandEvaluation class gathers all information about a command-string. It is used 40 internally by orxonox::CommandExecutor and can also be returned by it to provide more information 41 about a command. It's also possible to evaluate the arguments of a command to execute it faster. 42 43 @see See @ref CommandExecutorExample "this description" for an example. 44 */ 45 29 46 #ifndef _CommandEvaluation_H__ 30 47 #define _CommandEvaluation_H__ … … 41 58 namespace orxonox 42 59 { 60 /** 61 @brief CommandEvaluation is used to gather information about a command and to evaluate its arguments 62 63 This class provides several information about a command-string, for example the 64 evaluated ConsoleCommand, but also other information like hints if the command 65 is not yet finished. 66 67 @note You don't have to call evaluateArguments() manually, it's also done automatically 68 if you call the command the first time. However you can of course do it at any earlier 69 time, for example to return an error message if it doesn't work. 70 71 @remarks execCommand_ and hintCommand_ can be different in this case: There are multiple 72 commands avaliable, let's say "tcl", "tclexecute", and "tclquery". The user enters 73 "tcl", which is already a valid command. Now execCommand_ points to the "tcl"-command, 74 but hintCommand_ still points to the autocompletion command of CommandExecutor, because 75 the auto-completion list must still return the three possible commands, "tcl tclexecute tclquery" 76 because the user may want to execute "tclquery" and needs auto-completion. 77 78 @see See @ref CommandExecutorExample "this description" for an example. 79 */ 43 80 class _CoreExport CommandEvaluation 44 81 { … … 56 93 std::string getCommandSuggestion() const; 57 94 58 int evaluate Params(bool bPrintError = false);95 int evaluateArguments(bool bPrintError = false); 59 96 97 /// Returns true if the command evaluation contains a valid command that can be executed. 60 98 inline bool isValid() const 61 99 { return (this->execCommand_ != 0); } 62 100 101 /// Returns the console command that was evaluated by this object. 63 102 inline const ConsoleCommand* getConsoleCommand() const 64 103 { return this->execCommand_; } 65 104 66 void setEvaluated Parameter(unsigned int index, const MultiType& param);67 MultiType getEvaluated Parameter(unsigned int index) const;105 void setEvaluatedArgument(unsigned int index, const MultiType& arg); 106 MultiType getEvaluatedArgument(unsigned int index) const; 68 107 108 /** 109 @brief Returns a list of possible arguments for the given command. 110 111 Note that the command's arguments may not be complete yet, so in this case 112 this list returns the possibilities. They can then be used to display a list 113 of the possible arguments or to apply auto-completion. 114 */ 69 115 const ArgumentCompletionList& getPossibleArguments() const 70 116 { return this->possibleArguments_; } 71 117 118 /// Returns the number of possible arguments. Empty ("") arguments are not counted. 72 119 size_t getPossibleArgumentsSize() const 73 120 { return CommandEvaluation::getSize(this->possibleArguments_); } … … 90 137 static std::string getCommonBegin(const ArgumentCompletionList& list); 91 138 92 const ConsoleCommand* execCommand_; 93 const ConsoleCommand* hintCommand_; 94 SubString tokens_; 95 std::string string_; 96 unsigned int execArgumentsOffset_; 97 unsigned int hintArgumentsOffset_; 98 bool bPossibleArgumentsRetrieved_; 99 ArgumentCompletionList possibleArguments_; 139 const ConsoleCommand* execCommand_; ///< The command that will be executed (can be NULL if the command is not valid) 140 const ConsoleCommand* hintCommand_; ///< The command that is used to display hints and argument lists (can be different to execCommand_ in some cases) 141 SubString tokens_; ///< The single words of the command string, split into tokens 142 std::string string_; ///< The original command string, entered by the user in the shell 143 unsigned int execArgumentsOffset_; ///< The index of the first argument in tokens_ used to execute the command 144 unsigned int hintArgumentsOffset_; ///< The index of the first argument in tokens_ used to display hints and argument lists 145 bool bPossibleArgumentsRetrieved_; ///< True if the list of possible arguments was already retrieved 146 ArgumentCompletionList possibleArguments_; ///< List of possible arguments for the command in the current state 100 147 101 bool bEvaluated Params_;102 bool bTriedToEvaluated Params_;103 unsigned int numberOfEvaluated Params_;104 MultiType param_[MAX_FUNCTOR_ARGUMENTS];148 bool bEvaluatedArguments_; ///< True if the arguments of the command have been evaluated (and stored in arguments_) 149 bool bTriedToEvaluatedArguments_; ///< True if an attempt was started to evaluate the arguments (but not necessarily successful) 150 unsigned int numberOfEvaluatedArguments_; ///< The number of evaluated arguments (ranges from 0 to MAX_FUNCTOR_ARGUMENTS) 151 MultiType arguments_[MAX_FUNCTOR_ARGUMENTS]; ///< The evaluated arguments (the arguments from string_ or tokens_ converted to the right type) 105 152 }; 106 153 } -
code/trunk/src/libraries/core/command/CommandExecutor.cc
r7284 r7401 27 27 */ 28 28 29 /** 30 @file 31 @brief Implementation of CommandExecutor 32 */ 33 29 34 #include "CommandExecutor.h" 30 35 … … 49 54 .argumentCompleter(1, autocompletion::command()); 50 55 56 /** 57 @brief Returns a reference to the only instance of CommandExecutor. 58 */ 51 59 /* static */ CommandExecutor& CommandExecutor::getInstance() 52 60 { … … 55 63 } 56 64 65 /** 66 @brief Executes a command. 67 @param command A string containing the command 68 @param useTcl If true, the command is passed to tcl (see TclBind) 69 @return Returns the error-code (see @ref CommandExecutorErrorCodes "error codes") 70 */ 57 71 /* static */ int CommandExecutor::execute(const std::string& command, bool useTcl) 58 72 { … … 62 76 } 63 77 78 /** 79 @brief Executes a command and returns its return-value. 80 @param command A string containing the command 81 @param error A pointer to a value (or NULL) where the error-code should be written to (see @ref CommandExecutorErrorCodes "error codes") 82 @param useTcl If true, the command is passed to tcl (see TclBind) 83 @return Returns the return-value of the command (if any - MT_Type::Null otherwise) 84 */ 64 85 /* static */ MultiType CommandExecutor::queryMT(const std::string& command, int* error, bool useTcl) 65 86 { 66 87 if (useTcl) 88 { 89 // pass the command to tcl 67 90 return TclBind::eval(command, error); 91 } 68 92 else 69 93 { 70 94 CommandEvaluation evaluation; 95 96 // try to get the command evaluation from the cache 71 97 if (!CommandExecutor::getInstance().getCached(command, evaluation)) 72 98 { 99 // it wasn't in the cache - evaluate the command 73 100 evaluation = CommandExecutor::evaluate(command); 74 evaluation.evaluateParams(); 101 102 // evaluate its arguments 103 evaluation.evaluateArguments(); 104 105 // write the evaluation to the cache 75 106 CommandExecutor::getInstance().cache(command, evaluation); 76 107 } 77 108 109 // query the command and return its return-value 78 110 return evaluation.query(error); 79 111 } 80 112 } 81 113 114 /** 115 @brief Executes a command and returns its return-value as string. 116 @param command A string containing the command 117 @param error A pointer to a value (or NULL) where the error-code should be written to (see @ref CommandExecutorErrorCodes "error codes") 118 @param useTcl If true, the command is passed to tcl (see TclBind) 119 @return Returns the return-value of the command converted to a string (or "" if there's no return value) 120 */ 82 121 /* static */ std::string CommandExecutor::query(const std::string& command, int* error, bool useTcl) 83 122 { … … 85 124 } 86 125 126 /** 127 @brief Evaluates the given command. 128 @param command A string containing the command 129 @return Returns an instance of CommandEvaluation, which contains the evaluated ConsoleCommand, if the command is valid. 130 131 Evaluates the given command string and returns an instance of CommandEvaluation. 132 If the command is valid, this contains the evaluated ConsoleCommand. Otherwise it 133 can still be used to print hints or complete the command. 134 135 @note Tcl commands can not be evaluated. You have to pass them to execute() or to 136 TclBind directly. 137 */ 87 138 /* static */ CommandEvaluation CommandExecutor::evaluate(const std::string& command) 88 139 { 140 // initialize the command evaluation 89 141 CommandEvaluation evaluation; 90 142 evaluation.initialize(command); 91 143 144 // assign the fallback-command to get hints about the possible commands and groups 92 145 evaluation.hintCommand_ = ConsoleCommand::getCommand(__CC_CommandExecutor_name, __CC_autocomplete_name); 93 146 147 // check if there's at least one argument 94 148 if (evaluation.getNumberOfArguments() >= 1) 95 149 { 150 // try to get a command from the first token 96 151 evaluation.execCommand_ = ConsoleCommand::getCommandLC(evaluation.getToken(0)); 97 152 if (evaluation.execCommand_) … … 99 154 else if (evaluation.getNumberOfArguments() >= 2) 100 155 { 156 // try to get a command from the first two tokens 101 157 evaluation.execCommand_ = ConsoleCommand::getCommandLC(evaluation.getToken(0), evaluation.getToken(1)); 102 158 if (evaluation.execCommand_) … … 105 161 } 106 162 163 // if a valid command was found and the user is already entering arguments, overwrite hintCommand_ with execCommand_ 107 164 if (evaluation.execCommand_ && evaluation.getNumberOfArguments() > evaluation.execArgumentsOffset_) 108 165 { … … 114 171 } 115 172 173 /** 174 @brief Gets an evaluated command from the cache. 175 @param command The command that should be looked up in the cache 176 @param evaluation Reference to a CommandEvaluation that will be used to return the cached evaluation. 177 @return Returns true if the command was found in the cache 178 */ 116 179 bool CommandExecutor::getCached(const std::string& command, CommandEvaluation& evaluation) 117 180 { … … 119 182 return false; 120 183 184 // check if the command is in the cache 121 185 std::map<std::string, CacheEntry>::iterator it = this->cache_.find(command); 122 186 if (it != this->cache_.end()) … … 134 198 } 135 199 200 /** 201 @brief Writes a command evaluation for a given command to the cache. 202 */ 136 203 void CommandExecutor::cache(const std::string& command, const CommandEvaluation& evaluation) 137 204 { … … 156 223 } 157 224 225 /** 226 @brief This function is used as console command which executes commands that are usually hidden. 227 228 The argument completion function of this console commands is used to find 229 and enter hidden commands and their arguments. 230 */ 158 231 /* static */ MultiType CommandExecutor::unhide(const std::string& command) 159 232 { … … 161 234 } 162 235 236 /** 237 @brief This function is used as console command which saves a command and optionally also it's arguments as a new console command with a new name. 238 @param alias The name of the new command alias 239 @param command The existing command and (optionally) its arguments 240 */ 163 241 /* static */ void CommandExecutor::alias(const std::string& alias, const std::string& command) 164 242 { 243 // first check if the given command is valid, else print an error 165 244 CommandEvaluation evaluation = CommandExecutor::evaluate(command); 166 245 if (evaluation.isValid()) 167 246 { 247 // it is valid - copy the executor of this command 168 248 ExecutorPtr executor = new Executor(*evaluation.getConsoleCommand()->getExecutor().get()); 169 249 170 if (!evaluation.evaluateParams()) 250 // evaluate the arguments and if this returns no error, store them as default values 251 if (!evaluation.evaluateArguments()) 171 252 { 172 253 for (size_t i = 0; i < MAX_FUNCTOR_ARGUMENTS; ++i) 173 executor->setDefaultValue(i, evaluation.getEvaluatedParameter(i)); 174 } 175 254 executor->setDefaultValue(i, evaluation.getEvaluatedArgument(i)); 255 } 256 257 // split the alias in tokens 176 258 SubString tokens(alias, " "); 177 259 260 // check if the alias already exists - print an error and return if it does 178 261 if ((tokens.size() == 1 && ConsoleCommand::getCommand(tokens[0])) || (tokens.size() == 2 && ConsoleCommand::getCommand(tokens[0], tokens[1]))) 179 262 { … … 182 265 } 183 266 267 // create a new console command with the given alias as its name 184 268 if (tokens.size() == 1) 185 269 createConsoleCommand(tokens[0], executor); -
code/trunk/src/libraries/core/command/CommandExecutor.h
r7284 r7401 27 27 */ 28 28 29 /** 30 @file 31 @ingroup Command CommandExecEval 32 @brief Declaration of the orxonox::CommandExecutor class which is used to execute and evaluate @ref orxonox::ConsoleCommand "console commands". 33 34 @anchor CommandExecutorExample 35 36 orxonox::CommandExecutor can be used to execute console commands (see orxonox::ConsoleCommand). 37 Commands are strings that can be entered by the user in the shell or they can be part of a 38 script. 39 40 A command can be passed to orxonox::CommandExecutor::execute() which will execute them - eiter 41 directly, or - if requested - passes it to Tcl. See orxonox::TclBind for more information. 42 Appart from execute() the command can also be passed to orxonox::CommandExecutor::query() which 43 behaves the same except for that it returns the return value of the command. 44 45 If you don't want to execute the command, but rather gather more information about it, pass it 46 to orxonox::CommandExecutor::evaluate(). This function returns an instance of 47 orxonox::CommandEvaluation. This class provides more information about the command, for example 48 the evaluated instance of orxonox::ConsoleCommand. Its also possible to gather hints about the 49 command or to complete the command-string by using argument completion functions. More than that 50 the command evaluation can also evaluate the arguments, which allows faster execution of the 51 command. 52 53 Example: 54 @code 55 CommandExecutor::execute("log test"); // writes "test" to the console 56 CommandExecutor::execute("log [expr 1+1]"); // writes "2" to the console - expr is a Tcl command 57 58 CommandExecutor::query("expr 1+1"); // returns "2" 59 CommandExecutor::queryMT("expr 1+1"); // returns 2 60 @endcode 61 62 And another example about how to use evaluate(): 63 @code 64 CommandEvaluation evaluation; 65 evaluation = CommandExecutor::evaluate("log test"); // returns an evaluation of "log test" 66 67 evaluation.execute(); // writes "test" to the console 68 evaluation.hint(); // returns "log: {string}" 69 @endcode 70 71 @anchor CommandExecutorErrorCodes 72 73 @b Error @b codes: 74 75 orxonox::CommandExecutor defines a number of error codes that are returned 76 by different functions that operate with commands: 77 78 - CommandExecutor::Success: No error 79 - CommandExecutor::Error: The command doesn't exist 80 - CommandExecutor::Incomplete: The command needs more arguments 81 - CommandExecutor::Deactivated: The command is not active 82 - CommandExecutor::Denied: The command needs a different @ref orxonox::AccessLevel "access level" 83 */ 84 29 85 #ifndef _CommandExecutor_H__ 30 86 #define _CommandExecutor_H__ … … 42 98 namespace orxonox 43 99 { 100 /** 101 @brief This class is used to execute and evaluate command-strings. 102 103 CommandExecutor executes command-strings and returns evaluated commands. It's 104 also possible to execute Tcl commands if the corresponding argument of execute() 105 is true. 106 107 @see See @ref CommandExecutorExample "this description" for more information and some examples. 108 */ 44 109 class _CoreExport CommandExecutor 45 110 { … … 53 118 static CommandEvaluation evaluate(const std::string& command); 54 119 55 static const int Success = 0; 56 static const int Error = 1; 57 static const int Incomplete = 2; 58 static const int Deactivated = 3; 59 static const int Denied = 4; 120 static const int Success = 0; ///< Error code for "success" (or no error) 121 static const int Error = 1; ///< Error code if the command doesn't exist 122 static const int Incomplete = 2; ///< Error code if the command needs more arguments 123 static const int Deactivated = 3; ///< Error code if the command is not active 124 static const int Denied = 4; ///< Error code if the command needs a different access level 60 125 61 126 static MultiType unhide(const std::string& command); 62 127 static void alias(const std::string& alias, const std::string& command); 63 static void _autocomplete(const std::string& group, const std::string& name) {} 128 static void _autocomplete(const std::string& group, const std::string& name) {} ///< Pseudo console command used whenever no real command is available. In these cases this command provides auto-completion for console commands and groups. 64 129 65 130 private: 66 CommandExecutor() {} 67 CommandExecutor(const CommandExecutor& other); 68 ~CommandExecutor() {} 131 CommandExecutor() {} ///< Empty constructor 132 CommandExecutor(const CommandExecutor& other); ///< Not implemented copy-constructor 133 ~CommandExecutor() {} ///< Empty destructor 69 134 70 135 static CommandExecutor& getInstance(); … … 73 138 void cache(const std::string& command, const CommandEvaluation& evaluation); 74 139 140 /// Helper struct, used to store cached entries 75 141 struct CacheEntry 76 142 { 77 CommandEvaluation evaluation_; 78 std::list<std::string>::iterator iterator_; 143 CommandEvaluation evaluation_; ///< The command evaluation which is stored in the cache 144 std::list<std::string>::iterator iterator_; ///< The iterator of the corresponding element in cachelist_, used for faster access 79 145 }; 80 146 81 std::map<std::string, CacheEntry> cache_; 82 std::list<std::string> cachelist_; 147 std::map<std::string, CacheEntry> cache_; ///< A map that connects command strings and evaluated commands in the cache 148 std::list<std::string> cachelist_; ///< A list used to sort the elements in the cache by their age 83 149 }; // tolua_export 84 150 } // tolua_export -
code/trunk/src/libraries/core/command/ConsoleCommand.cc
r7284 r7401 27 27 */ 28 28 29 /** 30 @file 31 @brief Implementation of the ConsoleCommand class. 32 */ 33 29 34 #include "ConsoleCommand.h" 30 35 … … 36 41 namespace orxonox 37 42 { 43 /** 44 @brief Constructor: Initializes all values and registers the command. 45 @param group The group of the command 46 @param name The name of the command 47 @param executor The executor of the command 48 @param bInitialized If true, the executor is used for both, the definition of the function-header AND to executute the command. If false, the command is inactive and needs to be assigned a function before it can be used. 49 */ 38 50 ConsoleCommand::ConsoleCommand(const std::string& group, const std::string& name, const ExecutorPtr& executor, bool bInitialized) 39 51 { … … 45 57 this->baseFunctor_ = executor->getFunctor(); 46 58 47 this->argumentCompleter_[0] = 0; 48 this->argumentCompleter_[1] = 0; 49 this->argumentCompleter_[2] = 0; 50 this->argumentCompleter_[3] = 0; 51 this->argumentCompleter_[4] = 0; 59 for (size_t i = 0; i < MAX_FUNCTOR_ARGUMENTS; ++i) 60 this->argumentCompleter_[i] = 0; 52 61 53 62 this->keybindMode_ = KeybindMode::OnPress; … … 60 69 } 61 70 71 /** 72 @brief Destructor: Unregisters the command. 73 */ 62 74 ConsoleCommand::~ConsoleCommand() 63 75 { … … 65 77 } 66 78 79 /** 80 @brief Registers the command with the same name, but without group, as shortcut. 81 */ 67 82 ConsoleCommand& ConsoleCommand::addShortcut() 68 83 { … … 71 86 } 72 87 88 /** 89 @brief Registers the command with an alias as shortcut. 90 */ 73 91 ConsoleCommand& ConsoleCommand::addShortcut(const std::string& name) 74 92 { … … 77 95 } 78 96 97 /** 98 @brief Registers the command in a different group but with the same name. 99 */ 79 100 ConsoleCommand& ConsoleCommand::addGroup(const std::string& group) 80 101 { … … 83 104 } 84 105 106 /** 107 @brief Registers an alias of the command in a different group with a different name. 108 */ 85 109 ConsoleCommand& ConsoleCommand::addGroup(const std::string& group, const std::string& name) 86 110 { … … 89 113 } 90 114 115 /** 116 @brief Returns true if the command can be executed right now. 117 118 This returns only true, if the following conditions are met: 119 - The command is active 120 - The command has an executor 121 - The executor has a functor 122 - The functor is static or has an object 123 */ 91 124 bool ConsoleCommand::isActive() const 92 125 { … … 94 127 } 95 128 129 /** 130 @brief Returns true if the current state of the game matches the required access level. 131 */ 96 132 bool ConsoleCommand::hasAccess() const 97 133 { … … 101 137 case AccessLevel::Standalone: return GameMode::isStandalone(); 102 138 case AccessLevel::Master: return GameMode::isMaster(); 103 case AccessLevel::Server: return GameMode:: hasServer();139 case AccessLevel::Server: return GameMode::isServer(); 104 140 case AccessLevel::Client: return GameMode::isClient(); 105 case AccessLevel::Online: return (GameMode:: hasServer() || GameMode::isClient());141 case AccessLevel::Online: return (GameMode::isServer() || GameMode::isClient()); 106 142 case AccessLevel::Offline: return GameMode::isStandalone(); 107 143 case AccessLevel::None: return false; … … 110 146 } 111 147 148 /** 149 @brief Returns true if the headers of the given functor match the declaration of this command. 150 */ 112 151 bool ConsoleCommand::headersMatch(const FunctorPtr& functor) 113 152 { 153 // get the minimum of the number of parameters of both commands 114 154 unsigned int minparams = std::min(this->baseFunctor_->getParamCount(), functor->getParamCount()); 115 155 156 // if the reduced headers don't match -> return false 116 157 if (this->baseFunctor_->getHeaderIdentifier(minparams) != functor->getHeaderIdentifier(minparams)) 117 158 return false; 159 // if the reduced headers match and the new functor has less or equal parameters -> return true 118 160 else if (functor->getParamCount() <= this->baseFunctor_->getParamCount()) 119 161 return true; 162 // the headers match but the new functor has more arguments and there is no executor with default-values -> return false 120 163 else if (!this->executor_) 121 164 return false; 165 // the headers match but the new functor has more arguments, check if the executor has enough default-values 122 166 else 123 167 { … … 135 179 } 136 180 181 /** 182 @brief Returns true if the headers of the given executor match the declaration of this command. 183 */ 137 184 bool ConsoleCommand::headersMatch(const ExecutorPtr& executor) 138 185 { 186 // get the minimum of the number of parameters of both commands 139 187 unsigned int minparams = std::min(this->baseFunctor_->getParamCount(), executor->getParamCount()); 140 188 189 // if the reduced headers don't match -> return false 141 190 if (this->baseFunctor_->getHeaderIdentifier(minparams) != executor->getFunctor()->getHeaderIdentifier(minparams)) 142 191 return false; 192 // if the reduced headers match and the new functor has less or equal parameters -> return true 143 193 else if (executor->getParamCount() <= this->baseFunctor_->getParamCount()) 144 194 return true; 195 // the headers match but the new functor has more arguments, check if the new executor has enough default-values 145 196 else 146 197 { … … 158 209 } 159 210 211 /** 212 @brief Changes the executor. 213 @param executor The new executor 214 @param bForce If true, the executor is always assigned, even if the headers don't match 215 @return Returns true if the assignment was successful 216 */ 160 217 bool ConsoleCommand::setFunction(const ExecutorPtr& executor, bool bForce) 161 218 { 219 // assign the executor if a) it's a null-pointer, b) its functor is a null-pointer, c) it's forced, d) the headers match 162 220 if (!executor || !executor->getFunctor() || bForce || this->headersMatch(executor)) 163 221 { 222 // assign the executor and clear the object stack (because it's also a new function) 164 223 this->executor_ = executor; 165 224 this->objectStack_.clear(); … … 173 232 } 174 233 234 /** 235 @brief Changes the functor of the current executor. 236 @param functor The new functor 237 @param bForce If true, the functor is always assigned, even if the headers don't match 238 @return Returns true if the assignment was successful 239 */ 175 240 bool ConsoleCommand::setFunction(const FunctorPtr& functor, bool bForce) 176 241 { 242 // assign the functor if a) it's a null-pointer, b) it's forced, c) the headers match 177 243 if (!functor || bForce || this->headersMatch(functor)) 178 244 { 245 // assign the functor (create a new executor if necessary) and clear the object stack 179 246 if (this->executor_) 180 247 this->executor_->setFunctor(functor); … … 192 259 } 193 260 261 /** 262 @brief Pushes a new executor to the command-stack. 263 @param executor The new executor 264 @param bForce If true, the executor is always assigned, even if the headers don't match 265 */ 194 266 void ConsoleCommand::pushFunction(const ExecutorPtr& executor, bool bForce) 195 267 { 268 // prepare the old function to be put on the stack 196 269 Command command; 197 270 command.executor_ = this->executor_; … … 200 273 command.objectStack_ = this->objectStack_; 201 274 275 // check if the new executor can be assigned and push the old function to the stack 202 276 if (this->setFunction(executor, bForce)) 203 277 this->commandStack_.push(command); 204 278 } 205 279 280 /** 281 @brief Pushes a new functor to the command-stack. 282 @param functor The new functor 283 @param bForce If true, the functor is always assigned, even if the headers don't match 284 */ 206 285 void ConsoleCommand::pushFunction(const FunctorPtr& functor, bool bForce) 207 286 { 287 // prepare the old function to be put on the stack 208 288 Command command; 209 289 command.executor_ = this->executor_; … … 212 292 command.objectStack_ = this->objectStack_; 213 293 294 // check if the new functor can be assigned and push the old function to the stack 214 295 if (this->setFunction(functor, bForce)) 215 296 this->commandStack_.push(command); 216 297 } 217 298 299 /** 300 @brief Pushes a copy of the current executor and functor on the stack. 301 */ 218 302 void ConsoleCommand::pushFunction() 219 303 { … … 224 308 } 225 309 310 /** 311 @brief Removes the current function from the stack and restores the old state. 312 */ 226 313 void ConsoleCommand::popFunction() 227 314 { 228 315 Command command; 316 317 // check if there's a function on the stack 229 318 if (!this->commandStack_.empty()) 230 319 { 320 // yes it is - assign it to command and remove it from the stack 231 321 command = this->commandStack_.top(); 232 322 this->commandStack_.pop(); 233 323 } 234 324 325 // restore the old executor (and also restore its functor in case this was changed in the meantime) 235 326 this->executor_ = command.executor_; 236 327 if (command.executor_) … … 239 330 } 240 331 332 /** 333 @brief Sets the functor to NULL (which also deactivates the command). 334 */ 241 335 void ConsoleCommand::resetFunction() 242 336 { … … 246 340 } 247 341 342 /** 343 @brief Returns the current executor which can be used to execute the command. 344 */ 248 345 const ExecutorPtr& ConsoleCommand::getExecutor() const 249 346 { … … 251 348 } 252 349 350 /** 351 @brief Changes the current object that is used to execute member-functions. 352 @return Returns true if the object was successfully changed 353 */ 253 354 bool ConsoleCommand::setObject(void* object) 254 355 { 255 if (this->executor_) 256 { 356 // check if there's an executor 357 if (this->executor_) 358 { 359 // check if there's a functor 257 360 if (this->executor_->getFunctor()) 258 361 { 362 // change the object 259 363 this->executor_->getFunctor()->setRawObjectPointer(object); 260 364 return true; … … 269 373 } 270 374 375 /** 376 @brief Push a new object to the object-stack. 377 */ 271 378 void ConsoleCommand::pushObject(void* object) 272 379 { … … 276 383 } 277 384 385 /** 386 @brief Removes the current object from the stack an restores the old object. 387 */ 278 388 void ConsoleCommand::popObject() 279 389 { … … 287 397 } 288 398 399 /** 400 @brief Returns the current object pointer that is used to execute member-functions. 401 */ 289 402 void* ConsoleCommand::getObject() const 290 403 { … … 295 408 } 296 409 297 ConsoleCommand& ConsoleCommand::defaultValues(const MultiType& param1) 298 { 299 if (this->executor_) 300 this->executor_->setDefaultValues(param1); 410 /** 411 @brief Changes the default values of the current executor. 412 */ 413 ConsoleCommand& ConsoleCommand::defaultValues(const MultiType& arg1) 414 { 415 if (this->executor_) 416 this->executor_->setDefaultValues(arg1); 301 417 else 302 418 COUT(1) << "Error: Can't set default values in console command \"" << this->baseName_ << "\", no executor set." << std::endl; … … 305 421 } 306 422 307 ConsoleCommand& ConsoleCommand::defaultValues(const MultiType& param1, const MultiType& param2) 308 { 309 if (this->executor_) 310 this->executor_->setDefaultValues(param1, param2); 423 /** 424 @brief Changes the default values of the current executor. 425 */ 426 ConsoleCommand& ConsoleCommand::defaultValues(const MultiType& arg1, const MultiType& arg2) 427 { 428 if (this->executor_) 429 this->executor_->setDefaultValues(arg1, arg2); 311 430 else 312 431 COUT(1) << "Error: Can't set default values in console command \"" << this->baseName_ << "\", no executor set." << std::endl; … … 315 434 } 316 435 317 ConsoleCommand& ConsoleCommand::defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3) 318 { 319 if (this->executor_) 320 this->executor_->setDefaultValues(param1, param2, param3); 436 /** 437 @brief Changes the default values of the current executor. 438 */ 439 ConsoleCommand& ConsoleCommand::defaultValues(const MultiType& arg1, const MultiType& arg2, const MultiType& arg3) 440 { 441 if (this->executor_) 442 this->executor_->setDefaultValues(arg1, arg2, arg3); 321 443 else 322 444 COUT(1) << "Error: Can't set default values in console command \"" << this->baseName_ << "\", no executor set." << std::endl; … … 325 447 } 326 448 327 ConsoleCommand& ConsoleCommand::defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4) 328 { 329 if (this->executor_) 330 this->executor_->setDefaultValues(param1, param2, param3, param4); 449 /** 450 @brief Changes the default values of the current executor. 451 */ 452 ConsoleCommand& ConsoleCommand::defaultValues(const MultiType& arg1, const MultiType& arg2, const MultiType& arg3, const MultiType& arg4) 453 { 454 if (this->executor_) 455 this->executor_->setDefaultValues(arg1, arg2, arg3, arg4); 331 456 else 332 457 COUT(1) << "Error: Can't set default values in console command \"" << this->baseName_ << "\", no executor set." << std::endl; … … 335 460 } 336 461 337 ConsoleCommand& ConsoleCommand::defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) 338 { 339 if (this->executor_) 340 this->executor_->setDefaultValues(param1, param2, param3, param4, param5); 462 /** 463 @brief Changes the default values of the current executor. 464 */ 465 ConsoleCommand& ConsoleCommand::defaultValues(const MultiType& arg1, const MultiType& arg2, const MultiType& arg3, const MultiType& arg4, const MultiType& arg5) 466 { 467 if (this->executor_) 468 this->executor_->setDefaultValues(arg1, arg2, arg3, arg4, arg5); 341 469 else 342 470 COUT(1) << "Error: Can't set default values in console command \"" << this->baseName_ << "\", no executor set." << std::endl; … … 345 473 } 346 474 347 ConsoleCommand& ConsoleCommand::defaultValue(unsigned int index, const MultiType& param) 348 { 349 if (this->executor_) 350 this->executor_->setDefaultValue(index, param); 475 /** 476 @brief Changes the default value of the argument with given index of the current executor. 477 @param index The index of the argument (the first argument has index 0) 478 @param arg The new default value 479 */ 480 ConsoleCommand& ConsoleCommand::defaultValue(unsigned int index, const MultiType& arg) 481 { 482 if (this->executor_) 483 this->executor_->setDefaultValue(index, arg); 351 484 else 352 485 COUT(1) << "Error: Can't set default values in console command \"" << this->baseName_ << "\", no executor set." << std::endl; … … 355 488 } 356 489 357 ConsoleCommand& ConsoleCommand::argumentCompleter(unsigned int param, ArgumentCompleter* completer) 358 { 359 if (param < 5) 360 this->argumentCompleter_[param] = completer; 361 else 362 COUT(2) << "Warning: Couldn't add autocompletion-function for param " << param << " in console command \"" << this->baseName_ << "\": index out of bound." << std::endl; 363 364 return *this; 365 } 366 367 ArgumentCompleter* ConsoleCommand::getArgumentCompleter(unsigned int param) const 368 { 369 if (param < 5) 370 return this->argumentCompleter_[param]; 490 /** 491 @brief Changes the argument completer for the given argument. 492 @param index The index of the argument (the first argument has index 0) 493 @param completer The new argument completer 494 */ 495 ConsoleCommand& ConsoleCommand::argumentCompleter(unsigned int index, ArgumentCompleter* completer) 496 { 497 if (index < 5) 498 this->argumentCompleter_[index] = completer; 499 else 500 COUT(2) << "Warning: Couldn't add autocompletion-function for index " << index << " in console command \"" << this->baseName_ << "\": index out of bound." << std::endl; 501 502 return *this; 503 } 504 505 /** 506 @brief Returns the argument completer for the argument with given index. 507 */ 508 ArgumentCompleter* ConsoleCommand::getArgumentCompleter(unsigned int index) const 509 { 510 if (index < 5) 511 return this->argumentCompleter_[index]; 371 512 else 372 513 return 0; 373 514 } 374 515 516 /** 517 @brief Sets the description of this command. 518 */ 375 519 ConsoleCommand& ConsoleCommand::description(const std::string& description) 376 520 { … … 380 524 } 381 525 526 /** 527 @brief Returns the description of this command. 528 */ 382 529 const std::string& ConsoleCommand::getDescription() const 383 530 { … … 385 532 } 386 533 387 ConsoleCommand& ConsoleCommand::descriptionParam(unsigned int param, const std::string& description) 388 { 389 if (param < MAX_FUNCTOR_ARGUMENTS) 390 { 391 this->descriptionParam_[param] = std::string("ConsoleCommandDescription::" + this->baseName_ + "::param" + multi_cast<std::string>(param)); 392 AddLanguageEntry(this->descriptionParam_[param], description); 393 } 394 return *this; 395 } 396 397 const std::string& ConsoleCommand::getDescriptionParam(unsigned int param) const 398 { 399 if (param < MAX_FUNCTOR_ARGUMENTS) 400 return GetLocalisation_noerror(this->descriptionParam_[param]); 534 /** 535 @brief Sets the description for an argument with given index. 536 */ 537 ConsoleCommand& ConsoleCommand::descriptionParam(unsigned int index, const std::string& description) 538 { 539 if (index < MAX_FUNCTOR_ARGUMENTS) 540 { 541 this->descriptionParam_[index] = std::string("ConsoleCommandDescription::" + this->baseName_ + "::param" + multi_cast<std::string>(index)); 542 AddLanguageEntry(this->descriptionParam_[index], description); 543 } 544 return *this; 545 } 546 547 /** 548 @brief Returns the description for the argument with given index. 549 */ 550 const std::string& ConsoleCommand::getDescriptionParam(unsigned int index) const 551 { 552 if (index < MAX_FUNCTOR_ARGUMENTS) 553 return GetLocalisation_noerror(this->descriptionParam_[index]); 401 554 402 555 return this->descriptionParam_[0]; 403 556 } 404 557 558 /** 559 @brief Sets the description for the return-value. 560 */ 405 561 ConsoleCommand& ConsoleCommand::descriptionReturnvalue(const std::string& description) 406 562 { … … 410 566 } 411 567 412 const std::string& ConsoleCommand::getDescriptionReturnvalue(int param) const 568 /** 569 @brief Returns the description for the return-value. 570 */ 571 const std::string& ConsoleCommand::getDescriptionReturnvalue(int index) const 413 572 { 414 573 return GetLocalisation_noerror(this->descriptionReturnvalue_); 415 574 } 416 575 576 /** 577 @brief Returns the command with given group an name. 578 @param group The group of the requested command 579 @param name The group of the requested command 580 @param bPrintError If true, an error is printed if the command doesn't exist 581 */ 417 582 /* static */ const ConsoleCommand* ConsoleCommand::getCommand(const std::string& group, const std::string& name, bool bPrintError) 418 583 { 584 // find the group 419 585 std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = ConsoleCommand::getCommandMap().find(group); 420 586 if (it_group != ConsoleCommand::getCommandMap().end()) 421 587 { 588 // find the name 422 589 std::map<std::string, ConsoleCommand*>::const_iterator it_name = it_group->second.find(name); 423 590 if (it_name != it_group->second.end()) 424 591 { 592 // return the pointer 425 593 return it_name->second; 426 594 } … … 436 604 } 437 605 606 /** 607 @brief Returns the command with given group an name in lowercase. 608 @param group The group of the requested command in lowercase 609 @param name The group of the requested command in lowercase 610 @param bPrintError If true, an error is printed if the command doesn't exist 611 */ 438 612 /* static */ const ConsoleCommand* ConsoleCommand::getCommandLC(const std::string& group, const std::string& name, bool bPrintError) 439 613 { … … 441 615 std::string nameLC = getLowercase(name); 442 616 617 // find the group 443 618 std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = ConsoleCommand::getCommandMapLC().find(groupLC); 444 619 if (it_group != ConsoleCommand::getCommandMapLC().end()) 445 620 { 621 // find the name 446 622 std::map<std::string, ConsoleCommand*>::const_iterator it_name = it_group->second.find(nameLC); 447 623 if (it_name != it_group->second.end()) 448 624 { 625 // return the pointer 449 626 return it_name->second; 450 627 } … … 460 637 } 461 638 639 /** 640 @brief Returns the static map that stores all console commands. 641 */ 462 642 /* static */ std::map<std::string, std::map<std::string, ConsoleCommand*> >& ConsoleCommand::getCommandMap() 463 643 { … … 466 646 } 467 647 648 /** 649 @brief Returns the static map that stores all console commands in lowercase. 650 */ 468 651 /* static */ std::map<std::string, std::map<std::string, ConsoleCommand*> >& ConsoleCommand::getCommandMapLC() 469 652 { … … 472 655 } 473 656 657 /** 658 @brief Registers a new command with given group an name by adding it to the command map. 659 */ 474 660 /* static */ void ConsoleCommand::registerCommand(const std::string& group, const std::string& name, ConsoleCommand* command) 475 661 { … … 477 663 return; 478 664 665 // check if a command with this name already exists 479 666 if (ConsoleCommand::getCommand(group, name) != 0) 480 667 { … … 486 673 else 487 674 { 675 // add the command to the map 488 676 ConsoleCommand::getCommandMap()[group][name] = command; 489 677 ConsoleCommand::getCommandMapLC()[getLowercase(group)][getLowercase(name)] = command; … … 491 679 } 492 680 681 /** 682 @brief Removes the command from the command map. 683 */ 493 684 /* static */ void ConsoleCommand::unregisterCommand(ConsoleCommand* command) 494 685 { 686 // iterate through all groups 495 687 for (std::map<std::string, std::map<std::string, ConsoleCommand*> >::iterator it_group = ConsoleCommand::getCommandMap().begin(); it_group != ConsoleCommand::getCommandMap().end(); ) 496 688 { 689 // iterate through all commands of each group 497 690 for (std::map<std::string, ConsoleCommand*>::iterator it_name = it_group->second.begin(); it_name != it_group->second.end(); ) 498 691 { 692 // erase the command 499 693 if (it_name->second == command) 500 694 it_group->second.erase(it_name++); … … 503 697 } 504 698 699 // erase the group if it is empty now 505 700 if (it_group->second.empty()) 506 701 ConsoleCommand::getCommandMap().erase(it_group++); … … 509 704 } 510 705 706 // now the same for the lowercase-map: 707 708 // iterate through all groups 511 709 for (std::map<std::string, std::map<std::string, ConsoleCommand*> >::iterator it_group = ConsoleCommand::getCommandMapLC().begin(); it_group != ConsoleCommand::getCommandMapLC().end(); ) 512 710 { 711 // iterate through all commands of each group 513 712 for (std::map<std::string, ConsoleCommand*>::iterator it_name = it_group->second.begin(); it_name != it_group->second.end(); ) 514 713 { 714 // erase the command 515 715 if (it_name->second == command) 516 716 it_group->second.erase(it_name++); … … 519 719 } 520 720 721 // erase the group if it is empty now 521 722 if (it_group->second.empty()) 522 723 ConsoleCommand::getCommandMapLC().erase(it_group++); … … 526 727 } 527 728 729 /** 730 @brief Deletes all commands 731 */ 528 732 /* static */ void ConsoleCommand::destroyAll() 529 733 { 734 // delete entries until the map is empty 530 735 while (!ConsoleCommand::getCommandMap().empty() && !ConsoleCommand::getCommandMap().begin()->second.empty()) 531 736 delete ConsoleCommand::getCommandMap().begin()->second.begin()->second; -
code/trunk/src/libraries/core/command/ConsoleCommand.h
r7284 r7401 27 27 */ 28 28 29 /** 30 @defgroup ConsoleCommand Console commands 31 @ingroup Command 32 */ 33 34 /** 35 @file 36 @ingroup Command ConsoleCommand 37 @brief Declaration of the orxonox::ConsoleCommand class and the SetConsoleCommand() macro. 38 39 @anchor ConsoleCommandExample 40 41 Console commands can be used to write scripts, use key-bindings or simply to be 42 entered into the shell by the user. Instances of orxonox::ConsoleCommand define 43 the function of a command, and also more information like, for example, if it is 44 active, default values, and possible arguments. 45 46 Commands need to be registered to the system statically on startup by using the 47 SetConsoleCommand() or DeclareConsoleCommand() macros outside of a function. 48 This ensures that commands are known to the system at any time, so they can be 49 evaluated (see orxonox::CommandExecutor::evaluate()), for example for key-bindings. 50 51 Example: 52 @code 53 void myCoutFunction(const std::string& text) // Define a static function 54 { 55 COUT(0) << "Text: " << text << std::endl; // Print the text to the console 56 } 57 58 SetConsoleCommand("cout", &myCoutFunction); // Register the function as command with name "cout" 59 @endcode 60 61 Now you can open the shell and execute the command: 62 @code 63 $ cout Hello World 64 @endcode 65 66 Internally this command is now passed to orxonox::CommandExecutor::execute(): 67 @code 68 CommandExecutor::execute("cout HelloWorld"); 69 @endcode 70 71 CommandExecutor searches for a command with name "cout" and passes the arguments 72 "Hello World" to it. Because we registered myCoutFunction() with this command, 73 as a result the following text will be printed to the console: 74 @code 75 Text: Hello World 76 @endcode 77 78 You can add more attributes to the ConsoleCommand, by using the command-chain feature 79 of SetConsoleCommand(). For example like this: 80 @code 81 SetConsoleCommand("cout", &myCoutFunction) 82 .addGroup("output", "text") 83 .accessLevel(AccessLevel::Offline) 84 .defaultValues("no text"); 85 @endcode 86 87 Open the shell again and try it: 88 @code 89 $ cout Hello World 90 Text: Hello World 91 $ output text Hello World 92 Text: Hello World 93 $ cout 94 Text: no text 95 @endcode 96 97 If you execute it online (note: the access level is "Offline"), you will see the 98 following (or something similar): 99 @code 100 $ cout Hello World 101 Error: Can't execute command "cout", access denied. 102 @endcode 103 104 If a command is executed, the arguments are passed to an underlying function, 105 whitch is wrapped by an orxonox::Functor which again is wrapped by an orxonox::Executor. 106 The Functor contains the function-pointer, as well as the object-pointer in 107 case of a non-static member-function. The executor stores possible default-values 108 for each argument of the function. 109 110 The function of a command can be changed at any time. It's possible to just exchange 111 the function-pointer of the underlying Functor if the headers of the functions are 112 exactly the same. But you can also exchange the Functor itself or even completely 113 replace the Executor. Also the other attributes of a ConsoleCommand can be modified 114 during the game, for example it can be activated or deactivated. 115 116 To do so, the function ModifyConsoleCommand() has to be used. It returns an instance 117 of orxonox::ConsoleCommand::ConsoleCommandManipulator which has an interface similar to 118 orxonox::ConsoleCommand, but with slight differences. You can use it the same way like 119 SetConsoleCommand(), meaning you can use command-chains to change different attributes at 120 the same time. ModifyConsoleCommand() must not be executed statically, but rather in a 121 function at some point of the execution of the program. 122 123 Example: 124 @code 125 void myOtherCoutFunction(const std::string& text) // Define a new static function 126 { 127 COUT(0) << "Uppercase: " << getUppercase(text) << std::endl; // Print the text in uppercase to the console 128 } 129 130 { 131 // ... // somewhere in the code 132 133 ModifyConsoleCommand("cout").setFunction(&myOtherCoutFunction); // Modify the underlying function of the command 134 135 // ... 136 } 137 @endcode 138 139 If you now enter the command into the shell, you'll see a different behavior: 140 @code 141 $ cout Hello World 142 Uppercase: HELLO WORLD 143 $ cout 144 Uppercase: NO TEXT 145 @endcode 146 147 A few important notes about changing functions: 148 149 Instead of changing the function with setFunction(), you can also create a command-stack 150 by using pushFunction() and popFunction(). It's important to note a few things about that, 151 because the underlying structure of Executor and Functor has a few pitfalls: 152 - If you push a new function-pointer, the same executor as before will be used (and, if 153 the headers match, even the same functor can be used, which is very fast) 154 - If you push a new Functor, the same executor as before will be used 155 - If you push a new Executor, everything is changed 156 157 Note that the executor contains the @b default @b values, so if you just exchange the 158 Functor, the default values remain the same. However if you decide to change the default 159 values at any point of the stack, <b>this will also change the default values on all 160 other stack-levels</b> that share the same executor. If you don't like this behavior, 161 you have to explicitly push a new executor before changing the default values, either by 162 calling pushFunction(executor) or by calling pushFunction(void) which pushes a copy of 163 the current executor to the stack. 164 165 Another important point are object pointers in case of non-static member-functions. 166 Whenever you set or push a new function, <b>you must add the object pointer again</b> 167 because objects are stored in the Functor which is usually exchanged if you change 168 the function. 169 170 You can also use a stack for objects, but note that this <b>object-stack is different for each 171 function</b> - so if you set a new function, the object-stack will be cleared. If you push 172 a new function, the old object-stack is stored in the stack, so it can be restored if 173 you pop the function. 174 175 %DeclareConsoleCommand(): 176 177 Appart from SetConsoleCommand() you can also call DeclareConsoleCommand(). In contrast 178 to SetConsoleCommand(), this doesn't assign a function to the command. Indeed you have 179 to pass a function-pointer to DeclareConsoleCommand(), but it is only used to determine 180 the header of the future command-function. This allows to declare a command statically, 181 thus it's possible to evaluate key-bindings of this command, but the actual function 182 can be assigned at a later point. 183 184 Example: 185 @code 186 DeclareConsoleCommand("cout", &prototype::void__string); 187 @endcode 188 189 If you try to execute the command now, you see the following (or something similar): 190 @code 191 $ cout Hello World 192 Error: Can't execute command "cout", command is not active. 193 @endcode 194 195 You first have to assign a function to use the command: 196 @code 197 { 198 // ... 199 200 ModifyConsoleCommand("cout").setFunction(&myCoutFunction); 201 202 // ... 203 } 204 @endcode 205 206 Now you can use it: 207 @code 208 $ cout Hello World 209 Text: Hello World 210 @endcode 211 212 Note that the initial function prototype::void__string is defined in the namespace 213 orxonox::prototype. If there's no function with the desired header, you can extend 214 the collection of functions or simply use another function that has the same header. 215 */ 216 29 217 #ifndef _ConsoleCommand_H__ 30 218 #define _ConsoleCommand_H__ … … 42 230 43 231 232 /** 233 @brief Defines a console command. The macro is overloaded for 2-4 parameters. 234 235 This is an overloaded macro. Depending on the number of arguments a different 236 overloaded implementation of the macro will be chosen. 237 238 Console commands created with SetConsoleCommand() become active immediately and 239 the given function-pointer (and optionally the object) will be used to execute 240 the command. 241 */ 44 242 #define SetConsoleCommand(...) \ 45 243 BOOST_PP_EXPAND(BOOST_PP_CAT(SetConsoleCommand, ORXONOX_VA_NARGS(__VA_ARGS__))(__VA_ARGS__)) 244 /** 245 @brief This macro is executed if you call SetConsoleCommand() with 2 arguments. 246 @param name The name (string) of the console command 247 @param functionpointer The function-pointer of the corresponding command-function 248 */ 46 249 #define SetConsoleCommand2(name, functionpointer) \ 47 250 SetConsoleCommandGeneric("", name, orxonox::createFunctor(functionpointer)) 251 /** 252 @brief This macro is executed if you call SetConsoleCommand() with 3 arguments. 253 @param group The group (string) of the console command 254 @param name The name (string) of the console command 255 @param functionpointer The function-pointer of the corresponding command-function 256 */ 48 257 #define SetConsoleCommand3(group, name, functionpointer) \ 49 258 SetConsoleCommandGeneric(group, name, orxonox::createFunctor(functionpointer)) 259 /** 260 @brief This macro is executed if you call SetConsoleCommand() with 4 arguments. 261 @param group The group (string) of the console command 262 @param name The name (string) of the console command 263 @param functionpointer The function-pointer of the corresponding command-function 264 @param object The object that will be assigned to the command. Used for member-functions. 265 */ 50 266 #define SetConsoleCommand4(group, name, functionpointer, object) \ 51 267 SetConsoleCommandGeneric(group, name, orxonox::createFunctor(functionpointer, object)) 52 268 269 /// Internal macro 53 270 #define SetConsoleCommandGeneric(group, name, functor) \ 54 271 static orxonox::ConsoleCommand& BOOST_PP_CAT(__consolecommand_, __LINE__) = (*orxonox::createConsoleCommand(group, name, orxonox::createExecutor(functor))) 55 272 56 273 274 /** 275 @brief Declares a console command. The macro is overloaded for 2-3 parameters. 276 277 This is an overloaded macro. Depending on the number of arguments a different 278 overloaded implementation of the macro will be chosen. 279 280 Console commands created with DeclareConsoleCommand() don't use the the given 281 function-pointer to execute the command, it is only used to define the header 282 of the future command-function. The command is inactive until you manually 283 set a function with orxonox::ModifyConsoleCommand(). You can use a different 284 function-pointer than in the final command, as long as it has the same header. 285 */ 57 286 #define DeclareConsoleCommand(...) \ 58 287 BOOST_PP_EXPAND(BOOST_PP_CAT(DeclareConsoleCommand, ORXONOX_VA_NARGS(__VA_ARGS__))(__VA_ARGS__)) 288 /** 289 @brief This macro is executed if you call DeclareConsoleCommand() with 2 arguments. 290 @param name The name (string) of the console command 291 @param functionpointer The function-pointer of an arbitrary function that has the same header as the final function 292 */ 59 293 #define DeclareConsoleCommand2(name, functionpointer) \ 60 294 DeclareConsoleCommandGeneric("", name, orxonox::createFunctor(functionpointer)) 295 /** 296 @brief This macro is executed if you call DeclareConsoleCommand() with 3 arguments. 297 @param group The group (string) of the console command 298 @param name The name (string) of the console command 299 @param functionpointer The function-pointer of an arbitrary function that has the same header as the final function 300 */ 61 301 #define DeclareConsoleCommand3(group, name, functionpointer) \ 62 302 DeclareConsoleCommandGeneric(group, name, orxonox::createFunctor(functionpointer)) 63 #define DeclareConsoleCommand4(group, name, functionpointer, object) \ 64 DeclareConsoleCommandGeneric(group, name, orxonox::createFunctor(functionpointer, object)) 65 303 304 /// Internal macro 66 305 #define DeclareConsoleCommandGeneric(group, name, functor) \ 67 306 static orxonox::ConsoleCommand& BOOST_PP_CAT(__consolecommand_, __LINE__) = (*orxonox::createConsoleCommand(group, name, orxonox::createExecutor(functor), false)) … … 70 309 namespace orxonox 71 310 { 311 /** 312 @brief A small collection of functions that can be used in DeclareConsoleCommand() if 313 you don't want to use the real function-pointer. 314 */ 72 315 namespace prototype 73 316 { … … 78 321 namespace AccessLevel 79 322 { 323 /** 324 @brief Possible access levels: A command can only be executed if the program is in the state which is requested by the access level. 325 */ 80 326 enum Enum 81 327 { … … 91 337 } 92 338 339 /** 340 @brief The ConsoleCommand class stores all information about a console command which can be executed by CommandExecutor. 341 342 Console commands can be entered by the user into the shell, called in scripts, or 343 used for key-bindings. They are simple text strings that can be executed by 344 CommandExecutor. CommandExecutor will search for a ConsoleCommand with the given 345 group and name and will execute it's Executor (which again calls the Functor and 346 this finally calls the command-function). 347 348 @see See @ref ConsoleCommandExample "ConsoleCommand.h" for more information and some examples. 349 */ 93 350 class _CoreExport ConsoleCommand 94 351 { 95 352 friend struct ConsoleCommandManipulator; 96 353 354 /** 355 @brief Helper class that is used to put the current state of the ConsoleCommand on a stack. 356 */ 97 357 struct Command 98 358 { 99 ExecutorPtr executor_; 100 FunctorPtr functor_; 101 std::vector<void*> objectStack_; 359 ExecutorPtr executor_; ///< The executor 360 FunctorPtr functor_; ///< The function that is used with the executor - has to be stored separatley because the executor is often used with different functors 361 std::vector<void*> objectStack_; ///< The object stack 102 362 }; 103 363 104 364 public: 365 /** 366 @brief Helper class that is used to manipulate console commands. 367 368 An instance of this class is returned if you call the ModifyConsoleCommand macro. 369 This class provides an interface which wraps some functions of ConsoleCommand. It 370 allows access to some private functions like setFunction() (that can't be called 371 right after SetConsoleCommand()) but it also hides some functions that shouln't be 372 called after the static declaration like addShortcut() or description(). 373 374 @see See @ref ConsoleCommandExample "ConsoleCommand.h" for more information and examples. 375 */ 105 376 struct ConsoleCommandManipulator 106 377 { 107 378 public: 379 /// Constructor: Creates a manipulator for a given ConsoleCommand. 108 380 ConsoleCommandManipulator(const ConsoleCommand* command) : command_(const_cast<ConsoleCommand*>(command)) {} 109 381 382 /// Changes the current function of the command. @param function The new function-pointer @param bForce If true, the new function-pointer is always assigned, even if the headers don't match 110 383 template <class F> 111 384 inline ConsoleCommandManipulator& setFunction(F function, bool bForce = false) … … 113 386 if (this->command_) 114 387 { 388 // check if the headers match. If they do, only change the function-pointer of the current Functor instead of creating a new Functor 115 389 if (this->command_->getExecutor() && this->command_->getExecutor()->getFunctor() && this->command_->getExecutor()->getFunctor()->getFullIdentifier() == typeid(F)) 116 390 { … … 123 397 return *this; 124 398 } 399 /// Changes the current function of the command. @param function The new function-pointer @param object The new object-pointer (for member-functions) @param bForce If true, the new function-pointer is always assigned, even if the headers don't match 125 400 template <class F, class O> 126 401 inline ConsoleCommandManipulator& setFunction(F function, O* object, bool bForce = false) … … 128 403 if (this->command_) 129 404 { 405 // check if the headers match. If they do, only change the function-pointer of the current Functor instead of creating a new Functor 130 406 if (this->command_->getExecutor() && this->command_->getExecutor()->getFunctor() && this->command_->getExecutor()->getFunctor()->getFullIdentifier() == typeid(F)) 131 407 { … … 139 415 return *this; 140 416 } 417 /// Changes the current Functor of the command. @param functor The new Functor @param bForce If true, the new Functor is always assigned, even if the headers don't match 141 418 inline ConsoleCommandManipulator& setFunction(const FunctorPtr& functor, bool bForce = false) 142 419 { if (this->command_) { this->command_->setFunction(functor, bForce); } return *this; } 420 /// Changes the current Executor of the command. @param executor The new Executor @param bForce If true, the new Executor is always assigned, even if the headers don't match 143 421 inline ConsoleCommandManipulator& setFunction(const ExecutorPtr& executor, bool bForce = false) 144 422 { if (this->command_) { this->command_->setFunction(executor, bForce); } return *this; } 145 423 424 /// Pushes a copy of the current Executor on the command-stack, that can be altered without changing the old Executor. @details This function is especially useful if you don't wan't to change the function, but only the default values of the executor. 146 425 inline ConsoleCommandManipulator& pushFunction() 147 426 { if (this->command_) { this->command_->pushFunction(); } return *this; } 427 /// Pushes a new function on the command-stack. @param function The new function-pointer @param bForce If true, the new function-pointer is always assigned, even if the headers don't match 148 428 template <class F> 149 429 inline ConsoleCommandManipulator& pushFunction(F function, bool bForce = false) 150 430 { if (this->command_) { this->command_->pushFunction(createFunctor(function), bForce); } return *this; } 431 /// Pushes a new function on the command-stack. @param function The new function-pointer @param object The new object-pointer (for member-functions) @param bForce If true, the new function-pointer is always assigned, even if the headers don't match 151 432 template <class F, class O> 152 433 inline ConsoleCommandManipulator& pushFunction(F function, O* object, bool bForce = false) 153 434 { if (this->command_) { this->command_->pushFunction(createFunctor(function, object), bForce); } return *this; } 435 /// Pushes a new Functor on the command-stack. @param functor The new Functor @param bForce If true, the new Functor is always assigned, even if the headers don't match 154 436 inline ConsoleCommandManipulator& pushFunction(const FunctorPtr& functor, bool bForce = false) 155 437 { if (this->command_) { this->command_->pushFunction(functor, bForce); } return *this; } 438 /// Pushes a new Executor on the command-stack. @param executor The new Executor @param bForce If true, the new Executor is always assigned, even if the headers don't match 156 439 inline ConsoleCommandManipulator& pushFunction(const ExecutorPtr& executor, bool bForce = false) 157 440 { if (this->command_) { this->command_->pushFunction(executor, bForce); } return *this; } 158 441 442 /// Removes the current function from the stack and restores the old state. If there's no other function on the stack, the command is deactivated. 159 443 inline ConsoleCommandManipulator& popFunction() 160 444 { if (this->command_) { this->command_->popFunction(); } return *this; } 161 445 446 /// Sets the current function-pointer to NULL, which also deactivates the command. 162 447 inline ConsoleCommandManipulator& resetFunction() 163 448 { if (this->command_) { this->command_->resetFunction(); } return *this; } 164 449 450 /// Changes the current object (used for member-functions). 165 451 inline ConsoleCommandManipulator& setObject(void* object) 166 452 { if (this->command_) { this->command_->setObject(object); } return *this; } 453 /// Pushes a new object on the object-stack. 167 454 inline ConsoleCommandManipulator& pushObject(void* object) 168 455 { if (this->command_) { this->command_->pushObject(object); } return *this; } 456 /// Removes the current object from the object-stack and restores the old object (or NULL if there's no object left on the stack). 169 457 inline ConsoleCommandManipulator& popObject() 170 458 { if (this->command_) { this->command_->popObject(); } return *this; } 171 459 460 /// Changes the activity of the command. 172 461 inline ConsoleCommandManipulator& setActive(bool bActive) 173 462 { if (this->command_) { this->command_->setActive(bActive); } return *this; } 463 /// Activates the command. 174 464 inline ConsoleCommandManipulator& activate() 175 465 { return this->setActive(true); } 466 /// Deactivates the command. 176 467 inline ConsoleCommandManipulator& deactivate() 177 468 { return this->setActive(false); } 178 469 470 /// Changes the visibility of the command. 179 471 inline ConsoleCommandManipulator& setHidden(bool bHidden) 180 472 { if (this->command_) { this->command_->setHidden(bHidden); } return *this; } 473 /// Hides the command (can still be executed, but is not visible in the list of available commands). 181 474 inline ConsoleCommandManipulator& hide() 182 475 { return this->setHidden(true); } 476 /// Makes the command visible. 183 477 inline ConsoleCommandManipulator& show() 184 478 { return this->setHidden(false); } 185 479 186 inline ConsoleCommandManipulator& defaultValues(const MultiType& param1) 187 { if (this->command_) { this->command_->defaultValues(param1); } return *this; } 188 inline ConsoleCommandManipulator& defaultValues(const MultiType& param1, const MultiType& param2) 189 { if (this->command_) { this->command_->defaultValues(param1, param2); } return *this; } 190 inline ConsoleCommandManipulator& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3) 191 { if (this->command_) { this->command_->defaultValues(param1, param2, param3); } return *this; } 192 inline ConsoleCommandManipulator& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4) 193 { if (this->command_) { this->command_->defaultValues(param1, param2, param3, param4); } return *this; } 194 inline ConsoleCommandManipulator& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) 195 { if (this->command_) { this->command_->defaultValues(param1, param2, param3, param4, param5); } return *this; } 196 inline ConsoleCommandManipulator& defaultValue(unsigned int index, const MultiType& param) 197 { if (this->command_) { this->command_->defaultValue(index, param); } return *this; } 198 480 /// Changes the default values of the current executor (doesn't modify executors on deeper levels of the command-stack). 481 inline ConsoleCommandManipulator& defaultValues(const MultiType& arg1) 482 { if (this->command_) { this->command_->defaultValues(arg1); } return *this; } 483 /// Changes the default values of the current executor (doesn't modify executors on deeper levels of the command-stack). 484 inline ConsoleCommandManipulator& defaultValues(const MultiType& arg1, const MultiType& arg2) 485 { if (this->command_) { this->command_->defaultValues(arg1, arg2); } return *this; } 486 /// Changes the default values of the current executor (doesn't modify executors on deeper levels of the command-stack). 487 inline ConsoleCommandManipulator& defaultValues(const MultiType& arg1, const MultiType& arg2, const MultiType& arg3) 488 { if (this->command_) { this->command_->defaultValues(arg1, arg2, arg3); } return *this; } 489 /// Changes the default values of the current executor (doesn't modify executors on deeper levels of the command-stack). 490 inline ConsoleCommandManipulator& defaultValues(const MultiType& arg1, const MultiType& arg2, const MultiType& arg3, const MultiType& arg4) 491 { if (this->command_) { this->command_->defaultValues(arg1, arg2, arg3, arg4); } return *this; } 492 /// Changes the default values of the current executor (doesn't modify executors on deeper levels of the command-stack). 493 inline ConsoleCommandManipulator& defaultValues(const MultiType& arg1, const MultiType& arg2, const MultiType& arg3, const MultiType& arg4, const MultiType& arg5) 494 { if (this->command_) { this->command_->defaultValues(arg1, arg2, arg3, arg4, arg5); } return *this; } 495 /// Changes the default value of the argument with given index of the current executor (doesn't modify executors on deeper levels of the command-stack). 496 inline ConsoleCommandManipulator& defaultValue(unsigned int index, const MultiType& arg) 497 { if (this->command_) { this->command_->defaultValue(index, arg); } return *this; } 498 499 /// Changes the access level of the command. 199 500 inline ConsoleCommandManipulator& accessLevel(AccessLevel::Enum level) 200 501 { if (this->command_) { this->command_->accessLevel(level); } return *this; } 201 502 202 inline ConsoleCommandManipulator& argumentCompleter(unsigned int param, ArgumentCompleter* completer) 203 { if (this->command_) { this->command_->argumentCompleter(param, completer); } return *this; } 204 503 /// Changes the argument completer for the given parameter. 504 inline ConsoleCommandManipulator& argumentCompleter(unsigned int index, ArgumentCompleter* completer) 505 { if (this->command_) { this->command_->argumentCompleter(index, completer); } return *this; } 506 507 /// Defines the command to be an input command. 205 508 inline ConsoleCommandManipulator& setAsInputCommand() 206 509 { if (this->command_) { this->command_->setAsInputCommand(); } return *this; } 510 /// Changes the keybind mode of the command. 207 511 inline ConsoleCommandManipulator& keybindMode(KeybindMode::Value mode) 208 512 { if (this->command_) { this->command_->keybindMode(mode); } return *this; } 513 /// Sets the input configured param to the given index. 209 514 inline ConsoleCommandManipulator& inputConfiguredParam(int index) 210 515 { if (this->command_) { this->command_->inputConfiguredParam(index); } return *this; } 211 516 212 517 private: 213 ConsoleCommand* command_; 518 ConsoleCommand* command_; ///< The command which is being manipulated by this object 214 519 }; 215 520 … … 223 528 ConsoleCommand& addGroup(const std::string& group, const std::string& name); 224 529 530 /// Returns the name that was first used for this command. 225 531 inline const std::string& getName() const 226 532 { return this->baseName_; } 227 533 228 534 const ExecutorPtr& getExecutor() const; 535 /// Returns the functor that defines the required header for this command (but isn't necessarily executed). 229 536 inline const FunctorPtr& getBaseFunctor() const 230 537 { return this->baseFunctor_; } 231 538 539 /// Changes the activity of the command. 232 540 inline ConsoleCommand& setActive(bool bActive) 233 541 { this->bActive_ = bActive; return *this; } 542 /// Activates the command. 234 543 inline ConsoleCommand& activate() 235 544 { return this->setActive(true); } 545 /// Deactivates the command. 236 546 inline ConsoleCommand& deactivate() 237 547 { return this->setActive(false); } 238 548 549 /// Changes the visibility of the command. 239 550 inline ConsoleCommand& setHidden(bool bHidden) 240 551 { this->bHidden_ = bHidden; return *this; } 552 /// Hides the command (can still be executed, but is not visible in the list of available commands). 241 553 inline ConsoleCommand& hide() 242 554 { return this->setHidden(true); } 555 /// Makes the command visible. 243 556 inline ConsoleCommand& show() 244 557 { return this->setHidden(false); } … … 246 559 bool isActive() const; 247 560 bool hasAccess() const; 561 /// Returns true if the command is currently hidden. 248 562 inline bool isHidden() const 249 563 { return this->bHidden_; } … … 252 566 const std::string& getDescription() const; 253 567 254 ConsoleCommand& descriptionParam(unsigned int param, const std::string& description);255 const std::string& getDescriptionParam(unsigned int param) const;568 ConsoleCommand& descriptionParam(unsigned int index, const std::string& description); 569 const std::string& getDescriptionParam(unsigned int index) const; 256 570 257 571 ConsoleCommand& descriptionReturnvalue(const std::string& description); 258 const std::string& getDescriptionReturnvalue(int param) const; 259 260 ConsoleCommand& defaultValues(const MultiType& param1); 261 ConsoleCommand& defaultValues(const MultiType& param1, const MultiType& param2); 262 ConsoleCommand& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3); 263 ConsoleCommand& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4); 264 ConsoleCommand& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5); 265 ConsoleCommand& defaultValue(unsigned int index, const MultiType& param); 266 572 const std::string& getDescriptionReturnvalue(int index) const; 573 574 ConsoleCommand& defaultValues(const MultiType& arg1); 575 ConsoleCommand& defaultValues(const MultiType& arg1, const MultiType& arg2); 576 ConsoleCommand& defaultValues(const MultiType& arg1, const MultiType& arg2, const MultiType& arg3); 577 ConsoleCommand& defaultValues(const MultiType& arg1, const MultiType& arg2, const MultiType& arg3, const MultiType& arg4); 578 ConsoleCommand& defaultValues(const MultiType& arg1, const MultiType& arg2, const MultiType& arg3, const MultiType& arg4, const MultiType& arg5); 579 ConsoleCommand& defaultValue(unsigned int index, const MultiType& arg); 580 581 /// Changes the access level of the command. 267 582 inline ConsoleCommand& accessLevel(AccessLevel::Enum level) 268 583 { this->accessLevel_ = level; return *this; } 584 /// Returns the access level of the command. 269 585 inline AccessLevel::Enum getAccessLevel() const 270 586 { return this->accessLevel_; } 271 587 272 ConsoleCommand& argumentCompleter(unsigned int param, ArgumentCompleter* completer); 273 ArgumentCompleter* getArgumentCompleter(unsigned int param) const; 274 588 ConsoleCommand& argumentCompleter(unsigned int index, ArgumentCompleter* completer); 589 ArgumentCompleter* getArgumentCompleter(unsigned int index) const; 590 591 /// Defines the command to be an input command 275 592 inline ConsoleCommand& setAsInputCommand() 276 593 { … … 281 598 } 282 599 600 /// Changes the keybind mode. 283 601 inline ConsoleCommand& keybindMode(KeybindMode::Value mode) 284 602 { this->keybindMode_ = mode; return *this; } 603 /// Returns the keybind mode 285 604 inline KeybindMode::Value getKeybindMode() const 286 605 { return this->keybindMode_; } 287 606 607 /// Changes the input configured param to the given index. 288 608 inline ConsoleCommand& inputConfiguredParam(int index) 289 609 { this->inputConfiguredParam_ = index; return *this; } 610 /// Returns the input configured param. 290 611 inline int getInputConfiguredParam_() const 291 612 { return this->inputConfiguredParam_; } 292 613 614 /// Returns a manipulator for this command. 293 615 inline ConsoleCommandManipulator getManipulator() const 294 616 { return this; } … … 311 633 void* getObject() const; 312 634 313 bool bActive_; 314 bool bHidden_; 315 AccessLevel::Enum accessLevel_; 316 std::string baseName_; 317 FunctorPtr baseFunctor_; 318 319 ExecutorPtr executor_; 320 std::stack<Command> commandStack_; 321 std::vector<void*> objectStack_; 322 323 ArgumentCompleter* argumentCompleter_[ 5];324 325 KeybindMode::Value keybindMode_; 326 int inputConfiguredParam_; 327 328 LanguageEntryLabel description_; 329 LanguageEntryLabel descriptionReturnvalue_; 330 LanguageEntryLabel descriptionParam_[MAX_FUNCTOR_ARGUMENTS]; 635 bool bActive_; ///< True if the command should be active (it can still be inactive, for example if the function is missing) 636 bool bHidden_; ///< True if the command is hidden (it is still executable, but not visible in the list of available commands) 637 AccessLevel::Enum accessLevel_; ///< The access level (the state of the game in which you can access the command) 638 std::string baseName_; ///< The name that was first assigned to the command 639 FunctorPtr baseFunctor_; ///< The functor that defines the header of the command-function 640 641 ExecutorPtr executor_; ///< The Executor that is used to execute the command 642 std::stack<Command> commandStack_; ///< A stack of commands, used to push and pop different functions 643 std::vector<void*> objectStack_; ///< A stack of objects, used to push and pop different objects for a function 644 645 ArgumentCompleter* argumentCompleter_[MAX_FUNCTOR_ARGUMENTS]; ///< ArgumentCompleter for each argument 646 647 KeybindMode::Value keybindMode_; ///< The keybind mode 648 int inputConfiguredParam_; ///< The input configured param 649 650 LanguageEntryLabel description_; ///< The description of the command 651 LanguageEntryLabel descriptionReturnvalue_; ///< A description of the return-value 652 LanguageEntryLabel descriptionParam_[MAX_FUNCTOR_ARGUMENTS]; ///< A description for each argument 331 653 332 654 public: 655 /// Returns the map with all groups and commands. 333 656 static inline const std::map<std::string, std::map<std::string, ConsoleCommand*> >& getCommands() 334 657 { return ConsoleCommand::getCommandMap(); } 658 /// Returns the map with all groups and commands in lowercase. 335 659 static inline const std::map<std::string, std::map<std::string, ConsoleCommand*> >& getCommandsLC() 336 660 { return ConsoleCommand::getCommandMapLC(); } 337 661 662 /// Returns a command (shortcut) with given name. @param name The name of the command shortcut @param bPrintError If true, an error is printed if the command doesn't exist 338 663 static inline const ConsoleCommand* getCommand(const std::string& name, bool bPrintError = false) 339 664 { return ConsoleCommand::getCommand("", name, bPrintError); } 665 /// Returns a command (shortcut) with given name in lowercase. @param name The lowercase name of the command shortcut @param bPrintError If true, an error is printed if the command doesn't exist 340 666 static inline const ConsoleCommand* getCommandLC(const std::string& name, bool bPrintError = false) 341 667 { return ConsoleCommand::getCommandLC("", name, bPrintError); } … … 354 680 }; 355 681 682 /** 683 @brief Creates a new ConsoleCommand. 684 @param name The name of the command 685 @param executor The executor of the command 686 @param bInitialized If true, the command is ready to be executed, otherwise it has to be activated first. 687 */ 356 688 inline ConsoleCommand* createConsoleCommand(const std::string& name, const ExecutorPtr& executor, bool bInitialized = true) 357 689 { return new ConsoleCommand("", name, executor, bInitialized); } 690 /** 691 @brief Creates a new ConsoleCommand. 692 @param group The group of the command 693 @param name The name of the command 694 @param executor The executor of the command 695 @param bInitialized If true, the command is ready to be executed, otherwise it has to be activated first. 696 */ 358 697 inline ConsoleCommand* createConsoleCommand(const std::string& group, const std::string& name, const ExecutorPtr& executor, bool bInitialized = true) 359 698 { return new ConsoleCommand(group, name, executor, bInitialized); } 360 699 700 701 /** 702 @brief Returns a manipulator for a command with the given name. 703 704 @note If the command doesn't exist, the manipulator contains a NULL pointer to the command, 705 but it can still be used without checks, because all functions of ConsoleCommandManipulator 706 check internally if the command exists. 707 */ 361 708 inline ConsoleCommand::ConsoleCommandManipulator ModifyConsoleCommand(const std::string& name) 362 709 { return ConsoleCommand::getCommand(name, true); } 710 /** 711 @brief Returns a manipulator for a command with the given group and name. 712 713 @note If the command doesn't exist, the manipulator contains a NULL pointer to the command, 714 but it can still be used without checks, because all functions of ConsoleCommandManipulator 715 check internally if the command exists. 716 */ 363 717 inline ConsoleCommand::ConsoleCommandManipulator ModifyConsoleCommand(const std::string& group, const std::string& name) 364 718 { return ConsoleCommand::getCommand(group, name, true); } -
code/trunk/src/libraries/core/command/ConsoleCommandCompilation.cc
r7284 r7401 26 26 * 27 27 */ 28 29 /** 30 @file 31 @brief Implementation of some console commands. 32 */ 28 33 29 34 #include "ConsoleCommandCompilation.h" … … 51 56 SetConsoleCommand("calculate", calculate); 52 57 58 /** 59 @brief Reads the content of a file and executes the commands in it line by line. 60 */ 53 61 void source(const std::string& filename) 54 62 { … … 86 94 } 87 95 96 /** 97 @brief Simply returns the arguments. 98 */ 88 99 std::string echo(const std::string& text) 89 100 { … … 91 102 } 92 103 104 /** 105 @brief Writes text to the console, depending on the first argument with or without a line-break after it. 106 */ 93 107 void puts(bool newline, const std::string& text) 94 108 { … … 103 117 } 104 118 119 /** 120 @brief Writes text to a file. 121 */ 105 122 void write(const std::string& filename, const std::string& text) 106 123 { … … 118 135 } 119 136 137 /** 138 @brief Appends text to a file. 139 */ 120 140 void append(const std::string& filename, const std::string& text) 121 141 { … … 133 153 } 134 154 155 /** 156 @brief Reads text from a file 157 */ 135 158 std::string read(const std::string& filename) 136 159 { … … 158 181 } 159 182 183 /** 184 @brief Parses the mathematical expression and returns the result. 185 */ 160 186 float calculate(const std::string& calculation) 161 187 { -
code/trunk/src/libraries/core/command/ConsoleCommandCompilation.h
r7284 r7401 27 27 */ 28 28 29 /** 30 @file 31 @ingroup Command ConsoleCommand 32 @brief Declaration of some console commands. 33 */ 34 29 35 #ifndef _ConsoleCommandCompilation_H__ 30 36 #define _ConsoleCommandCompilation_H__ -
code/trunk/src/libraries/core/command/Executor.cc
r7284 r7401 27 27 * Inspiration: Executor by Benjamin Grauer 28 28 */ 29 30 /** 31 @file 32 @brief Implementation of orxonox::Executor 33 */ 29 34 30 35 #include "Executor.h" … … 40 45 namespace orxonox 41 46 { 47 /** 48 @brief Constructor: Creates an executor. 49 @param functor The wrapped functor 50 @param name The name of the executor (optional, used mostly for debug output) 51 */ 42 52 Executor::Executor(const FunctorPtr& functor, const std::string& name) 43 53 { … … 46 56 } 47 57 58 /** 59 @brief Copy-constructor: Creates a new executor with the same values and a clone of the wrapped Functor. 60 */ 48 61 Executor::Executor(const Executor& other) : name_(other.name_) 49 62 { … … 53 66 } 54 67 68 /** 69 @brief Destructor 70 */ 55 71 Executor::~Executor() 56 72 { 57 73 } 58 74 75 /** 76 @brief Calls the wrapped function with arguments that are passed in a string. 77 @param arguments The arguments that should be passed to the function, separated by @a delimiter 78 @param error A pointer to a variable (or NULL) that is used to store the error code (see @ref CommandExecutorErrorCodes "CommandExecutor error codes") 79 @param delimiter The delimiter that is used to separate the arguments in the string @a arguments 80 @param bPrintError If true, errors are printed to the console if the function couldn't be executed with the given arguments 81 @return Returns the return value of the function (or MT_Type::Null if there is no return value) 82 */ 59 83 MultiType Executor::parse(const std::string& arguments, int* error, const std::string& delimiter, bool bPrintError) const 60 84 { … … 62 86 } 63 87 88 /** 89 @brief Calls the wrapped function with arguments that are passed as tokens in a SubString 90 @param arguments The arguments that should be passed to the function 91 @param error A pointer to a variable (or NULL) that is used to store the error code (see @ref CommandExecutorErrorCodes "CommandExecutor error codes") 92 @param delimiter The delimiter that was used to separate the arguments in the SubString @a arguments (used to join the surplus arguments) 93 @param bPrintError If true, errors are printed to the console if the function couldn't be executed with the given arguments 94 @return Returns the return value of the function (or MT_Type::Null if there is no return value) 95 */ 64 96 MultiType Executor::parse(const SubString& arguments, int* error, const std::string& delimiter, bool bPrintError) const 65 97 { 66 MultiType param[MAX_FUNCTOR_ARGUMENTS]; 67 unsigned int paramCount = this->evaluateParams(arguments, param, error, delimiter); 68 98 // evaluate the arguments 99 MultiType arg[MAX_FUNCTOR_ARGUMENTS]; 100 unsigned int argCount = this->evaluateArguments(arguments, arg, error, delimiter); 101 102 // check if an error occurred 69 103 if (error && *error) 70 104 { 71 105 if (bPrintError) 72 COUT(2) << "Warning: Can't call executor " << this->name_ << " through parser: Not enough parameters or default values given (input: " << arguments.join() << ")." << std::endl;106 COUT(2) << "Warning: Can't call executor " << this->name_ << " through parser: Not enough arguments or default values given (input: " << arguments.join() << ")." << std::endl; 73 107 return MT_Type::Null; 74 108 } 75 109 76 COUT(5) << "Executor::parse: \"" << arguments.join(delimiter) << "\" -> " << paramCount << " params: " << param[0] << " / " << param[1] << " / " << param[2] << " / " << param[3] << " / " << param[4] << std::endl; 77 78 switch (paramCount) 110 COUT(5) << "Executor::parse: \"" << arguments.join(delimiter) << "\" -> " << argCount << " arguments: " << arg[0] << " / " << arg[1] << " / " << arg[2] << " / " << arg[3] << " / " << arg[4] << std::endl; 111 112 // execute the function with the evaluated arguments (the default values of the executor are also included in these arguments) 113 switch (argCount) 79 114 { 80 115 case 0: return (*this->functor_)(); 81 case 1: return (*this->functor_)( param[0]);82 case 2: return (*this->functor_)( param[0], param[1]);83 case 3: return (*this->functor_)( param[0], param[1], param[2]);84 case 4: return (*this->functor_)( param[0], param[1], param[2], param[3]);116 case 1: return (*this->functor_)(arg[0]); 117 case 2: return (*this->functor_)(arg[0], arg[1]); 118 case 3: return (*this->functor_)(arg[0], arg[1], arg[2]); 119 case 4: return (*this->functor_)(arg[0], arg[1], arg[2], arg[3]); 85 120 case 5: 86 default: return (*this->functor_)( param[0], param[1], param[2], param[3], param[4]);121 default: return (*this->functor_)(arg[0], arg[1], arg[2], arg[3], arg[4]); 87 122 } 88 123 } 89 124 90 int Executor::evaluateParams(const SubString& arguments, MultiType param[MAX_FUNCTOR_ARGUMENTS], int* error, const std::string& delimiter) const 125 /** 126 @brief Converts the arguments in a SubString to the right type, so they can be used to execute the function without further conversions. 127 @param arguments The arguments that should be converted 128 @param arg An array of MultiType where the converted arguments will be stored 129 @param error A pointer to a variable (or NULL) that is used to store the error code (see @ref CommandExecutorErrorCodes "CommandExecutor error codes") 130 @param delimiter The delimiter that was used to separate the arguments in the SubString @a arguments (used to join the surplus arguments) 131 @return Returns the number of evaluated arguments 132 */ 133 int Executor::evaluateArguments(const SubString& arguments, MultiType arg[MAX_FUNCTOR_ARGUMENTS], int* error, const std::string& delimiter) const 91 134 { 92 135 unsigned int paramCount = this->functor_->getParamCount(); … … 106 149 // assign all given arguments to the multitypes 107 150 for (unsigned int i = 0; i < std::min(std::min(argumentCount, paramCount), MAX_FUNCTOR_ARGUMENTS); i++) 108 param[i] = arguments[i];151 arg[i] = arguments[i]; 109 152 110 153 // fill the remaining multitypes with default values 111 154 for (unsigned int i = argumentCount; i < std::min(paramCount, MAX_FUNCTOR_ARGUMENTS); i++) 112 param[i] = this->defaultValue_[i];155 arg[i] = this->defaultValue_[i]; 113 156 114 157 // assign the remaining arguments all to the last parameter if it is a string 115 158 if ((paramCount <= MAX_FUNCTOR_ARGUMENTS) &&(argumentCount > paramCount) && (paramCount == 1 || this->functor_->getTypenameParam(paramCount - 1) == "string")) 116 param[paramCount - 1] = arguments.subSet(paramCount - 1).join(delimiter);117 118 // evaluate the param types through the functor159 arg[paramCount - 1] = arguments.subSet(paramCount - 1).join(delimiter); 160 161 // evaluate the parameter types through the functor 119 162 for (unsigned int i = 0; i < std::min(paramCount, MAX_FUNCTOR_ARGUMENTS); i++) 120 this->functor_->evaluate Param(i, param[i]);163 this->functor_->evaluateArgument(i, arg[i]); 121 164 122 165 if (error) … … 125 168 } 126 169 127 void Executor::setDefaultValues(const MultiType& param1) 128 { 129 this->defaultValue_[0] = param1; 130 } 131 132 void Executor::setDefaultValues(const MultiType& param1, const MultiType& param2) 133 { 134 this->defaultValue_[0] = param1; 135 this->defaultValue_[1] = param2; 136 } 137 138 void Executor::setDefaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3) 139 { 140 this->defaultValue_[0] = param1; 141 this->defaultValue_[1] = param2; 142 this->defaultValue_[2] = param3; 143 } 144 145 void Executor::setDefaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4) 146 { 147 this->defaultValue_[0] = param1; 148 this->defaultValue_[1] = param2; 149 this->defaultValue_[2] = param3; 150 this->defaultValue_[3] = param4; 151 } 152 153 void Executor::setDefaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) 154 { 155 this->defaultValue_[0] = param1; 156 this->defaultValue_[1] = param2; 157 this->defaultValue_[2] = param3; 158 this->defaultValue_[3] = param4; 159 this->defaultValue_[4] = param5; 160 } 161 162 void Executor::setDefaultValue(unsigned int index, const MultiType& param) 170 /// Defines the default value for the first parameter. 171 void Executor::setDefaultValues(const MultiType& arg1) 172 { 173 this->defaultValue_[0] = arg1; 174 } 175 176 /// Defines the default value for the first two parameters. 177 void Executor::setDefaultValues(const MultiType& arg1, const MultiType& arg2) 178 { 179 this->defaultValue_[0] = arg1; 180 this->defaultValue_[1] = arg2; 181 } 182 183 /// Defines the default value for the first three parameters. 184 void Executor::setDefaultValues(const MultiType& arg1, const MultiType& arg2, const MultiType& arg3) 185 { 186 this->defaultValue_[0] = arg1; 187 this->defaultValue_[1] = arg2; 188 this->defaultValue_[2] = arg3; 189 } 190 191 /// Defines the default value for the first four parameters. 192 void Executor::setDefaultValues(const MultiType& arg1, const MultiType& arg2, const MultiType& arg3, const MultiType& arg4) 193 { 194 this->defaultValue_[0] = arg1; 195 this->defaultValue_[1] = arg2; 196 this->defaultValue_[2] = arg3; 197 this->defaultValue_[3] = arg4; 198 } 199 200 /// Defines the default value for the first five parameters. 201 void Executor::setDefaultValues(const MultiType& arg1, const MultiType& arg2, const MultiType& arg3, const MultiType& arg4, const MultiType& arg5) 202 { 203 this->defaultValue_[0] = arg1; 204 this->defaultValue_[1] = arg2; 205 this->defaultValue_[2] = arg3; 206 this->defaultValue_[3] = arg4; 207 this->defaultValue_[4] = arg5; 208 } 209 210 /// Defines the default value for a parameter with given index (the first parameter has index 0). 211 void Executor::setDefaultValue(unsigned int index, const MultiType& arg) 163 212 { 164 213 if (index < MAX_FUNCTOR_ARGUMENTS) 165 this->defaultValue_[index] = param; 166 } 167 214 this->defaultValue_[index] = arg; 215 } 216 217 /// Returns true if the executor has a default value for each parameter of the wrapped function, so it can be called without passing additional arguments. 168 218 bool Executor::allDefaultValuesSet() const 169 219 { -
code/trunk/src/libraries/core/command/Executor.h
r7284 r7401 28 28 */ 29 29 30 /** 31 @defgroup FunctorExecutor Functor and Executor 32 @ingroup Command 33 */ 34 35 /** 36 @file 37 @ingroup Command FunctorExecutor 38 @brief Declaration of the orxonox::Executor class and the createExecutor() functions. 39 40 @anchor ExecutorExample 41 42 orxonox::Executor is used to wrap an orxonox::Functor and to store default values for 43 its parameters. Usually one uses the function createExecutor() to create a new executor. 44 This function returns an orxonox::ExecutorPtr which is a typedef of @ref orxonox::SharedPtr 45 "SharedPtr<Executor>", used to manage the pointer to the executor. 46 47 Executors are mostly used to execute callbacks. Because some callback functions need arguments, 48 Executor provides an easy interface to store these arguments as default values, so the 49 executor can also be executed without arguments because it will use these default values. 50 51 The Executor doesn't contain the function-pointer directly. Instead it wraps an instance 52 of orxonox::Functor. See @ref FunctorExample "Functor.h" for more information and some 53 examples. 54 55 Example: 56 @code 57 void myFunction(int a, int b) // declare a static function 58 { 59 COUT(0) << "The sum is " << (a + b) << std::endl; // print the sum of a and b to the console 60 } 61 62 FunctorPtr functor = createFunctor(&myFunction); // create a functor that wraps the function-pointer 63 ExecutorPtr executor = createExecutor(functor); // create an executor that wraps the functor 64 65 (*executor)(2, 5); // calls the executor with arguments 2 and 5, prints "The sum is 7" to the console 66 67 executor->setDefaultValue(1, 10); // sets the default-value for the second parameter (note: paramters start at index 0) to 10 68 69 (*executor)(2); // calls the executor with argument 2 and default-value 10, prints "The sum is 12" 70 71 executor->setDefaultValue(0, 5); // sets the default-value for the first parameter to 5 72 73 (*executor)(); // calls the executor with default-values only, prints "The sum is 15" 74 @endcode 75 76 Because executors that were created with createExecutor() are managed by an orxonox::SharedPtr, 77 they don't need to be deleted after usage. 78 */ 79 30 80 #ifndef _Executor_H__ 31 81 #define _Executor_H__ … … 40 90 namespace orxonox 41 91 { 92 /** 93 @brief This class is used to wrap a Functor and to store default values for any of its parameters. 94 95 @see See @ref ExecutorExample "Executor.h" for an example. 96 */ 42 97 class _CoreExport Executor 43 98 { … … 47 102 virtual ~Executor(); 48 103 104 /// Calls the wrapped function with 0 arguments. If the function needs more arguments, the executor's default values are used. 49 105 inline MultiType operator()() const 50 106 { return (*this->functor_)(this->defaultValue_[0], this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); } 51 inline MultiType operator()(const MultiType& param1) const 52 { return (*this->functor_)(param1, this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); } 53 inline MultiType operator()(const MultiType& param1, const MultiType& param2) const 54 { return (*this->functor_)(param1, param2, this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); } 55 inline MultiType operator()(const MultiType& param1, const MultiType& param2, const MultiType& param3) const 56 { return (*this->functor_)(param1, param2, param3, this->defaultValue_[3], this->defaultValue_[4]); } 57 inline MultiType operator()(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4) const 58 { return (*this->functor_)(param1, param2, param3, param4, this->defaultValue_[4]); } 59 inline MultiType operator()(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) const 60 { return (*this->functor_)(param1, param2, param3, param4, param5); } 107 /// Calls the wrapped function with 1 argument. If the function needs more arguments, the executor's default values are used. 108 inline MultiType operator()(const MultiType& arg1) const 109 { return (*this->functor_)(arg1, this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); } 110 /// Calls the wrapped function with 2 arguments. If the function needs more arguments, the executor's default values are used. 111 inline MultiType operator()(const MultiType& arg1, const MultiType& arg2) const 112 { return (*this->functor_)(arg1, arg2, this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); } 113 /// Calls the wrapped function with 3 arguments. If the function needs more arguments, the executor's default values are used. 114 inline MultiType operator()(const MultiType& arg1, const MultiType& arg2, const MultiType& arg3) const 115 { return (*this->functor_)(arg1, arg2, arg3, this->defaultValue_[3], this->defaultValue_[4]); } 116 /// Calls the wrapped function with 4 arguments. If the function needs more arguments, the executor's default values are used. 117 inline MultiType operator()(const MultiType& arg1, const MultiType& arg2, const MultiType& arg3, const MultiType& arg4) const 118 { return (*this->functor_)(arg1, arg2, arg3, arg4, this->defaultValue_[4]); } 119 /// Calls the wrapped function with 5 arguments. If the function needs more arguments, the executor's default values are used. 120 inline MultiType operator()(const MultiType& arg1, const MultiType& arg2, const MultiType& arg3, const MultiType& arg4, const MultiType& arg5) const 121 { return (*this->functor_)(arg1, arg2, arg3, arg4, arg5); } 61 122 62 123 MultiType parse(const std::string& arguments, int* error = 0, const std::string& delimiter = " ", bool bPrintError = false) const; 63 124 MultiType parse(const SubString& arguments, int* error = 0, const std::string& delimiter = " ", bool bPrintError = false) const; 64 125 65 int evaluateParams(const SubString& arguments, MultiType param[MAX_FUNCTOR_ARGUMENTS], int* error = 0, const std::string& delimiter = " ") const; 66 126 int evaluateArguments(const SubString& arguments, MultiType arg[MAX_FUNCTOR_ARGUMENTS], int* error = 0, const std::string& delimiter = " ") const; 127 128 /// Changes the functor. 67 129 inline void setFunctor(const FunctorPtr& functor) 68 130 { this->functor_ = functor; } 131 /// Returns the functor. 69 132 inline const FunctorPtr& getFunctor() const 70 133 { return this->functor_; } 71 134 135 /// Changes the name of the executor. 72 136 inline void setName(const std::string& name) 73 137 { this->name_ = name; } 138 /// Returns the name of the executor. 74 139 inline const std::string& getName() const 75 140 { return this->name_; } 76 141 142 /// Returns the number of parameters of the wrapped function. 77 143 inline unsigned int getParamCount() const 78 144 { return this->functor_->getParamCount(); } 145 /// Returns true if the wrapped function returns a value. 79 146 inline bool hasReturnvalue() const 80 147 { return this->functor_->hasReturnvalue(); } 148 /// Returns the type of the wrapped function (static or member). 81 149 inline Functor::Type::Enum getType() const 82 150 { return this->functor_->getType(); } 151 /// Returns the name of the type of a parameter with given index (the first parameter has index 0). 83 152 inline std::string getTypenameParam(unsigned int param) const 84 153 { return this->functor_->getTypenameParam(param); } 154 /// Returns the name of the type of the return value. 85 155 inline std::string getTypenameReturnvalue() const 86 156 { return this->functor_->getTypenameReturnvalue(); } 87 157 88 void setDefaultValues(const MultiType& param1); 89 void setDefaultValues(const MultiType& param1, const MultiType& param2); 90 void setDefaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3); 91 void setDefaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4); 92 void setDefaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5); 93 void setDefaultValue(unsigned int index, const MultiType& param); 94 158 void setDefaultValues(const MultiType& arg1); 159 void setDefaultValues(const MultiType& arg1, const MultiType& arg2); 160 void setDefaultValues(const MultiType& arg1, const MultiType& arg2, const MultiType& arg3); 161 void setDefaultValues(const MultiType& arg1, const MultiType& arg2, const MultiType& arg3, const MultiType& arg4); 162 void setDefaultValues(const MultiType& arg1, const MultiType& arg2, const MultiType& arg3, const MultiType& arg4, const MultiType& arg5); 163 void setDefaultValue(unsigned int index, const MultiType& arg); 164 165 /// Returns the default value for a parameter with given index (the first parameter has index 0). 95 166 inline MultiType getDefaultValue(unsigned int index) const 96 167 { … … 102 173 103 174 bool allDefaultValuesSet() const; 175 176 /// Returns true if the executor contains a default value for the parameter with given index (the first parameter has index 0). 104 177 inline bool defaultValueSet(unsigned int index) const 105 178 { … … 111 184 112 185 protected: 113 FunctorPtr functor_; 114 std::string name_; 115 MultiType defaultValue_[MAX_FUNCTOR_ARGUMENTS]; 186 FunctorPtr functor_; ///< The underlying Functor that wraps a function 187 std::string name_; ///< The name of the executor 188 MultiType defaultValue_[MAX_FUNCTOR_ARGUMENTS]; ///< The default values, one for each parameter 116 189 }; 117 190 191 /** 192 @brief A child class of Executor, used to distinguish executors that wrap static functions from executors that wrap member-functions. 193 194 Behaves exactly like Executor, because static functions need no special treatment. 195 */ 118 196 class _CoreExport ExecutorStatic : public Executor 119 197 { 120 198 public: 199 /// Constructor: Initializes the parent class 121 200 ExecutorStatic(const FunctorStaticPtr& functor, const std::string& name = "") : Executor(functor, name) {} 201 /// Destructor 122 202 virtual ~ExecutorStatic() {} 123 203 }; 124 204 205 /** 206 @brief A child class of Executor, used for easier handling of non-static member-functions. 207 208 Overloads some functions that call the underlying FunctorMember and additionally pass 209 an object-pointer that is needed for non-static member-functions. 210 */ 125 211 template <class T> 126 212 class ExecutorMember : public Executor 127 213 { 128 214 public: 215 /// Constructor: Initializes the parent class and the pointer to the member-functor. 129 216 ExecutorMember(const FunctorMemberPtr<T>& functor, const std::string& name = "") : Executor(functor, name), functorMember_(functor) {} 217 /// Destructor 130 218 virtual ~ExecutorMember() {} 131 219 132 220 using Executor::operator(); 133 221 222 /// Calls the wrapped function with 0 arguments and an object-pointer. If the function needs more arguments, the executor's default values are used. 134 223 inline MultiType operator()(T* object) const 135 224 { return (*this->functorMember_)(object, this->defaultValue_[0], this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); } 136 inline MultiType operator()(T* object, const MultiType& param1) const 137 { return (*this->functorMember_)(object, param1, this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); } 138 inline MultiType operator()(T* object, const MultiType& param1, const MultiType& param2) const 139 { return (*this->functorMember_)(object, param1, param2, this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); } 140 inline MultiType operator()(T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3) const 141 { return (*this->functorMember_)(object, param1, param2, param3, this->defaultValue_[3], this->defaultValue_[4]); } 142 inline MultiType operator()(T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4) const 143 { return (*this->functorMember_)(object, param1, param2, param3, param4, this->defaultValue_[4]); } 144 inline MultiType operator()(T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) const 145 { return (*this->functorMember_)(object, param1, param2, param3, param4, param5); } 146 147 148 inline MultiType operator()(const T* object) const 149 { return (*this->functorMember_)(object, this->defaultValue_[0], this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); } 150 inline MultiType operator()(const T* object, const MultiType& param1) const 151 { return (*this->functorMember_)(object, param1, this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); } 152 inline MultiType operator()(const T* object, const MultiType& param1, const MultiType& param2) const 153 { return (*this->functorMember_)(object, param1, param2, this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); } 154 inline MultiType operator()(const T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3) const 155 { return (*this->functorMember_)(object, param1, param2, param3, this->defaultValue_[3], this->defaultValue_[4]); } 156 inline MultiType operator()(const T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4) const 157 { return (*this->functorMember_)(object, param1, param2, param3, param4, this->defaultValue_[4]); } 158 inline MultiType operator()(const T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) const 159 { return (*this->functorMember_)(object, param1, param2, param3, param4, param5); } 160 225 /// Calls the wrapped function with 1 argument and an object-pointer. If the function needs more arguments, the executor's default values are used. 226 inline MultiType operator()(T* object, const MultiType& arg1) const 227 { return (*this->functorMember_)(object, arg1, this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); } 228 /// Calls the wrapped function with 2 arguments and an object-pointer. If the function needs more arguments, the executor's default values are used. 229 inline MultiType operator()(T* object, const MultiType& arg1, const MultiType& arg2) const 230 { return (*this->functorMember_)(object, arg1, arg2, this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); } 231 /// Calls the wrapped function with 3 arguments and an object-pointer. If the function needs more arguments, the executor's default values are used. 232 inline MultiType operator()(T* object, const MultiType& arg1, const MultiType& arg2, const MultiType& arg3) const 233 { return (*this->functorMember_)(object, arg1, arg2, arg3, this->defaultValue_[3], this->defaultValue_[4]); } 234 /// Calls the wrapped function with 4 arguments and an object-pointer. If the function needs more arguments, the executor's default values are used. 235 inline MultiType operator()(T* object, const MultiType& arg1, const MultiType& arg2, const MultiType& arg3, const MultiType& arg4) const 236 { return (*this->functorMember_)(object, arg1, arg2, arg3, arg4, this->defaultValue_[4]); } 237 /// Calls the wrapped function with 5 arguments and an object-pointer. If the function needs more arguments, the executor's default values are used. 238 inline MultiType operator()(T* object, const MultiType& arg1, const MultiType& arg2, const MultiType& arg3, const MultiType& arg4, const MultiType& arg5) const 239 { return (*this->functorMember_)(object, arg1, arg2, arg3, arg4, arg5); } 240 241 /// Changes the object-pointer of the underlying FunctorMember. 161 242 inline void setObject(T* object) const 162 243 { this->functorMember_->setObject(object); } 163 inline void setObject(const T* object) const 164 { this->functorMember_->setObject(object); } 244 /// Returns the object-pointer of the underlying FunctorMember. 245 inline T* getObject() const 246 { return this->functorMember_->getObject(); } 165 247 166 248 using Executor::parse; 167 249 168 MultiType parse(T* object, const std::string& params, int* error = 0, const std::string& delimiter = " ", bool bPrintError = false) const 250 /// Overloads Executor::parse() with an additional object-pointer. 251 MultiType parse(T* object, const std::string& arguments, int* error = 0, const std::string& delimiter = " ", bool bPrintError = false) const 169 252 { 170 253 T* oldobject = this->functorMember_->getObject(); 171 254 172 255 this->functorMember_->setObject(object); 173 const MultiType& result = this->Executor::parse( params, error, delimiter, bPrintError);256 const MultiType& result = this->Executor::parse(arguments, error, delimiter, bPrintError); 174 257 this->functorMember_->setObject(oldobject); 175 258 … … 177 260 } 178 261 179 MultiType parse(const T* object, const std::string& params, int* error = 0, const std::string& delimiter = " ", bool bPrintError = false) const180 {181 T* oldobject = this->functorMember_->getObject();182 183 this->functorMember_->setObject(object);184 const MultiType& result = this->Executor::parse(params, error, delimiter, bPrintError);185 this->functorMember_->setObjects(oldobject);186 187 return result;188 }189 190 262 protected: 191 FunctorMemberPtr<T> functorMember_; 263 FunctorMemberPtr<T> functorMember_; ///< A pointer to the FunctorMember is stored separately to avoid casting when executing the function. 192 264 }; 193 265 266 /// Creates a new Executor that wraps a given Functor. 194 267 inline ExecutorPtr createExecutor(const FunctorPtr& functor, const std::string& name = "") 195 268 { … … 197 270 } 198 271 272 /// Creates a new ExecutorMember that wraps a given FunctorMember. 199 273 template <class T> 200 274 inline ExecutorMemberPtr<T> createExecutor(const FunctorMemberPtr<T>& functor, const std::string& name = "") … … 203 277 } 204 278 279 /// Creates a new ExecutorStatic that wraps a given FunctorStatic. 205 280 inline ExecutorStaticPtr createExecutor(const FunctorStaticPtr& functor, const std::string& name = "") 206 281 { -
code/trunk/src/libraries/core/command/ExecutorPtr.h
r7284 r7401 27 27 */ 28 28 29 /** 30 @file 31 @ingroup Command FunctorExecutor 32 @brief Typedefs and definitions of ExecutorPtr, ExecutorStaticPtr, and ExecutorMemberPtr 33 34 Instances of orxonox::Executor are usually managed by an orxonox::SharedPtr. This ensures 35 that Executors will be destroyed after usage. To make things easier, there's a typedef 36 that defines ExecutorPtr as SharedPtr<Executor>. 37 38 Because there's not only orxonox::Executor, but also orxonox::ExecutorStatic, and 39 orxonox::ExecutorMember, the shared pointers need to store them all and also reflect 40 their hierarchy - ExecutorStatic and ExecutorMember should not be mixed, but both can 41 be converted to Executor. This is achieved by using orxonox::SharedChildPtr. 42 43 Because it's not possible to use a typedef for a template, we have to define the 44 helper class ExecutorMemberPtr<T> that makes it easier to use ExecutorMember. 45 */ 46 29 47 #ifndef _ExecutorPtr_H__ 30 48 #define _ExecutorPtr_H__ … … 35 53 namespace orxonox 36 54 { 55 /// ExecutorPtr is just a typedef of SharedPtr 37 56 typedef SharedPtr<Executor> ExecutorPtr; 38 57 58 /// ExecutorStaticPtr is just a typedef of SharedChildPtr 39 59 typedef SharedChildPtr<ExecutorStatic, ExecutorPtr> ExecutorStaticPtr; 40 60 61 /// It's not possible to use a typedef for ExecutorMemberPtr<T>, so we have to create a child-class instead. It inherits all functions from SharedChildPtr, but needs to (re-)implement some constructors. 41 62 template <class T> 42 63 class ExecutorMemberPtr : public SharedChildPtr<ExecutorMember<T>, ExecutorPtr> -
code/trunk/src/libraries/core/command/Functor.h
r7284 r7401 27 27 */ 28 28 29 /** 30 @file 31 @ingroup Command FunctorExecutor 32 @brief Definition of orxonox::Functor and its specialized subclasses, as well as the createFunctor() functions. 33 34 @anchor FunctorExample 35 36 Functors can be used to wrap function-pointers. While function-pointers have a very 37 complicated syntax in C++, Functors are always the same and you can call the wrapped 38 function-pointer independently of its parameter with arguments of type MultiType. These 39 arguments are then automatically converted to the right type. 40 41 To create a Functor, the helper function createFunctor() is used. It returns an instance 42 of orxonox::FunctorPtr which is simply a typedef of @ref orxonox::SharedPtr "SharedPtr<Functor>". 43 This means you don't have to delete the Functor after using it, because it is managed 44 by the SharedPtr. 45 46 Example: 47 @code 48 int myStaticFunction(int value) // Definition of a static function 49 { 50 return (value * 2); // Return the double of the value 51 } 52 53 FunctorPtr functor = createFunctor(&myStaticFunction); // Create a Functor 54 55 int result = (*functor)(5); // Calls the functor with value = 5, result == 10 56 57 int result = (*functor)("7"); // Calls the functor with a string which is converted to an integer, result == 14 58 @endcode 59 60 Functors can also be used if you work with member-functions. In this case createFunctor() 61 returns an instance of orxonox::FunctorMemberPtr - this allows you to define the object 62 that will be used to call the function. 63 64 Example: 65 @code 66 class MyClass // Define a class 67 { 68 public: 69 MyClass(const std::string& text) // Constructor 70 { 71 this->text_ = text; 72 } 73 74 bool contains(const std::string& word) // Function that searches for "word" in "text" 75 { 76 return (this->text_.find(word) != std::string::npos); 77 } 78 79 private: 80 std::string text_; // Member variable 81 }; 82 83 MyClass* object = new MyClass("Hello World"); // Create an object of type MyClass and set its text to "Hello World" 84 85 FunctorPtr functor = createFunctor(&MyClass:contains, object); // Create a Functor (note the object!) 86 87 bool result = (*functor)("World"); // result == true 88 bool result = (*functor)("test"); // result == false 89 @endcode 90 91 Instead of assigning the object directly to the functor when creating it, you can also define 92 it at any later point or when you call the functor. Note however that this works only with 93 orxonox::FunctorMember. 94 95 @code 96 MyClass* object1 = new MyClass("Hello World"); // Create an object 97 MyClass* object2 = new MyClass("this is a test"); // Create another object 98 99 FunctorMemberPtr functor = createFunctor(&MyClass:contains); // Create a FunctorMember (note: no object this time) 100 101 bool result = (*functor)("World"); // result == false and an error: "Error: Can't execute FunctorMember, no object set." 102 103 bool result = (*functor)(object1, "World"); // result == true 104 bool result = (*functor)(object1, "test"); // result == false 105 bool result = (*functor)(object2, "test"); // result == true 106 107 functor->setObject(object1); // Assign an object to the FunctorMember 108 109 bool result = (*functor)("World"); // result == true (no error this time, because the object was set using setObject()) 110 @endcode 111 */ 112 29 113 #ifndef _Functor_H__ 30 114 #define _Functor_H__ … … 40 124 namespace orxonox 41 125 { 42 const unsigned int MAX_FUNCTOR_ARGUMENTS = 5; 43 126 const unsigned int MAX_FUNCTOR_ARGUMENTS = 5; ///< The maximum number of parameters of a function that is supported by Functor 127 128 namespace detail 129 { 130 template <class T> 131 inline std::string _typeToString() { return "unknown"; } 132 133 template <> inline std::string _typeToString<void>() { return "void"; } 134 template <> inline std::string _typeToString<int>() { return "int"; } 135 template <> inline std::string _typeToString<unsigned int>() { return "uint"; } 136 template <> inline std::string _typeToString<char>() { return "char"; } 137 template <> inline std::string _typeToString<unsigned char>() { return "uchar"; } 138 template <> inline std::string _typeToString<short>() { return "short"; } 139 template <> inline std::string _typeToString<unsigned short>() { return "ushort"; } 140 template <> inline std::string _typeToString<long>() { return "long"; } 141 template <> inline std::string _typeToString<unsigned long>() { return "ulong"; } 142 template <> inline std::string _typeToString<long long>() { return "longlong"; } 143 template <> inline std::string _typeToString<unsigned long long>() { return "ulonglong"; } 144 template <> inline std::string _typeToString<float>() { return "float"; } 145 template <> inline std::string _typeToString<double>() { return "double"; } 146 template <> inline std::string _typeToString<long double>() { return "longdouble"; } 147 template <> inline std::string _typeToString<bool>() { return "bool"; } 148 template <> inline std::string _typeToString<std::string>() { return "string"; } 149 template <> inline std::string _typeToString<Vector2>() { return "Vector2"; } 150 template <> inline std::string _typeToString<Vector3>() { return "Vector3"; } 151 template <> inline std::string _typeToString<Quaternion>() { return "Quaternion"; } 152 template <> inline std::string _typeToString<ColourValue>() { return "ColourValue"; } 153 template <> inline std::string _typeToString<Radian>() { return "Radian"; } 154 template <> inline std::string _typeToString<Degree>() { return "Degree"; } 155 } 156 157 /// Returns the name of type @a T as string. 44 158 template <class T> 45 inline std::string _typeToString() { return "unknown"; } 46 47 template <> inline std::string _typeToString<void>() { return ""; } 48 template <> inline std::string _typeToString<int>() { return "int"; } 49 template <> inline std::string _typeToString<unsigned int>() { return "uint"; } 50 template <> inline std::string _typeToString<char>() { return "char"; } 51 template <> inline std::string _typeToString<unsigned char>() { return "uchar"; } 52 template <> inline std::string _typeToString<short>() { return "short"; } 53 template <> inline std::string _typeToString<unsigned short>() { return "ushort"; } 54 template <> inline std::string _typeToString<long>() { return "long"; } 55 template <> inline std::string _typeToString<unsigned long>() { return "ulong"; } 56 template <> inline std::string _typeToString<long long>() { return "longlong"; } 57 template <> inline std::string _typeToString<unsigned long long>() { return "ulonglong"; } 58 template <> inline std::string _typeToString<float>() { return "float"; } 59 template <> inline std::string _typeToString<double>() { return "double"; } 60 template <> inline std::string _typeToString<long double>() { return "longdouble"; } 61 template <> inline std::string _typeToString<bool>() { return "bool"; } 62 template <> inline std::string _typeToString<std::string>() { return "string"; } 63 template <> inline std::string _typeToString<Vector2>() { return "Vector2"; } 64 template <> inline std::string _typeToString<Vector3>() { return "Vector3"; } 65 template <> inline std::string _typeToString<Quaternion>() { return "Quaternion"; } 66 template <> inline std::string _typeToString<ColourValue>() { return "ColourValue"; } 67 template <> inline std::string _typeToString<Radian>() { return "Radian"; } 68 template <> inline std::string _typeToString<Degree>() { return "Degree"; } 69 70 template <class T> 71 inline std::string typeToString() { return _typeToString<typename Loki::TypeTraits<T>::UnqualifiedReferredType>(); } 72 159 inline std::string typeToString() { return detail::_typeToString<typename Loki::TypeTraits<T>::UnqualifiedReferredType>(); } 160 161 /** 162 @brief The Functor classes are used to wrap function pointers. 163 164 Function-pointers in C++ have a pretty complicated syntax and you can't store 165 and call them unless you know the exact type. A Functor can be used to wrap 166 a function-pointer and to store it independent of its type. You can also call 167 it independently of its parameters by passing the arguments as MultiType. They 168 are converted automatically to the right type. 169 170 Functor is a pure virtual base class. 171 172 @see See @ref FunctorExample "Functor.h" for some examples. 173 */ 73 174 class _CoreExport Functor 74 175 { … … 76 177 struct Type 77 178 { 179 /// Defines the type of a function (static or member) 78 180 enum Enum 79 181 { … … 84 186 85 187 public: 188 /// Calls the function-pointer with up to five arguments. In case of a member-function, the assigned object-pointer is used to call the function. @return Returns the return-value of the function (if any; MT_Type::Null otherwise) 86 189 virtual MultiType operator()(const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null) = 0; 87 190 191 /// Creates a new instance of Functor with the same values like this (used instead of a copy-constructor) 88 192 virtual FunctorPtr clone() = 0; 89 193 194 /// Returns the type of the function: static or member. 90 195 virtual Type::Enum getType() const = 0; 196 /// Returns the number of parameters of the function. 91 197 virtual unsigned int getParamCount() const = 0; 198 /// Returns true if the function has a return-value. 92 199 virtual bool hasReturnvalue() const = 0; 93 200 94 virtual std::string getTypenameParam(unsigned int param) const = 0; 201 /// Returns the type-name of the parameter with given index (the first parameter has index 0). 202 virtual std::string getTypenameParam(unsigned int index) const = 0; 203 /// Returns the type-name of the return-value. 95 204 virtual std::string getTypenameReturnvalue() const = 0; 96 205 97 virtual void evaluateParam(unsigned int index, MultiType& param) const = 0; 98 99 virtual void setRawObjectPointer(void* object) {} 100 virtual void* getRawObjectPointer() const { return 0; } 101 102 template <class F> 103 inline bool setFunction(F* function) 104 { 105 if (this->getFullIdentifier() == typeid(F*)) 106 { 107 modifyFunctor(this, function); 108 return true; 109 } 110 return false; 111 } 112 206 /// Converts a given argument to the type of the parameter with given index (the first parameter has index 0). 207 virtual void evaluateArgument(unsigned int index, MultiType& argument) const = 0; 208 209 /// Assigns an object-pointer to the functor which is used to execute a member-function. 210 virtual void setRawObjectPointer(void* object) = 0; 211 /// Returns the object-pointer. 212 virtual void* getRawObjectPointer() const = 0; 213 214 /// Returns the full identifier of the function-pointer which is defined as typeid(@a F), where @a F is the type of the stored function-pointer. Used to compare functors. 113 215 virtual const std::type_info& getFullIdentifier() const = 0; 216 /// Returns an identifier of the header of the function (doesn't include the function's class). Used to compare functors. 114 217 virtual const std::type_info& getHeaderIdentifier() const = 0; 218 /// Returns an identifier of the header of the function (doesn't include the function's class), but regards only the first @a params parameters. Used to compare functions if an Executor provides default-values for the other parameters. 115 219 virtual const std::type_info& getHeaderIdentifier(unsigned int params) const = 0; 116 220 }; … … 118 222 namespace detail 119 223 { 224 // helper class to determine if a functor is static or not 120 225 template <class O> 121 226 struct FunctorTypeStatic … … 126 231 } 127 232 233 /** 234 @brief FunctorMember is a child class of Functor and expands it with an object-pointer, that 235 is used for member-functions, as well as an overloaded execution operator. 236 237 @param O The type of the function's class (or void if it's a static function) 238 239 Note that FunctorMember is also used for static functions, but with T = void. FunctorStatic 240 is a typedef of FunctorMember<void>. The void* object-pointer is ignored in this case. 241 242 @see See @ref FunctorExample "Functor.h" for some examples. 243 */ 128 244 template <class O> 129 245 class FunctorMember : public Functor 130 246 { 131 247 public: 248 /// Constructor: Stores the object-pointer. 132 249 FunctorMember(O* object = 0) : object_(object) {} 133 250 251 /// Calls the function-pointer with up to five arguments and an object. In case of a static-function, the object can be NULL. @return Returns the return-value of the function (if any; MT_Type::Null otherwise) 134 252 virtual MultiType operator()(O* object, const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null) = 0; 135 253 254 // see Functor::operator()() 136 255 MultiType operator()(const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null) 137 256 { 257 // call the function if it is static or if an object was assigned 138 258 if (detail::FunctorTypeStatic<O>::result || this->object_) 139 259 return (*this)(this->object_, param1, param2, param3, param4, param5); … … 145 265 } 146 266 267 // see Functor::getType() 147 268 Functor::Type::Enum getType() const 148 269 { return detail::FunctorTypeStatic<O>::result ? Functor::Type::Static : Functor::Type::Member; } 149 270 271 /// Assigns an object-pointer to the functor which is used to execute a member-function. 150 272 inline void setObject(O* object) 151 273 { this->object_ = object;} 274 /// Returns the object-pointer. 152 275 inline O* getObject() const 153 276 { return this->object_; } 154 277 278 // see Functor::setRawObjectPointer() 155 279 inline void setRawObjectPointer(void* object) 156 280 { this->object_ = (O*)object; } 281 // see Functor::getRawObjectPointer() 157 282 inline void* getRawObjectPointer() const 158 283 { return this->object_; } 159 284 160 285 protected: 161 O* object_; 286 O* object_; ///< The stored object-pointer, used to execute a member-function (or NULL for static functions) 162 287 }; 163 288 289 /// FunctorStatic is just a typedef of FunctorMember with @a T = void. 164 290 typedef FunctorMember<void> FunctorStatic; 165 291 292 /** 293 @brief FunctorPointer is a child class of FunctorMember and expands it with a function-pointer. 294 @param F The type of the function-pointer 295 @param O The type of the function's class (or void if it's a static function) 296 297 The template FunctorPointer has an additional template parameter that defines the type 298 of the function-pointer. This can be handy if you want to get or set the function-pointer. 299 You can then use a static_cast to cast a Functor to FunctorPointer if you know the type 300 of the function-pointer. 301 302 However FunctorPointer is not aware of the types of the different parameters or the 303 return value. 304 */ 166 305 template <class F, class O = void> 167 306 class FunctorPointer : public FunctorMember<O> 168 307 { 169 308 public: 309 /// Constructor: Initializes the base class and stores the function-pointer. 170 310 FunctorPointer(F functionPointer, O* object = 0) : FunctorMember<O>(object), functionPointer_(functionPointer) {} 171 311 312 /// Changes the function-pointer. 172 313 inline void setFunction(F functionPointer) 173 314 { this->functionPointer_ = functionPointer; } 315 /// Returns the function-pointer. 174 316 inline F getFunction() const 175 317 { return this->functionPointer_; } 176 318 319 // see Functor::getFullIdentifier() 177 320 const std::type_info& getFullIdentifier() const 178 321 { return typeid(F); } 179 322 180 323 protected: 181 F functionPointer_; 324 F functionPointer_; ///< The stored function-pointer 182 325 }; 183 326 184 327 namespace detail 185 328 { 329 // Helper class to get the type of the function pointer with the given class, parameters, return-value, and constness 186 330 template <class R, class O, bool isconst, class P1, class P2, class P3, class P4, class P5> struct FunctionPointer { typedef R (O::*Type)(P1, P2, P3, P4, P5); }; 187 331 template <class R, class O, class P1, class P2, class P3, class P4, class P5> struct FunctionPointer<R, O, false, P1, P2, P3, P4, P5> { typedef R (O::*Type)(P1, P2, P3, P4, P5); }; … … 204 348 template <class R> struct FunctionPointer<R, void, false, void, void, void, void, void> { typedef R (*Type)(); }; 205 349 350 // Helper class, used to call a function-pointer with a given object and parameters and to return its return-value (if available) 206 351 template <class R, class O, bool isconst, class P1, class P2, class P3, class P4, class P5> struct FunctorCaller { static inline MultiType call(typename detail::FunctionPointer<R, O, isconst, P1, P2, P3, P4, P5>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { return (object->*functionPointer)(param1, param2, param3, param4, param5); } }; 207 352 template <class R, class O, bool isconst, class P1, class P2, class P3, class P4> struct FunctorCaller<R, O, isconst, P1, P2, P3, P4, void> { static inline MultiType call(typename detail::FunctionPointer<R, O, isconst, P1, P2, P3, P4, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { return (object->*functionPointer)(param1, param2, param3, param4); } }; … … 229 374 template <bool isconst> struct FunctorCaller<void, void, isconst, void, void, void, void, void> { static inline MultiType call(typename detail::FunctionPointer<void, void, isconst, void, void, void, void, void>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { (*functionPointer)(); return MT_Type::Null; } }; 230 375 376 // Helper class, used to identify the header of a function-pointer (independent of its class) 231 377 template <class R, class P1, class P2, class P3, class P4, class P5> 232 378 struct FunctorHeaderIdentifier 233 379 {}; 234 380 381 // Helper class to determine if a function has a returnvalue 235 382 template <class T> 236 383 struct FunctorHasReturnvalue … … 240 387 { enum { result = false }; }; 241 388 389 // Helper class to count the number of parameters 242 390 template <class P1, class P2, class P3, class P4, class P5> 243 391 struct FunctorParamCount … … 260 408 } 261 409 410 /** 411 @brief FunctorTemplate is a child class of FunctorPointer and implements all functions 412 that need to know the exact types of the parameters, return-value, and class. 413 414 @param R The type of the return-value of the function 415 @param O The class of the function 416 @param isconst True if the function is a const member-function 417 @param P1 The type of the first parameter 418 @param P2 The type of the second parameter 419 @param P3 The type of the third parameter 420 @param P4 The type of the fourth parameter 421 @param P5 The type of the fifth parameter 422 423 This template has many parameters and is usually not used directly. It is created by 424 createFunctor(), but only the base-classes Functor, FunctorMember, and FunctorPointer 425 are used directly. It implements all the virtual functions that are declared by its 426 base classes. 427 428 All template arguments can be void. 429 */ 262 430 template <class R, class O, bool isconst, class P1, class P2, class P3, class P4, class P5> 263 431 class FunctorTemplate : public FunctorPointer<typename detail::FunctionPointer<R, O, isconst, P1, P2, P3, P4, P5>::Type, O> 264 432 { 265 433 public: 434 /// Constructor: Initializes the base class. 266 435 FunctorTemplate(typename detail::FunctionPointer<R, O, isconst, P1, P2, P3, P4, P5>::Type functionPointer, O* object = 0) : FunctorPointer<typename detail::FunctionPointer<R, O, isconst, P1, P2, P3, P4, P5>::Type, O>(functionPointer, object) {} 267 436 437 // see FunctorMember::operator()() 268 438 MultiType operator()(O* object, const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null) 269 439 { … … 271 441 } 272 442 443 // see Functor::clone() 273 444 FunctorPtr clone() 274 445 { … … 276 447 } 277 448 278 void evaluateParam(unsigned int index, MultiType& param) const 449 // see Functor::evaluateArgument() 450 void evaluateArgument(unsigned int index, MultiType& argument) const 279 451 { 280 452 switch (index) 281 453 { 282 case 0: param.convert<P1>(); break;283 case 1: param.convert<P2>(); break;284 case 2: param.convert<P3>(); break;285 case 3: param.convert<P4>(); break;286 case 4: param.convert<P5>(); break;454 case 0: argument.convert<P1>(); break; 455 case 1: argument.convert<P2>(); break; 456 case 2: argument.convert<P3>(); break; 457 case 3: argument.convert<P4>(); break; 458 case 4: argument.convert<P5>(); break; 287 459 } 288 460 } 289 461 462 // see Functor::getParamCount() 290 463 unsigned int getParamCount() const 291 464 { … … 293 466 } 294 467 468 // see Functor::hasReturnvalue() 295 469 bool hasReturnvalue() const 296 470 { … … 298 472 } 299 473 300 std::string getTypenameParam(unsigned int param) const 301 { 302 switch (param) 474 // see Functor::getTypenameParam() 475 std::string getTypenameParam(unsigned int index) const 476 { 477 switch (index) 303 478 { 304 479 case 0: return typeToString<P1>(); … … 311 486 } 312 487 488 // see Functor::getTypenameReturnvalue() 313 489 std::string getTypenameReturnvalue() const 314 490 { … … 316 492 } 317 493 494 // see Functor::getHeaderIdentifier() 318 495 const std::type_info& getHeaderIdentifier() const 319 496 { … … 321 498 } 322 499 500 // see Functor::getHeaderIdentifier(unsigned int) 323 501 const std::type_info& getHeaderIdentifier(unsigned int params) const 324 502 { … … 335 513 }; 336 514 337 template <class R, class O, class OO, class P1, class P2, class P3, class P4, class P5> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3, P4, P5), OO* object) { return new FunctorTemplate<R, O, false, P1, P2, P3, P4, P5>(functionPointer, object); } 338 template <class R, class O, class OO, class P1, class P2, class P3, class P4> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3, P4), OO* object) { return new FunctorTemplate<R, O, false, P1, P2, P3, P4, void>(functionPointer, object); } 339 template <class R, class O, class OO, class P1, class P2, class P3> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3), OO* object) { return new FunctorTemplate<R, O, false, P1, P2, P3, void, void>(functionPointer, object); } 340 template <class R, class O, class OO, class P1, class P2> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2), OO* object) { return new FunctorTemplate<R, O, false, P1, P2, void, void, void>(functionPointer, object); } 341 template <class R, class O, class OO, class P1> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1), OO* object) { return new FunctorTemplate<R, O, false, P1, void, void, void, void>(functionPointer, object); } 342 template <class R, class O, class OO> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(), OO* object) { return new FunctorTemplate<R, O, false, void, void, void, void, void>(functionPointer, object); } 343 template <class R, class O, class OO, class P1, class P2, class P3, class P4, class P5> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3, P4, P5) const, OO* object) { return new FunctorTemplate<R, O, true, P1, P2, P3, P4, P5>(functionPointer, object); } 344 template <class R, class O, class OO, class P1, class P2, class P3, class P4> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3, P4) const, OO* object) { return new FunctorTemplate<R, O, true, P1, P2, P3, P4, void>(functionPointer, object); } 345 template <class R, class O, class OO, class P1, class P2, class P3> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3) const, OO* object) { return new FunctorTemplate<R, O, true, P1, P2, P3, void, void>(functionPointer, object); } 346 template <class R, class O, class OO, class P1, class P2> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2) const, OO* object) { return new FunctorTemplate<R, O, true, P1, P2, void, void, void>(functionPointer, object); } 347 template <class R, class O, class OO, class P1> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1) const, OO* object) { return new FunctorTemplate<R, O, true, P1, void, void, void, void>(functionPointer, object); } 348 template <class R, class O, class OO> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)() const, OO* object) { return new FunctorTemplate<R, O, true, void, void, void, void, void>(functionPointer, object); } 349 350 template <class R, class O, class P1, class P2, class P3, class P4, class P5> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3, P4, P5)) { return new FunctorTemplate<R, O, false, P1, P2, P3, P4, P5>(functionPointer); } 351 template <class R, class O, class P1, class P2, class P3, class P4> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3, P4)) { return new FunctorTemplate<R, O, false, P1, P2, P3, P4, void>(functionPointer); } 352 template <class R, class O, class P1, class P2, class P3> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3)) { return new FunctorTemplate<R, O, false, P1, P2, P3, void, void>(functionPointer); } 353 template <class R, class O, class P1, class P2> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2)) { return new FunctorTemplate<R, O, false, P1, P2, void, void, void>(functionPointer); } 354 template <class R, class O, class P1> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1)) { return new FunctorTemplate<R, O, false, P1, void, void, void, void>(functionPointer); } 355 template <class R, class O> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)()) { return new FunctorTemplate<R, O, false, void, void, void, void, void>(functionPointer); } 356 template <class R, class O, class P1, class P2, class P3, class P4, class P5> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3, P4, P5) const) { return new FunctorTemplate<R, O, true, P1, P2, P3, P4, P5>(functionPointer); } 357 template <class R, class O, class P1, class P2, class P3, class P4> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3, P4) const) { return new FunctorTemplate<R, O, true, P1, P2, P3, P4, void>(functionPointer); } 358 template <class R, class O, class P1, class P2, class P3> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3) const) { return new FunctorTemplate<R, O, true, P1, P2, P3, void, void>(functionPointer); } 359 template <class R, class O, class P1, class P2> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2) const) { return new FunctorTemplate<R, O, true, P1, P2, void, void, void>(functionPointer); } 360 template <class R, class O, class P1> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1) const) { return new FunctorTemplate<R, O, true, P1, void, void, void, void>(functionPointer); } 361 template <class R, class O> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)() const) { return new FunctorTemplate<R, O, true, void, void, void, void, void>(functionPointer); } 362 363 template <class R, class P1, class P2, class P3, class P4, class P5> inline FunctorStaticPtr createFunctor(R (*functionPointer)(P1, P2, P3, P4, P5)) { return new FunctorTemplate<R, void, false, P1, P2, P3, P4, P5>(functionPointer); } 364 template <class R, class P1, class P2, class P3, class P4> inline FunctorStaticPtr createFunctor(R (*functionPointer)(P1, P2, P3, P4)) { return new FunctorTemplate<R, void, false, P1, P2, P3, P4, void>(functionPointer); } 365 template <class R, class P1, class P2, class P3> inline FunctorStaticPtr createFunctor(R (*functionPointer)(P1, P2, P3)) { return new FunctorTemplate<R, void, false, P1, P2, P3, void, void>(functionPointer); } 366 template <class R, class P1, class P2> inline FunctorStaticPtr createFunctor(R (*functionPointer)(P1, P2)) { return new FunctorTemplate<R, void, false, P1, P2, void, void, void>(functionPointer); } 367 template <class R, class P1> inline FunctorStaticPtr createFunctor(R (*functionPointer)(P1)) { return new FunctorTemplate<R, void, false, P1, void, void, void, void>(functionPointer); } 368 template <class R> inline FunctorStaticPtr createFunctor(R (*functionPointer)()) { return new FunctorTemplate<R, void, false, void, void, void, void, void>(functionPointer); } 515 template <class R, class O, class OO, class P1, class P2, class P3, class P4, class P5> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3, P4, P5), OO* object) { return new FunctorTemplate<R, O, false, P1, P2, P3, P4, P5>(functionPointer, object); } ///< Creates a new FunctorMember with the given function-pointer and an assigned object 516 template <class R, class O, class OO, class P1, class P2, class P3, class P4> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3, P4), OO* object) { return new FunctorTemplate<R, O, false, P1, P2, P3, P4, void>(functionPointer, object); } ///< Creates a new FunctorMember with the given function-pointer and an assigned object 517 template <class R, class O, class OO, class P1, class P2, class P3> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3), OO* object) { return new FunctorTemplate<R, O, false, P1, P2, P3, void, void>(functionPointer, object); } ///< Creates a new FunctorMember with the given function-pointer and an assigned object 518 template <class R, class O, class OO, class P1, class P2> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2), OO* object) { return new FunctorTemplate<R, O, false, P1, P2, void, void, void>(functionPointer, object); } ///< Creates a new FunctorMember with the given function-pointer and an assigned object 519 template <class R, class O, class OO, class P1> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1), OO* object) { return new FunctorTemplate<R, O, false, P1, void, void, void, void>(functionPointer, object); } ///< Creates a new FunctorMember with the given function-pointer and an assigned object 520 template <class R, class O, class OO> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(), OO* object) { return new FunctorTemplate<R, O, false, void, void, void, void, void>(functionPointer, object); } ///< Creates a new FunctorMember with the given function-pointer and an assigned object 521 template <class R, class O, class OO, class P1, class P2, class P3, class P4, class P5> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3, P4, P5) const, OO* object) { return new FunctorTemplate<R, O, true, P1, P2, P3, P4, P5>(functionPointer, object); } ///< Creates a new FunctorMember with the given function-pointer and an assigned object 522 template <class R, class O, class OO, class P1, class P2, class P3, class P4> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3, P4) const, OO* object) { return new FunctorTemplate<R, O, true, P1, P2, P3, P4, void>(functionPointer, object); } ///< Creates a new FunctorMember with the given function-pointer and an assigned object 523 template <class R, class O, class OO, class P1, class P2, class P3> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3) const, OO* object) { return new FunctorTemplate<R, O, true, P1, P2, P3, void, void>(functionPointer, object); } ///< Creates a new FunctorMember with the given function-pointer and an assigned object 524 template <class R, class O, class OO, class P1, class P2> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2) const, OO* object) { return new FunctorTemplate<R, O, true, P1, P2, void, void, void>(functionPointer, object); } ///< Creates a new FunctorMember with the given function-pointer and an assigned object 525 template <class R, class O, class OO, class P1> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1) const, OO* object) { return new FunctorTemplate<R, O, true, P1, void, void, void, void>(functionPointer, object); } ///< Creates a new FunctorMember with the given function-pointer and an assigned object 526 template <class R, class O, class OO> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)() const, OO* object) { return new FunctorTemplate<R, O, true, void, void, void, void, void>(functionPointer, object); } ///< Creates a new FunctorMember with the given function-pointer and an assigned object 527 528 template <class R, class O, class P1, class P2, class P3, class P4, class P5> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3, P4, P5)) { return new FunctorTemplate<R, O, false, P1, P2, P3, P4, P5>(functionPointer); } ///< Creates a new FunctorMember with the given function-pointer 529 template <class R, class O, class P1, class P2, class P3, class P4> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3, P4)) { return new FunctorTemplate<R, O, false, P1, P2, P3, P4, void>(functionPointer); } ///< Creates a new FunctorMember with the given function-pointer 530 template <class R, class O, class P1, class P2, class P3> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3)) { return new FunctorTemplate<R, O, false, P1, P2, P3, void, void>(functionPointer); } ///< Creates a new FunctorMember with the given function-pointer 531 template <class R, class O, class P1, class P2> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2)) { return new FunctorTemplate<R, O, false, P1, P2, void, void, void>(functionPointer); } ///< Creates a new FunctorMember with the given function-pointer 532 template <class R, class O, class P1> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1)) { return new FunctorTemplate<R, O, false, P1, void, void, void, void>(functionPointer); } ///< Creates a new FunctorMember with the given function-pointer 533 template <class R, class O> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)()) { return new FunctorTemplate<R, O, false, void, void, void, void, void>(functionPointer); } ///< Creates a new FunctorMember with the given function-pointer 534 template <class R, class O, class P1, class P2, class P3, class P4, class P5> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3, P4, P5) const) { return new FunctorTemplate<R, O, true, P1, P2, P3, P4, P5>(functionPointer); } ///< Creates a new FunctorMember with the given function-pointer 535 template <class R, class O, class P1, class P2, class P3, class P4> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3, P4) const) { return new FunctorTemplate<R, O, true, P1, P2, P3, P4, void>(functionPointer); } ///< Creates a new FunctorMember with the given function-pointer 536 template <class R, class O, class P1, class P2, class P3> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3) const) { return new FunctorTemplate<R, O, true, P1, P2, P3, void, void>(functionPointer); } ///< Creates a new FunctorMember with the given function-pointer 537 template <class R, class O, class P1, class P2> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2) const) { return new FunctorTemplate<R, O, true, P1, P2, void, void, void>(functionPointer); } ///< Creates a new FunctorMember with the given function-pointer 538 template <class R, class O, class P1> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1) const) { return new FunctorTemplate<R, O, true, P1, void, void, void, void>(functionPointer); } ///< Creates a new FunctorMember with the given function-pointer 539 template <class R, class O> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)() const) { return new FunctorTemplate<R, O, true, void, void, void, void, void>(functionPointer); } ///< Creates a new FunctorMember with the given function-pointer 540 541 template <class R, class P1, class P2, class P3, class P4, class P5> inline FunctorStaticPtr createFunctor(R (*functionPointer)(P1, P2, P3, P4, P5)) { return new FunctorTemplate<R, void, false, P1, P2, P3, P4, P5>(functionPointer); } ///< Creates a new Functor with the given function-pointer 542 template <class R, class P1, class P2, class P3, class P4> inline FunctorStaticPtr createFunctor(R (*functionPointer)(P1, P2, P3, P4)) { return new FunctorTemplate<R, void, false, P1, P2, P3, P4, void>(functionPointer); } ///< Creates a new Functor with the given function-pointer 543 template <class R, class P1, class P2, class P3> inline FunctorStaticPtr createFunctor(R (*functionPointer)(P1, P2, P3)) { return new FunctorTemplate<R, void, false, P1, P2, P3, void, void>(functionPointer); } ///< Creates a new Functor with the given function-pointer 544 template <class R, class P1, class P2> inline FunctorStaticPtr createFunctor(R (*functionPointer)(P1, P2)) { return new FunctorTemplate<R, void, false, P1, P2, void, void, void>(functionPointer); } ///< Creates a new Functor with the given function-pointer 545 template <class R, class P1> inline FunctorStaticPtr createFunctor(R (*functionPointer)(P1)) { return new FunctorTemplate<R, void, false, P1, void, void, void, void>(functionPointer); } ///< Creates a new Functor with the given function-pointer 546 template <class R> inline FunctorStaticPtr createFunctor(R (*functionPointer)()) { return new FunctorTemplate<R, void, false, void, void, void, void, void>(functionPointer); } ///< Creates a new Functor with the given function-pointer 369 547 } 370 548 -
code/trunk/src/libraries/core/command/FunctorPtr.h
r7284 r7401 27 27 */ 28 28 29 /** 30 @file 31 @ingroup Command FunctorExecutor 32 @brief Typedefs and definitions of FunctorPtr, FunctorMemberPtr, FunctorStaticPtr, and FunctorPointerPtr 33 34 Instances of orxonox::Functor are usually managed by an orxonox::SharedPtr. This ensures 35 that Functors will be destroyed after usage. To make things easier, there's a typedef 36 that defines FunctorPtr as SharedPtr<Functor>. 37 38 Because there's not only orxonox::Functor, but also orxonox::FunctorStatic, and 39 orxonox::FunctorMember, the shared pointers need to store them all and also reflect 40 their hierarchy - FunctorStatic and FunctorMember should not be mixed, but both can 41 be converted to Functor. This is achieved by using orxonox::SharedChildPtr. 42 43 Because it's not possible to use a typedef for a template, we have to define the 44 helper class FunctorMemberPtr<T> that makes it easier to use FunctorMember. The 45 same is also done for FunctorPointerPtr<T>, which can be converted to both, 46 FunctorMemberPtr<T> as well as FunctorPtr. 47 */ 48 29 49 #ifndef _FunctorPtr_H__ 30 50 #define _FunctorPtr_H__ … … 35 55 namespace orxonox 36 56 { 57 /// FunctorPtr is just a typedef of SharedPtr 37 58 typedef SharedPtr<Functor> FunctorPtr; 38 59 60 /// It's not possible to use a typedef for FunctorMemberPtr<T>, so we have to create a child-class instead. It inherits all functions from SharedChildPtr, but needs to (re-)implement some constructors. 39 61 template <class T> 40 62 class FunctorMemberPtr : public SharedChildPtr<FunctorMember<T>, FunctorPtr> … … 46 68 }; 47 69 70 /// FunctorStaticPtr is just FunctorMemberPtr with @a T = void 48 71 typedef FunctorMemberPtr<void> FunctorStaticPtr; 49 72 73 /// It's not possible to use a typedef for FunctorPointerPtr<T>, so we have to create a child-class instead. It inherits all functions from SharedChildPtr, but needs to (re-)implement some constructors. 50 74 template <class F, class T> 51 75 class FunctorPointerPtr : public SharedChildPtr<FunctorPointer<F, T>, FunctorMemberPtr<T> > -
code/trunk/src/libraries/core/command/IOConsole.h
r7287 r7401 27 27 */ 28 28 29 /** 30 @file 31 @ingroup Command ShellConsole 32 */ 33 29 34 #include "OrxonoxConfig.h" 30 35 -
code/trunk/src/libraries/core/command/IOConsolePOSIX.h
r7287 r7401 27 27 * 28 28 */ 29 30 /** 31 @file 32 @ingroup Command ShellConsole 33 */ 29 34 30 35 #ifndef _IOConsole_H__ -
code/trunk/src/libraries/core/command/IOConsoleWindows.h
r7287 r7401 26 26 * 27 27 */ 28 29 /** 30 @file 31 @ingroup Command ShellConsole 32 */ 28 33 29 34 #ifndef _IOConsole_H__ -
code/trunk/src/libraries/core/command/IRC.cc
r7284 r7401 27 27 */ 28 28 29 /** 30 @file 31 @brief Implementation of the IRC class and the IRC console commands. 32 */ 33 29 34 #include "IRC.h" 30 35 … … 39 44 namespace orxonox 40 45 { 41 static const unsigned int IRC_TCL_THREADID = 1421421421; 46 static const unsigned int IRC_TCL_THREADID = 1421421421; ///< The ID of the thread in TclThreadManager that is used for the IRC connection 42 47 43 48 SetConsoleCommand("IRC", "say", &IRC::say); … … 45 50 SetConsoleCommand("IRC", "nick", &IRC::nick); 46 51 52 /** 53 @brief Returns the only existing instance of IRC. 54 */ 55 IRC& IRC::getInstance() 56 { 57 static IRC instance; 58 return instance; 59 } 60 61 /** 62 @brief Constructor: Doesn't yet connect to IRC nor does it create a Tcl interpreter. 63 The IRC object will automatically connect to the IRC server if one of the registered 64 console commands is used the first time. 65 */ 47 66 IRC::IRC() 48 67 { … … 50 69 } 51 70 71 /** 72 @brief Creates and initializes a new multithreaded Tcl-interpreter and defines some callbacks to display IRC-messages in the console. 73 */ 52 74 void IRC::initialize() 53 75 { … … 70 92 } 71 93 72 IRC& IRC::getInstance() 73 { 74 static IRC instance; 75 return instance; 76 } 77 94 /** 95 @brief Executes a Tcl-command on the Tcl-interpreter. 96 */ 78 97 bool IRC::eval(const std::string& command) 79 98 { … … 96 115 } 97 116 117 /// Console command: Sends a message to the current channel on the IRC server. 98 118 void IRC::say(const std::string& message) 99 119 { … … 102 122 } 103 123 124 /// Console command: Sends a message to a given channel or nickname on the IRC server. 104 125 void IRC::msg(const std::string& channel, const std::string& message) 105 126 { … … 108 129 } 109 130 131 /// Console command: Changes the nickname on the IRC server. 110 132 void IRC::nick(const std::string& nickname) 111 133 { … … 114 136 } 115 137 138 /// Tcl-callback: Prints a message that was received from the current IRC channel to the console. 116 139 void IRC::tcl_say(Tcl::object const &channel, Tcl::object const &nick, Tcl::object const &args) 117 140 { … … 119 142 } 120 143 144 /// Tcl-callback: Prints a private message that was received from a user to the console. 121 145 void IRC::tcl_privmsg(Tcl::object const &query, Tcl::object const &nick, Tcl::object const &args) 122 146 { … … 124 148 } 125 149 150 /// Tcl-callback: Prints an action-message (usually /me ...) that was received from the current IRC channel to the console. 126 151 void IRC::tcl_action(Tcl::object const &channel, Tcl::object const &nick, Tcl::object const &args) 127 152 { … … 129 154 } 130 155 156 /// Tcl-callback: Prints all kinds of information that were received from the IRC server or channel (connection info, join, part, modes, ...) to the console. 131 157 void IRC::tcl_info(Tcl::object const &channel, Tcl::object const &args) 132 158 { -
code/trunk/src/libraries/core/command/IRC.h
r7284 r7401 27 27 */ 28 28 29 /** 30 @file 31 @ingroup Command Tcl 32 @brief Declaration of IRC helper class, used for IRC connections using Tcl. 33 */ 34 29 35 #ifndef _IRC_H__ 30 36 #define _IRC_H__ … … 36 42 namespace orxonox 37 43 { 44 /** 45 @brief The IRC class creates a Tcl-thread (see TclThreadManager) and connects to an IRC server. 46 It provides different console commands to send messages and to perform other actions on the IRC server. 47 */ 38 48 class _CoreExport IRC 39 49 { … … 55 65 56 66 IRC(); 57 IRC(const IRC& other); 58 ~IRC() {} 67 IRC(const IRC& other); ///< Copy-constructor: Not implemented 68 ~IRC() {} ///< Destructor 59 69 60 Tcl::interpreter* interpreter_; 61 std::string nickname_; 70 Tcl::interpreter* interpreter_; ///< The Tcl interpreter that is used for the IRC connection 71 std::string nickname_; ///< The user's nickname on the IRC server 62 72 }; 63 73 } -
code/trunk/src/libraries/core/command/Shell.cc
r7284 r7401 26 26 * 27 27 */ 28 29 /** 30 @file 31 @brief Implementation of the Shell class. 32 */ 28 33 29 34 #include "Shell.h" … … 48 53 unsigned int Shell::cacheSize_s; 49 54 55 /** 56 @brief Constructor: Initializes the values and registers itself at OutputHandler. 57 @param consoleName The name of the shell - used to define the name of the soft-debug-level config-value 58 @param bScrollable If true, the user is allowed to scroll through the output-lines 59 */ 50 60 Shell::Shell(const std::string& consoleName, bool bScrollable) 51 61 : OutputListener(consoleName) … … 88 98 } 89 99 100 /** 101 @brief Destructor: Unregisters the shell from OutputHandler. 102 */ 90 103 Shell::~Shell() 91 104 { … … 94 107 } 95 108 109 /** 110 @brief Defines the config values. 111 */ 96 112 void Shell::setConfigValues() 97 113 { … … 113 129 } 114 130 131 /** 132 @brief Config-value callback: Called when the history offset has changed in the config-file. 133 */ 115 134 void Shell::commandHistoryOffsetChanged() 116 135 { … … 119 138 } 120 139 140 /** 141 @brief Config-value callback: Called when the length of the command history has changed in the config-file. 142 */ 121 143 void Shell::commandHistoryLengthChanged() 122 144 { … … 131 153 } 132 154 155 /** 156 @brief Registers this object as listener for different key-events at the input buffer. 157 */ 133 158 void Shell::configureInputBuffer() 134 159 { … … 159 184 } 160 185 161 /* 162 void Shell::history() 163 { 164 Shell& instance = Shell::getInstance(); 165 166 for (unsigned int i = instance.historyOffset_; i < instance.commandHistory_.size(); ++i) 167 instance.addOutput(instance.commandHistory_[i] + '\n', -1); 168 for (unsigned int i = 0; i < instance.historyOffset_; ++i) 169 instance.addOutput(instance.commandHistory_[i] + '\n', -1); 170 } 171 */ 172 186 /** 187 @brief Registers a shell listener which listens for changes in this shell. 188 */ 173 189 void Shell::registerListener(ShellListener* listener) 174 190 { … … 176 192 } 177 193 194 /** 195 @brief Unregisters a shell listener. 196 */ 178 197 void Shell::unregisterListener(ShellListener* listener) 179 198 { … … 187 206 } 188 207 208 /** 209 @brief Changes the position of the cursor in the input buffer. 210 */ 189 211 void Shell::setCursorPosition(unsigned int cursor) 190 212 { … … 193 215 } 194 216 217 /** 218 @brief Sends output to the internal output buffer. 219 */ 195 220 void Shell::addOutput(const std::string& text, LineType type) 196 221 { … … 199 224 } 200 225 226 /** 227 @brief Clears the list of output-lines. 228 */ 201 229 void Shell::clearOutput() 202 230 { … … 210 238 } 211 239 240 /** 241 @brief Returns an iterator to the newest line of output (except if the user is currently scrolling through the output). 242 */ 212 243 Shell::LineList::const_iterator Shell::getNewestLineIterator() const 213 244 { … … 218 249 } 219 250 251 /** 252 @brief Returns the end() iterator of the list of output-lines. 253 */ 220 254 Shell::LineList::const_iterator Shell::getEndIterator() const 221 255 { … … 223 257 } 224 258 259 /** 260 @brief Adds a command to the history of entered commands and writes it to the config-file. 261 */ 225 262 void Shell::addToHistory(const std::string& command) 226 263 { … … 237 274 } 238 275 276 /** 277 @brief Returns a command from the history of entered commands (usually the most recent history entry, but the user can scroll through the history). 278 */ 239 279 const std::string& Shell::getFromHistory() const 240 280 { … … 246 286 } 247 287 288 /** 289 @brief Called by OutputHandler or internally whenever output was sent to the output buffer. Reads from the buffer and writes the new output-lines to the list. 290 */ 248 291 void Shell::outputChanged(int lineType) 249 292 { … … 251 294 do 252 295 { 296 // get the first line from the buffer 253 297 std::string output; 254 298 std::getline(this->outputBuffer_, output); 255 299 300 // check the state of the buffer 256 301 bool eof = this->outputBuffer_.eof(); 257 302 bool fail = this->outputBuffer_.fail(); 258 303 if (eof) 259 this->outputBuffer_.flush(); 304 this->outputBuffer_.flush(); // check if more output was received in the meantime 260 305 if (eof || fail) 261 this->outputBuffer_.clear(); 306 this->outputBuffer_.clear(); // clear the error flags 307 308 // the line is terminated with a line-break if neither an error occurred nor the end of the file was reached 262 309 newline = (!eof && !fail); 263 310 311 // no output retrieved - break the loop 264 312 if (!newline && output.empty()) 265 313 break; 266 314 315 // check if the last line was terminated with a line-break 267 316 if (this->bFinishedLastLine_) 268 317 { 318 // yes it was - push the new line to the list 269 319 this->outputLines_.push_front(std::make_pair(output, static_cast<LineType>(lineType))); 270 320 321 // adjust the scroll position if needed 271 322 if (this->scrollPosition_) 272 323 this->scrollPosition_++; 273 324 else 274 325 this->scrollIterator_ = this->outputLines_.begin(); 275 276 this->bFinishedLastLine_ = newline;277 326 278 327 if (!this->scrollPosition_) … … 281 330 else 282 331 { 332 // no it wasn't - add the new output to the last line 283 333 this->outputLines_.front().first += output; 284 this->bFinishedLastLine_ = newline;285 334 this->updateListeners<&ShellListener::onlyLastLineChanged>(); 286 335 } 336 337 // remember if the last line was terminated with a line-break 287 338 this->bFinishedLastLine_ = newline; 288 339 289 } while (newline); 290 } 291 340 } while (newline); // loop as long as more lines are in the buffer 341 } 342 343 /** 344 @brief Clears the text in the input buffer. 345 */ 292 346 void Shell::clearInput() 293 347 { … … 298 352 } 299 353 300 void Shell::setPromptPrefix(const std::string& str)301 {302 }303 304 354 305 355 // ########################################## … … 307 357 // ########################################## 308 358 359 /// InputBuffer callback: Called if the input changes. 309 360 void Shell::inputChanged() 310 361 { … … 313 364 } 314 365 366 /// InputBuffer callback: Called if a key was pressed that executes a command (usually [return]). 315 367 void Shell::execute() 316 368 { … … 340 392 } 341 393 394 /// InputBuffer callback: Called if a key was pressed that shows hints and completes a command (usually [tab]). 342 395 void Shell::hintAndComplete() 343 396 { … … 349 402 } 350 403 404 /// InputBuffer callback: Called if a key was pressed that deletes the character before the cursor (usually [backspace]). 351 405 void Shell::backspace() 352 406 { … … 356 410 } 357 411 358 void Shell::exit() 359 { 360 if (this->inputBuffer_->getSize() > 0) 361 { 362 this->clearInput(); 363 return; 364 } 365 366 this->clearInput(); 367 this->scrollPosition_ = 0; 368 this->scrollIterator_ = this->outputLines_.begin(); 369 370 this->updateListeners<&ShellListener::exit>(); 371 } 372 412 /// InputBuffer callback: Called if a key was pressed that deletes the character after the cursor (usually [delete]). 373 413 void Shell::deleteChar() 374 414 { … … 377 417 } 378 418 419 /// InputBuffer callback: Called if a key was pressed that moves the input cursor the right (usually [arrow right]). 379 420 void Shell::cursorRight() 380 421 { … … 383 424 } 384 425 426 /// InputBuffer callback: Called if a key was pressed that moves the input cursor the left (usually [arrow left]). 385 427 void Shell::cursorLeft() 386 428 { … … 389 431 } 390 432 433 /// InputBuffer callback: Called if a key was pressed that moves the input cursor the end of the input line (usually [end]). 391 434 void Shell::cursorEnd() 392 435 { … … 395 438 } 396 439 440 /// InputBuffer callback: Called if a key was pressed that moves the input cursor the beginning of the input line (usually [home]). 397 441 void Shell::cursorHome() 398 442 { … … 401 445 } 402 446 447 /// InputBuffer callback: Called if a key was pressed that scrolls upwards through the history of entered commands (usually [arrow up]). 403 448 void Shell::historyUp() 404 449 { … … 410 455 } 411 456 457 /// InputBuffer callback: Called if a key was pressed that scrolls downwards through the history of entered commands (usually [arrow down]). 412 458 void Shell::historyDown() 413 459 { … … 419 465 } 420 466 467 /// InputBuffer callback: Called if a key was pressed that searches upwards through the history for a command stat starts like the one the user is currently typing (usually [page up]). Only if the shell is not scrollable. 421 468 void Shell::historySearchUp() 422 469 { … … 437 484 } 438 485 486 /// InputBuffer callback: Called if a key was pressed that searches downwards through the history for a command stat starts like the one the user is currently typing (usually [page down]). Only if the shell is not scrollable. 439 487 void Shell::historySearchDown() 440 488 { … … 455 503 } 456 504 505 /// InputBuffer callback: Called if a key was pressed that scrolls upwards through the output history (usually [page up]). Only if the shell is scrollable. 457 506 void Shell::scrollUp() 458 507 { … … 466 515 } 467 516 517 /// InputBuffer callback: Called if a key was pressed that scrolls downwards through the output history (usually [page down]). Only if the shell is scrollable. 468 518 void Shell::scrollDown() 469 519 { … … 476 526 } 477 527 } 528 529 /// InputBuffer callback: Called if a key was pressed that clears the text in the input buffer or closes the shell (usually [esc]). 530 void Shell::exit() 531 { 532 if (this->inputBuffer_->getSize() > 0) 533 { 534 this->clearInput(); 535 return; 536 } 537 538 this->clearInput(); 539 this->scrollPosition_ = 0; 540 this->scrollIterator_ = this->outputLines_.begin(); 541 542 this->updateListeners<&ShellListener::exit>(); 543 } 478 544 } -
code/trunk/src/libraries/core/command/Shell.h
r7284 r7401 27 27 */ 28 28 29 /** 30 @defgroup ShellConsole Shell and console 31 @ingroup Command 32 */ 33 34 /** 35 @file 36 @ingroup Command ShellConsole 37 @brief Declaration of the Shell and ShellListener classes. 38 */ 39 29 40 #ifndef _Shell_H__ 30 41 #define _Shell_H__ … … 43 54 namespace orxonox 44 55 { 56 /** 57 @brief An interface, used to get a notification if the state of the Shell changes. 58 */ 45 59 class _CoreExport ShellListener 46 60 { … … 51 65 52 66 private: 53 virtual void linesChanged() {} 54 virtual void onlyLastLineChanged() {} 55 virtual void lineAdded() {} 56 virtual void inputChanged() {} 57 virtual void cursorChanged() {} 58 virtual void executed() {} 59 virtual void exit() {} 67 virtual void linesChanged() {} ///< Called if all output-lines have changed 68 virtual void onlyLastLineChanged() {} ///< Called if only the last output-line has changed 69 virtual void lineAdded() {} ///< Called if a new line was added to the output 70 virtual void inputChanged() {} ///< Called if the input has changed 71 virtual void cursorChanged() {} ///< Called if the cursor in the input line has changed 72 virtual void executed() {} ///< Called if a command from the input line was executed 73 virtual void exit() {} ///< Called if the console should be closed 60 74 }; 61 75 62 76 77 /** 78 @brief The Shell is the logical component of the console that displays output to the user and allows him to enter commands. 79 80 The Shell gathers output sent from OutputHandler by inheriting from OutputListener. 81 The output-lines are stored in the shell, so they can be displayed in a graphical 82 console. Additionally the Shell has an InputBuffer which is needed by the user to 83 enter commands. 84 85 Different graphical consoles build upon a Shell, for example InGameConsole and IOConsole. 86 */ 63 87 class _CoreExport Shell : virtual public OrxonoxClass, public OutputListener 64 88 { 65 89 public: 90 /// Defines the type of a line of text in the Shell - some types depend on the output level, others are of internal use. 66 91 enum LineType 67 92 { … … 88 113 void unregisterListener(ShellListener* listener); 89 114 115 /// Returns the input buffer which is needed by the user to enter text into the shell. 90 116 inline InputBuffer* getInputBuffer() 91 117 { return this->inputBuffer_; } 92 118 93 119 void setCursorPosition(unsigned int cursor); 120 /// Returns the current position of the cursor in the input buffer. 94 121 inline unsigned int getCursorPosition() const 95 122 { return this->inputBuffer_->getCursorPosition(); } 96 123 124 /// Returns the current content of the input buffer (the text which was entered by the user) 97 125 inline const std::string& getInput() const 98 126 { return this->inputBuffer_->get(); } … … 105 133 void clearOutput(); 106 134 135 /// Returns the number of output-lines that are displayed in the shell. 107 136 inline unsigned int getNumLines() const 108 137 { return this->outputLines_.size(); } 138 /// Returns the line which is currently viewed if the user scrolls through the older output-lines in the shell. 109 139 inline unsigned int getScrollPosition() const 110 140 { return this->scrollPosition_; } 111 141 112 inline const std::string& getPromptPrefix() const { return this->promptPrefix_; } 113 void setPromptPrefix(const std::string& str); 114 142 /// Returns the cache size that is actually used in CommandExecutor, but placed here for better readability of the config file. 115 143 static inline unsigned int getCacheSize() 116 144 { return Shell::cacheSize_s; } … … 145 173 void exit(); 146 174 175 /// Iterates through all registered @ref ShellListener "shell listeners" and calls the function @a F. 147 176 template <void (ShellListener::*F)()> 148 177 void updateListeners() … … 152 181 } 153 182 154 std::list<ShellListener*> listeners_; 155 InputBuffer* inputBuffer_; 156 std::stringstream outputBuffer_; 157 bool bFinishedLastLine_; 158 LineList outputLines_; 159 LineList::const_iterator scrollIterator_; 160 unsigned int scrollPosition_; 161 unsigned int historyPosition_; 162 163 std::string promptPrefix_; 164 const std::string consoleName_; 165 const bool bScrollable_; 183 std::list<ShellListener*> listeners_; ///< The registered shell listeners 184 InputBuffer* inputBuffer_; ///< The input buffer that is needed by the user to enter text 185 std::stringstream outputBuffer_; ///< The output buffer that is used to retrieve lines of output from OutputListener 186 bool bFinishedLastLine_; ///< Stores if the most recent output-line was terminated with a line-break or if more output is expected for this line 187 LineList outputLines_; ///< A list of all output-lines that were displayed in the shell so far 188 LineList::const_iterator scrollIterator_; ///< An iterator to an entry of the list of output-lines, changes if the user scrolls through the output in the shell 189 unsigned int scrollPosition_; ///< The number of the line that is currently being referenced by scrollIterator_ 190 unsigned int historyPosition_; ///< If the user scrolls through the history of entered commands (stored in commandHistory_), this contains the currently viewed history entry 191 192 const std::string consoleName_; ///< The name of this shell - used to define the name of the soft-debug-level config-value 193 const bool bScrollable_; ///< If true, the user can scroll through the output-lines 166 194 167 195 // Config values 168 unsigned int maxHistoryLength_; 169 unsigned int historyOffset_; 170 std::vector<std::string> commandHistory_; 171 int softDebugLevel_; 172 static unsigned int cacheSize_s; 196 unsigned int maxHistoryLength_; ///< The maximum number of saved commands 197 unsigned int historyOffset_; ///< The command history is a circular buffer, this variable defines the current write-offset 198 std::vector<std::string> commandHistory_; ///< The history of commands that were entered by the user 199 int softDebugLevel_; ///< The maximum level of output that is displayed in the shell (will be passed to OutputListener to filter output) 200 static unsigned int cacheSize_s; ///< The maximum cache size of the CommandExecutor - this is stored here for better readability of the config file and because CommandExecutor is no OrxonoxClass 173 201 }; 174 202 } -
code/trunk/src/libraries/core/command/TclBind.cc
r7284 r7401 49 49 TclBind* TclBind::singletonPtr_s = 0; 50 50 51 /** 52 @brief Constructor: Initializes the Tcl-interpreter with a given data path. 53 @param datapath Path to the directory that contains the Orxonox-specific Tcl-files 54 */ 51 55 TclBind::TclBind(const std::string& datapath) 52 56 { … … 56 60 } 57 61 62 /** 63 @brief Destructor: Deletes the Tcl-interpreter. 64 */ 58 65 TclBind::~TclBind() 59 66 { … … 62 69 } 63 70 71 /** 72 @brief Defines the path to the directory that contains the Orxonox-specific Tcl-files and initializes the Tcl-interpreter accordingly. 73 */ 64 74 void TclBind::setDataPath(const std::string& datapath) 65 75 { … … 71 81 } 72 82 83 /** 84 @brief Creates and initializes the Tcl-interpreter by registering all callbacks and defining some useful functions. 85 */ 73 86 void TclBind::initializeTclInterpreter() 74 87 { … … 96 109 } 97 110 111 /** 112 @brief Creates and initializes a new Tcl-interpreter and calls the Orxonox-specific 113 init.tcl script that defines some special functions which are required by Orxonox. 114 */ 98 115 Tcl::interpreter* TclBind::createTclInterpreter() 99 116 { … … 116 133 } 117 134 135 /** 136 @brief Returns the path to the Tcl-library (not the Orxonox-specific Tcl-files). 137 */ 118 138 std::string TclBind::getTclLibraryPath() 119 139 { … … 128 148 } 129 149 150 /** 151 @brief Callback: Used to send an Orxonox-command from Tcl to the CommandExecutor and to send its result back to Tcl. 152 */ 130 153 std::string TclBind::tcl_query(Tcl::object const &args) 131 154 { … … 151 174 } 152 175 176 /** 177 @brief Callback: Used to send an Orxonox-command from Tcl to the CommandExecutor. 178 */ 153 179 void TclBind::tcl_execute(Tcl::object const &args) 154 180 { … … 162 188 } 163 189 190 /** 191 @brief Console command, executes Tcl code. Can be used to bind Tcl-commands to a key, because native 192 Tcl-commands can not be evaluated and are thus not supported by the key-binder. 193 */ 164 194 std::string TclBind::tcl(const std::string& tclcode) 165 195 { … … 182 212 } 183 213 214 /** 215 @brief Console command and implementation of the Tcl-feature "bgerror" which is called if an error 216 occurred in the background of a Tcl-script. 217 */ 184 218 void TclBind::bgerror(const std::string& error) 185 219 { … … 187 221 } 188 222 223 /** 224 @brief Executes Tcl-code and returns the return-value. 225 @param tclcode A string that contains Tcl-code 226 @param error A pointer to an integer (or NULL) that is used to write an error-code (see @ref CommandExecutorErrorCodes "CommandExecutor error codes") 227 @return Returns the return-value of the executed code (or an empty string if there's no return-value) 228 */ 189 229 std::string TclBind::eval(const std::string& tclcode, int* error) 190 230 { … … 194 234 try 195 235 { 236 // execute the code 196 237 return TclBind::getInstance().interpreter_->eval(tclcode); 197 238 } -
code/trunk/src/libraries/core/command/TclBind.h
r7284 r7401 27 27 */ 28 28 29 /** 30 @defgroup Tcl Tcl 31 @ingroup Command 32 */ 33 34 /** 35 @file 36 @ingroup Command Tcl 37 @brief Declaration of the TclBind class. 38 39 @anchor TclBindExample 40 41 orxonox::TclBind is a wrapper class for a Tcl interpreter. It is implemented as 42 singleton, so it can be accessed by everyone, but all share the same static 43 Tcl interpreter. If you need a Tcl interpreter at your own, see orxonox::TclThreadManager 44 for more information. 45 46 orxonox::TclBind is used by orxonox::CommandExecutor to execute Tcl commands. It can 47 also be used to execute Tcl commands from different sources, but note that they may 48 interfer with the ingame console if used improperly. By no means execute blocking 49 commands such as endless loops or the tcl command @c vwait. Use orxonox::TclThreadManager 50 and execute these commands in a multithreaded Tcl interpreter instead. 51 52 TclBind also defines different callback functions to return commands from the 53 Tcl interpreter back to Orxonox. Because of that it's possible to send a mixture 54 of Orxonox- and Tcl-commands to TclBind::eval() and still get the desired behavior. 55 56 Example: 57 @code 58 TclBind::eval("puts \"Hello World\""); // calls the tcl command "puts", prints "Hello World" to the console 59 TclBind::eval("log Hello World"); // calls the orxonox command "log", prints "Hello World" to the console 60 61 TclBind::eval("log [expr 1+1]"); // prints "2" to the console (which is the result of the tcl command "expr") 62 63 TclBind::eval("puts -nonewline Hello; log World"); // prints "HelloWorld" to the console 64 65 TclBind::eval("for {set i 0} {$i < 10} {incr i} {log test: $i}"); // prints "test: 0", ..., "test: 9" to the console 66 @endcode 67 68 Note that @c puts and @c log behave slightly different, even though both can print 69 text to the console. @c puts needs quotation marks around multi-word output, while 70 @c log doesn't. @c puts on the other hand supports the flag @c -nonewline. 71 72 TclBind::eval() can also be used to obtain the return-value of a Tcl command: 73 @code 74 std::string result = TclBind::eval("expr 1+1"); // result == "2" 75 @endcode 76 */ 77 29 78 #ifndef _TclBind_H__ 30 79 #define _TclBind_H__ … … 38 87 namespace orxonox 39 88 { 89 /** 90 @brief A wrapper class for a Tcl interpreter. Used to execute Tcl commands. 91 92 TclBind is used to execute Tcl commands, for example if sent to CommandExecutor::execute(). 93 It also defines different callbacks for Tcl, which allows to combine Orxonox-console-commands 94 and Tcl-function without problems. 95 96 @see See @ref TclBindExample "TclBind.h" for more information and an example. 97 */ 40 98 class _CoreExport TclBind : public Singleton<TclBind> 41 99 { … … 49 107 50 108 void setDataPath(const std::string& datapath); 51 const std::string& getTclDataPath() const { return this->tclDataPath_; }52 109 static std::string getTclLibraryPath(); 110 /// Returns the path to the Orxonox-specific Tcl-files. 111 inline const std::string& getTclDataPath() const 112 { return this->tclDataPath_; } 53 113 54 114 void initializeTclInterpreter(); 55 115 static Tcl::interpreter* createTclInterpreter(); 56 Tcl::interpreter* getTclInterpreter() const { return this->interpreter_; } 116 /// Returns the Tcl-interpreter 117 inline Tcl::interpreter* getTclInterpreter() const 118 { return this->interpreter_; } 57 119 58 120 static std::string tcl_query(Tcl::object const &args); … … 62 124 63 125 private: 64 TclBind(const TclBind& other); 126 TclBind(const TclBind& other); ///< Copy-constructor, not implemented 65 127 66 Tcl::interpreter* interpreter_; 67 std::string tclDataPath_; 68 bool bSetTclDataPath_; 128 Tcl::interpreter* interpreter_; ///< The wrapped Tcl interpreter 129 std::string tclDataPath_; ///< The path to the directory that contains the Orxonox-specific Tcl-files 130 bool bSetTclDataPath_; ///< True if tclDataPath_ was defined (after a call to setDataPath()) 69 131 70 static TclBind* singletonPtr_s; 132 static TclBind* singletonPtr_s; ///< The singleton pointer 71 133 }; 72 134 } -
code/trunk/src/libraries/core/command/TclThreadList.h
r7284 r7401 27 27 */ 28 28 29 /** 30 @file 31 @ingroup Command Tcl 32 @brief Definition of TclThreadList. 33 */ 34 29 35 #ifndef _TclThreadList_H__ 30 36 #define _TclThreadList_H__ … … 40 46 namespace orxonox 41 47 { 48 /** 49 @brief A thread-safe implementation of a message queue, used by TclThreadManager. 50 */ 42 51 template <class T> 43 52 class TclThreadList … … 71 80 72 81 /** 73 @brief Returns a reference to the mutex which might be useful if you want to iterate through the list (see @ref begin and @ref end).82 @brief Returns a reference to the mutex which might be useful if you want to iterate through the list (see @ref getList()). 74 83 */ 75 84 inline boost::shared_mutex& getMutex() const -
code/trunk/src/libraries/core/command/TclThreadManager.cc
r7284 r7401 26 26 * 27 27 */ 28 29 /** 30 @file 31 @brief Implementation of TclThreadManager. 32 */ 28 33 29 34 #include "TclThreadManager.h" … … 251 256 void TclThreadManager::initialize(TclInterpreterBundle* bundle) 252 257 { 253 const std::string& id_string = getConvertedValue<unsigned int,std::string>(bundle->id_);258 const std::string& id_string = multi_cast<std::string>(bundle->id_); 254 259 255 260 // Initialize the new interpreter … … 303 308 /** 304 309 @brief Sends a command to the queue of a given Tcl-interpreter 305 @param id The id of the target interpreter310 @param target_id The id of the target interpreter 306 311 @param command The command to be sent 307 312 */ … … 326 331 @brief This function can be called from Tcl to send a command to the queue of any interpreter. 327 332 @param target_id The id of the target thread 333 @param args Contains the content of the command 328 334 */ 329 335 void TclThreadManager::tcl_crossexecute(int target_id, const Tcl::object& args) … … 334 340 /** 335 341 @brief Sends a command to the queue of a given Tcl-interpreter 336 @param id The id of the target interpreter342 @param target_id The id of the target interpreter 337 343 @param command The command to be sent 338 344 */ … … 347 353 /** 348 354 @brief Sends a query to a given Tcl-interpreter and waits for the result 349 @param id The id of the target interpreter355 @param target_id The id of the target interpreter 350 356 @param command The command to be sent 351 357 @return The result of the command … … 359 365 @brief This function can be called from Tcl to send a query to the main thread. 360 366 @param source_id The id of the calling thread 367 @param args Contains the content of the query 361 368 362 369 A query waits for the result of the command. This means, the calling thread will be blocked until … … 373 380 @param source_id The id of the calling thread 374 381 @param target_id The id of the target thread 382 @param args Contains the content of the query 375 383 */ 376 384 std::string TclThreadManager::tcl_crossquery(int source_id, int target_id, const Tcl::object& args) … … 384 392 @param target_id The id of the target thread 385 393 @param command The command to send as a query 386 @param bUseCommandExecutor Only used if the target_id is 0 (which references the main interpreter). In this case it means if the command should be passed to the CommandExecutor (true) or to the main Tcl interpreter (false). This is true when called by tcl_query and false when called by tcl_crossquery.394 @param bUseCommandExecutor Only used if the target_id is 0 (which references the main interpreter). In this case it means if the command should be passed to the CommandExecutor (true) or to the main Tcl interpreter (false). This is true when called by tcl_query() and false when called by tcl_crossquery(). 387 395 */ 388 396 std::string TclThreadManager::_query(unsigned int source_id, unsigned int target_id, const std::string& command, bool bUseCommandExecutor) … … 400 408 { 401 409 // This query would lead to a deadlock - return with an error 402 TclThreadManager::error("Error: Circular query (" + this->dumpList(source_bundle->queriers_.getList()) + ' ' + getConvertedValue<unsigned int,std::string>(source_bundle->id_) \403 + " -> " + getConvertedValue<unsigned int,std::string>(target_bundle->id_) \404 + "), couldn't query Tcl-interpreter with ID " + getConvertedValue<unsigned int,std::string>(target_bundle->id_) \405 + " from other interpreter with ID " + getConvertedValue<unsigned int,std::string>(source_bundle->id_) + '.');410 TclThreadManager::error("Error: Circular query (" + this->dumpList(source_bundle->queriers_.getList()) + ' ' + multi_cast<std::string>(source_bundle->id_) \ 411 + " -> " + multi_cast<std::string>(target_bundle->id_) \ 412 + "), couldn't query Tcl-interpreter with ID " + multi_cast<std::string>(target_bundle->id_) \ 413 + " from other interpreter with ID " + multi_cast<std::string>(source_bundle->id_) + '.'); 406 414 } 407 415 else … … 469 477 // This happens if the main thread tries to query a busy interpreter 470 478 // To avoid a lock of the main thread, we simply don't proceed with the query in this case 471 TclThreadManager::error("Error: Couldn't query Tcl-interpreter with ID " + getConvertedValue<unsigned int,std::string>(target_bundle->id_) + ", interpreter is busy right now.");479 TclThreadManager::error("Error: Couldn't query Tcl-interpreter with ID " + multi_cast<std::string>(target_bundle->id_) + ", interpreter is busy right now."); 472 480 } 473 481 } … … 515 523 else 516 524 { 517 TclThreadManager::error("Error: No Tcl-interpreter with ID " + getConvertedValue<unsigned int,std::string>(id) + " existing.");525 TclThreadManager::error("Error: No Tcl-interpreter with ID " + multi_cast<std::string>(id) + " existing."); 518 526 return 0; 519 527 } … … 531 539 output += ' '; 532 540 533 output += getConvertedValue<unsigned int,std::string>(*it);541 output += multi_cast<std::string>(*it); 534 542 } 535 543 return output; … … 583 591 if (cc != TCL_OK) 584 592 { 585 TclThreadManager::error("Tcl error (" + action + ", ID " + getConvertedValue<unsigned int,std::string>(bundle->id_) + "): " + static_cast<std::string>(result));593 TclThreadManager::error("Tcl error (" + action + ", ID " + multi_cast<std::string>(bundle->id_) + "): " + static_cast<std::string>(result)); 586 594 return ""; 587 595 } -
code/trunk/src/libraries/core/command/TclThreadManager.h
r7284 r7401 26 26 * 27 27 */ 28 29 /** 30 @file 31 @ingroup Command Tcl 32 @brief Declaration of TclThreadManager, used to create multithreaded Tcl interpreters. 33 */ 28 34 29 35 #ifndef _TclThreadManager_H__ -
code/trunk/src/libraries/core/input/Button.cc
r7284 r7401 176 176 // evaluate the command 177 177 CommandEvaluation eval = CommandExecutor::evaluate(commandStr); 178 if (!eval.isValid() || eval.evaluate Params(true))178 if (!eval.isValid() || eval.evaluateArguments(true)) 179 179 { 180 180 parseError("Command evaluation of \"" + commandStr + "\"failed.", true); -
code/trunk/src/libraries/core/input/InputCommands.cc
r5781 r7401 53 53 if (this->abs_ != 0.0f || this->rel_ != 0.0f) 54 54 { 55 evaluation_.setEvaluated Parameter(paramIndex_, Vector2(abs_, rel_));55 evaluation_.setEvaluatedArgument(paramIndex_, Vector2(abs_, rel_)); 56 56 // reset 57 57 rel_ = 0.0; -
code/trunk/src/libraries/core/input/InputManager.cc
r7284 r7401 140 140 Creates the OIS::InputMananger, the keyboard, the mouse and 141 141 the joys ticks. If either of the first two fail, this method throws an exception. 142 @param windowWidth143 The width of the render window144 @param windowHeight145 The height of the render window146 142 */ 147 143 void InputManager::loadDevices() -
code/trunk/src/libraries/core/input/InputManager.h
r6746 r7401 122 122 @param name 123 123 Unique name of the InputState when referenced as string 124 @param bAlwaysGetsInput 125 InputState always gets the input when activated 126 @param bTransparent 127 InputState will not prevent underlaying state from receiving input 124 128 @param priority 125 129 Priority matters when multiple states are active. You can specify any -
code/trunk/src/libraries/core/input/InputState.h
r7284 r7401 128 128 void resetExpiration() { bExpired_ = false; } 129 129 130 //! Updates one specific device handler with #device#Updated130 //! Updates one specific device handler with deviceUpdated 131 131 void update(float dt, unsigned int device); 132 132 //! Updates all handlers with allDevicesUpdated -
code/trunk/src/libraries/core/input/KeyBinder.cc
r6536 r7401 495 495 @brief 496 496 Event handler for the mouseMoved Event. 497 @param e 498 Mouse state information 497 @param abs_ 498 The absolute position of the mouse 499 @param rel_ 500 The relative movement of the mouse 501 @param clippingSize 502 Mouse screen area in pixels (usually 1024x1024) 499 503 */ 500 504 void KeyBinder::mouseMoved(IntVector2 abs_, IntVector2 rel_, IntVector2 clippingSize) … … 551 555 /** 552 556 @brief Event handler for the mouseScrolled Event. 553 @param e Mouse state information 557 @param abs The absolute position of the scroll wheel 558 @param rel The relative movement of the scroll wheel 554 559 */ 555 560 void KeyBinder::mouseScrolled(int abs, int rel) -
code/trunk/src/libraries/network/ClientInformation.cc
r6417 r7401 230 230 * This function should only be applied to the head of the list 231 231 * @param clientID id to look for 232 * @param look_backwards FIXME - add doc? parameter unused? 232 233 * @return pointer to the last element in the list or 0 if the search was unsuccessfull 233 234 */ … … 244 245 * This function goes forward through the list and looks for an element with clientID 245 246 * This function should only be applied to the head of the list 246 * @param peer peer to look for 247 * @param address peer to look for 248 * @param look_backwards FIXME - add doc? parameter unused? 247 249 * @return pointer to the element in the list 248 250 */ -
code/trunk/src/libraries/network/GamestateClient.cc
r7163 r7401 105 105 * @return iterator pointing to the next object in the list 106 106 */ 107 void GamestateClient::removeObject(ObjectList <Synchronisable>::iterator&it) {108 ObjectList <Synchronisable>::iteratortemp=it;107 void GamestateClient::removeObject(ObjectListIterator<Synchronisable> &it) { 108 ObjectListIterator<Synchronisable> temp=it; 109 109 ++it; 110 110 temp->destroy(); // or delete? -
code/trunk/src/libraries/network/synchronisable/Synchronisable.cc
r7183 r7401 217 217 * length of varx: size saved int syncvarlist 218 218 * @param mem pointer to allocated memory with enough size 219 * @param sizes FIXME - add doc! 219 220 * @param id gamestateid of the gamestate to be saved (important for priorities) 220 221 * @param mode defines the direction in which the data will be send/received … … 288 289 * @param mem pointer to the bytestream 289 290 * @param mode same as in getData 291 * @param forceCallback FIXME - add doc! 290 292 * @return true/false 291 293 */ … … 364 366 * This function determines, wheter the object should be saved to the bytestream (according to its syncmode/direction) 365 367 * @param id gamestate id 368 * @param mode FIXME - add doc! 366 369 * @return true/false 367 370 */ -
code/trunk/src/libraries/tools/ResourceCollection.cc
r5781 r7401 52 52 } 53 53 54 void ResourceCollection::XMLPort(Element& xml Element, XMLPort::Mode mode)54 void ResourceCollection::XMLPort(Element& xmlelement, XMLPort::Mode mode) 55 55 { 56 XMLPortParam(ResourceCollection, "resourceGroup", setResourceGroup, getResourceGroup, xml Element, mode);57 XMLPortObject(ResourceCollection, ResourceLocation, "", addResourceLocation, getResourceLocation, xml Element, mode);56 XMLPortParam(ResourceCollection, "resourceGroup", setResourceGroup, getResourceGroup, xmlelement, mode); 57 XMLPortObject(ResourceCollection, ResourceLocation, "", addResourceLocation, getResourceLocation, xmlelement, mode); 58 58 } 59 59 -
code/trunk/src/libraries/tools/ResourceCollection.h
r6105 r7401 44 44 virtual ~ResourceCollection(); 45 45 46 virtual void XMLPort(Element& xml Element, XMLPort::Mode mode);46 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 47 47 48 48 void setResourceGroup(const std::string& resourceGroup); -
code/trunk/src/libraries/tools/ResourceLocation.cc
r7174 r7401 56 56 } 57 57 58 void ResourceLocation::XMLPort(Element& xml Element, XMLPort::Mode mode)58 void ResourceLocation::XMLPort(Element& xmlelement, XMLPort::Mode mode) 59 59 { 60 XMLPortParam(ResourceLocation, "path", setPath, getPath, xml Element, mode);61 XMLPortParam(ResourceLocation, "archiveType", setArchiveType, getArchiveType, xml Element, mode);62 XMLPortParam(ResourceLocation, "recursive", setRecursive, getRecursive, xml Element, mode);60 XMLPortParam(ResourceLocation, "path", setPath, getPath, xmlelement, mode); 61 XMLPortParam(ResourceLocation, "archiveType", setArchiveType, getArchiveType, xmlelement, mode); 62 XMLPortParam(ResourceLocation, "recursive", setRecursive, getRecursive, xmlelement, mode); 63 63 if (path_.empty()) 64 64 ThrowException(AbortLoading, "ResourceLocation: No path given."); -
code/trunk/src/libraries/tools/ResourceLocation.h
r5781 r7401 46 46 virtual ~ResourceLocation(); 47 47 48 virtual void XMLPort(Element& xml Element, XMLPort::Mode mode);48 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 49 49 50 50 void setPath(const std::string& path) { path_ = path; } -
code/trunk/src/libraries/tools/Timer.cc
r7284 r7401 27 27 */ 28 28 29 /** 30 @file 31 @brief Implementation of the Timer class. 32 */ 33 29 34 #include "Timer.h" 30 35 … … 45 50 46 51 /** 47 @brief C alls a console command after 'delay'seconds.52 @brief Console-command: Calls another console command after @a delay seconds. 48 53 @param delay The delay in seconds 49 54 @param command The console command … … 60 65 61 66 /** 62 @brief Executes the command.63 @param timer The timer to destroy after the command-execution67 @brief Helper function for delay(), executes the command and destroys the timer. 68 @param timer The timer which called this function. 64 69 @param command The command to execute 65 70 */ … … 72 77 73 78 /** 74 @brief Kills all delayed commands.79 @brief Console-command: Kills all scheduled commands that were delayed using delay(). 75 80 */ 76 81 void killdelays() … … 92 97 93 98 /** 94 @brief Constructor: Initializes the Timer with given values. 95 @param interval The timer-interval in seconds 96 @param bLoop If true, the function gets called every 'interval' seconds 97 @param exeuctor A executor of the function to call 99 @brief Constructor: Initializes and starts the timer, which will call an executor after some time. 100 @param interval The timer-interval in seconds 101 @param bLoop If true, the executor gets called every @a interval seconds 102 @param executor The executor that will be called 103 @param bKillAfterCall If true, the timer will be deleted after the executor was called 98 104 */ 99 105 Timer::Timer(float interval, bool bLoop, const ExecutorPtr& executor, bool bKillAfterCall) … … 120 126 121 127 /** 122 @brief Executes the executor.128 @brief Calls the executor and destroys the timer if requested. 123 129 */ 124 130 void Timer::run() -
code/trunk/src/libraries/tools/Timer.h
r7284 r7401 27 27 */ 28 28 29 /*! 29 /** 30 @defgroup Timer Timer 31 @ingroup Tools 32 */ 33 34 /** 30 35 @file 31 @brief Definition and Implementation of the Timer class. 36 @ingroup Timer 37 @brief Declaration of the Timer class, used to call functions after a given time-interval. 32 38 33 The Timer is a callback-object, calling a given function after a given time-interval.39 @anchor TimerExample 34 40 35 Usage: 41 Timer is a helper class that executes a function after a given amount of time. 42 43 Usage: <br> 36 44 header.h: 37 class ClassName 38 { 39 public: 40 ClassName(); 41 void functionName(); 42 Timer myTimer; 43 }; 45 @code 46 class MyClass 47 { 48 public: 49 MyClass(); 50 void functionName(); 51 52 private: 53 Timer myTimer; 54 }; 55 @endcode 44 56 45 57 source.cc: 46 #include "core/command/Executor.h" 58 @code 59 #include "core/command/Executor.h" 47 60 48 ClassName::ClassName()49 50 myTimer.setTimer(interval_in_seconds, bLoop, createExecutor(createFunctor(&ClassName::functionName, this)));51 61 MyClass::MyClass() 62 { 63 myTimer.setTimer(3, false, createExecutor(createFunctor(&ClassName::myFunction, this))); 64 } 52 65 53 void ClassName::functionName() 54 { 55 whateveryouwant(); 56 something(else); 57 } 66 void MyClass::myFunction() 67 { 68 COUT(0) << "Hello World" << std::endl; 69 } 70 @endcode 71 72 The code in this example prints "Hello World" to the console, 3 seconds after creating 73 an instance of MyClass. 58 74 */ 59 75 … … 73 89 void executeDelayedCommand(Timer* timer, const std::string& command); 74 90 75 //! The Timer is a callback-object, calling a given function after a given time-interval. 91 /** 92 @brief Timer is a helper class that executes a function after a given amount of time. 93 94 @see See @ref TimerExample "Timer.h" for an example. 95 */ 76 96 class _ToolsExport Timer : public TimeFactorListener 77 97 { … … 82 102 83 103 /** 84 @brief Initializes the Timer with given values.85 @param interval The timer-interval in seconds86 @param bLoop If true, the function gets called every 'interval'seconds87 @param object The object owning the timer and the function88 @param executor A executor of the function to call104 @brief Initializes and starts the timer, which will call an executor after some time. 105 @param interval The timer-interval in seconds 106 @param bLoop If true, the executor gets called every @a interval seconds 107 @param executor The executor that will be called 108 @param bKillAfterCall If true, the timer will be deleted after the executor was called 89 109 */ 90 110 void setTimer(float interval, bool bLoop, const ExecutorPtr& executor, bool bKillAfterCall = false) … … 101 121 void run(); 102 122 103 / ** @brief Starts the Timer: Function-call after 'interval' seconds. */123 /// Re-starts the Timer: The executor will be called after @a interval seconds. 104 124 inline void startTimer() 105 125 { this->bActive_ = true; this->time_ = this->interval_; } 106 / ** @brief Stops the Timer. */126 /// Stops the Timer. 107 127 inline void stopTimer() 108 128 { this->bActive_ = false; this->time_ = this->interval_; } 109 / ** @brief Pauses the Timer - it will continue with the actual state if you unpause it. */129 /// Pauses the Timer - it will continue with the actual state if you call unpauseTimer(). 110 130 inline void pauseTimer() 111 131 { this->bActive_ = false; } 112 / ** @brief Unpauses the Timer - continues with the given state. */132 /// Unpauses the Timer - continues with the given state. 113 133 inline void unpauseTimer() 114 134 { this->bActive_ = true; } 115 / ** @brief Returns true if the Timer is active (= not stoped, not paused). @return True = Time is active */135 /// Returns true if the Timer is active (neither stoped nor paused). 116 136 inline bool isActive() const 117 137 { return this->bActive_; } 118 / ** @brief Returns the remaining time until the Timer calls the function. @return The remaining time */138 /// Returns the remaining time until the Timer calls the executor. 119 139 inline float getRemainingTime() const 120 140 { return static_cast<float>(this->time_ / 1000000.0f); } 121 / ** @brief Gives the Timer some extra time. @param time The amount of extra time in seconds */141 /// Increases the remaining time of the Timer by the given amount of time (in seconds). 122 142 inline void addTime(float time) 123 143 { if (time > 0.0f) this->time_ += static_cast<long long>(time * 1000000.0f); } 124 / ** @brief Decreases the remaining time of the Timer. @param time The amount of time to remove */144 /// Decreases the remaining time of the Timer by the given amount of time (in seconds) 125 145 inline void removeTime(float time) 126 146 { if (time > 0.0f) this->time_ -= static_cast<long long>(time * 1000000.0f); } 127 / ** @brief Sets the interval of the Timer. @param interval The interval */147 /// Changes the calling interval. 128 148 inline void setInterval(float interval) 129 149 { this->interval_ = static_cast<long long>(interval * 1000000.0f); } 130 / ** @brief Sets bLoop to a given value. @param bLoop True = loop */150 /// Defines if the timer call the executor every @a interval seconds or only once. 131 151 inline void setLoop(bool bLoop) 132 152 { this->bLoop_ = bLoop; } … … 137 157 void init(); 138 158 139 ExecutorPtr executor_; //!< The executor of the function that shouldbe called when the time expires159 ExecutorPtr executor_; //!< The executor of the function that will be called when the time expires 140 160 141 161 long long interval_; //!< The time-interval in micro seconds 142 bool bLoop_; //!< If true, the function gets called every 'interval'seconds143 bool bActive_; //!< If true, the Timer ticks and calls the functionif the time's up144 bool bKillAfterCall_; //!< If true the timer gets deleted after it called the function162 bool bLoop_; //!< If true, the executor gets called every @a interval seconds 163 bool bActive_; //!< If true, the Timer ticks and calls the executor if the time's up 164 bool bKillAfterCall_; //!< If true the timer gets deleted after it expired and called the executor 145 165 146 long long time_; //!< Internal variable, counting the time till the next function-call166 long long time_; //!< Internal variable, counting the time untill the next executor-call 147 167 }; 148 168 } -
code/trunk/src/libraries/util/Clipboard.cc
r6417 r7401 54 54 55 55 /** 56 @brief Puts text into the windows-clipboard 57 @param text The text 56 @brief Puts text into the Windows-clipboard 58 57 @return True if the action was successful 59 58 */ … … 119 118 namespace orxonox 120 119 { 121 static std::string clipboard; // !< Keeps the text of our internal clipboard120 static std::string clipboard; ///< Keeps the text of our internal clipboard 122 121 123 122 /** 124 123 @brief Default implementation if there is no OS-specific implementation or no clipboard. Copies the text into an internal clipboard. 125 @param text The text 126 @return True 124 @see fromClipboard() 127 125 */ 128 126 bool toClipboard(const std::string& text) … … 134 132 /** 135 133 @brief Default implementation if there is no OS-specific implementation or no clipboard. Gets the text from the internal clipboard. 136 @ return The text134 @see toClipboard() 137 135 */ 138 136 std::string fromClipboard() -
code/trunk/src/libraries/util/Clipboard.h
r5781 r7401 29 29 /** 30 30 @file 31 @brief Some functions to exchange text between the OS clipboard and Orxonox. 31 @ingroup Util Command 32 @brief Some functions to exchange text between the OS clipboard and the Shell in Orxonox. 32 33 33 34 Use fromClipboard() to get text from the clipboard (if there is any text) and 34 toClipboard( text) to put text into the clipboard.35 toClipboard() to put text into the clipboard. 35 36 36 Th ose functions can only work properly if there's an OS-specific implementation.37 If an OS isn't supported, the clipboard only works within Orxonox, but exchange38 with other programs isn't possible.37 These functions can only work properly if there's an OS-specific implementation 38 in Clipboard.cc. If a specific OS is not supported, the clipboard only works 39 within Orxonox, but the exchange with other programs is not possible. 39 40 */ 40 41 -
code/trunk/src/libraries/util/Clock.cc
r6417 r7401 45 45 } 46 46 47 /**48 @remarks49 Mind the types! Ogre::Timer::getMicroseconds() will return an unsigned50 long, which will eventually overflow. But if you use the subtraction of51 the current time minus the last time the timer gave us and sum these up to52 a 64 bit integer, we get the desired result.53 Also mind that we don't have to store the last timer's time as unsigned long54 as well because (unsigned long)tickTime_ will do exactly that.55 */56 47 void Clock::capture() 57 48 { -
code/trunk/src/libraries/util/Clock.h
r6417 r7401 27 27 */ 28 28 29 /** 30 @file 31 @ingroup Util 32 */ 33 29 34 #ifndef _Clock_H__ 30 35 #define _Clock_H__ … … 35 40 namespace orxonox 36 41 { 42 /** Simple real time clock based on Ogre::Timer 43 @details 44 The class can be used to both capture the current real time or to 45 incrementally capture the time and then distribute that time information 46 via Clock& references (for instance for the game tick). <br> 47 Precision: <br> 48 @par Precision 49 The maximum precision is given by the Ogre::Timer and that is somewhere 50 in the microsecond range for both Windows and UNIX. 51 @par Remarks for Usage on Windows 52 For proper functionality this class MUST be used in the same thread! <br> 53 Furthermore it might be possible that the Ogre::Timer has a performance 54 caveat because it will only capture the time on the same CPU core. 55 Confining the main thread to one process could speed up the game. 56 See \ref cmdargspage "Ccommandline Argument" 'limitToCPU' (only on Windows) 57 */ 37 58 class _UtilExport Clock 38 59 { 39 60 public: 61 /// Starts the time at 0 40 62 Clock(); 41 63 ~Clock(); 42 64 65 /** Internally captures the time and stays at that particular time 66 @remarks 67 Mind the types! Ogre::Timer::getMicroseconds() will return an unsigned 68 long, which will eventually overflow. But if you use the subtraction of 69 the current time minus the last time the timer gave us and sum these up to 70 a 64 bit integer, we get the desired result. <br> 71 Also mind that we don't have to store the last timer's time as unsigned long 72 as well because (unsigned long)tickTime_ will do exactly that. 73 */ 43 74 void capture(); 44 75 45 unsigned long long getMicroseconds() const { return tickTime_; } 46 unsigned long long getMilliseconds() const { return tickTime_ / 1000; } 47 unsigned long getSeconds() const { return static_cast<long> (tickTime_ / 1000000); } 48 float getSecondsPrecise() const { return static_cast<float>(tickTime_ / 1000000.0f); } 76 /// Returns the last captured absolute time in microseconds 77 unsigned long long getMicroseconds() const 78 { return tickTime_; } 79 /// Returns the last captured absolute time in milliseconds 80 unsigned long long getMilliseconds() const 81 { return tickTime_ / 1000; } 82 /// Returns the last captured absolute time in seconds 83 unsigned long getSeconds() const 84 { return static_cast<long> (tickTime_ / 1000000); } 85 /// Returns the last captured absolute time in seconds as float 86 float getSecondsPrecise() const 87 { return static_cast<float>(tickTime_ / 1000000.0f); } 49 88 50 float getDeltaTime() const { return tickDtFloat_; } 51 long getDeltaTimeMicroseconds() const { return tickDt_; } 89 /// Returns the timespan in seconds between the last two calls to capture() 90 float getDeltaTime() const 91 { return tickDtFloat_; } 92 /// Returns the timespan in microseconds between the last two calls to capture() 93 long getDeltaTimeMicroseconds() const 94 { return tickDt_; } 52 95 96 /** Returns the current real time in microseconds 97 @note 98 This is especially useful to measure execution times because of the 99 high precision. 100 */ 53 101 unsigned long long getRealMicroseconds() const; 54 102 55 103 private: 104 /// Undefined 56 105 Clock(const Clock& instance); 57 106 58 Ogre::Timer* timer_; 59 unsigned long long tickTime_; 60 long tickDt_; 61 float tickDtFloat_; 107 Ogre::Timer* timer_; ///< Ogre timer object 108 unsigned long long tickTime_; ///< Currently captured time 109 long tickDt_; ///< Delta time in microseconds (cache value) 110 float tickDtFloat_; ///< Delta time in seconds (cache value) 62 111 }; 63 112 } -
code/trunk/src/libraries/util/Convert.cc
r7163 r7401 32 32 namespace orxonox 33 33 { 34 //template <class FromType, class ToType>35 34 bool ConverterExplicit<std::string, bool>::convert(bool* output, const std::string& input) 36 35 { -
code/trunk/src/libraries/util/Convert.h
r7305 r7401 28 28 */ 29 29 30 /*! 31 @file 32 @brief Definition and Implementation of the Convert class. 30 /** 31 @defgroup Convert Conversion functions 32 @ingroup Util 33 */ 34 35 /** Functions that convert values between different types. 36 @file 37 @ingroup Convert 38 @par Usage 39 There are three ways to use the conversions depending on what you need. <br> 40 - For simply converting values without having to know whether the conversion 41 was successful (for instance float --> string), use orxonox::multi_cast 42 which effectively works exactly like static_cast, etc. 43 @code 44 float input = 42.0; 45 std::string output = multi_cast<std::string>(input); 46 @endcode 47 - If you care about whether the conversion was successful, 48 use orxonox::convertValue. 49 @code 50 std::string input("3.4"); 51 float output; 52 bool success = convertValue(&output, input); 53 @endcode 54 - If you care about success and if you can also feed a fallback value, 55 use orxonox::convertValue. 56 @code 57 std::string input("3.4"); 58 float output; 59 bool success = convertValue(&output, input, 0.0); 60 @endcode 61 - If success doesn't matter but you can feed a fallback value, 62 use orxonox::getConvertedValue. 63 @code 64 std::string input("3.4"); 65 float output = getConvertedValue(input, 0.0); 66 @endcode 67 @details 68 The back end of these functions are the actual implementations for the 69 specific conversions, for instance from Ogre::Vector3 to std::string and 70 vice versa. Some of them also use the iostream operators. <br> 71 The real deal is evaluating which function is needed for a conversion based 72 on the input and output type. But there are lots of catches in conjunction 73 with templates which explains why there are so many functions in this file. 74 <br> <br> 75 @par Search Order 76 Finding the right function is governed by priority rules: <br> 77 -# (Partial) template specialisation of orxonox::ConverterExplicit::convert() 78 -# An implicit conversion. This includes 'FooBar' to 'int' if FooBar 79 defines operator int() or float(). 80 -# Global or member operators for iostream when converting from or 81 to std::string (and FROM const char*) 82 -# (Partial) template specialisation of orxonox::ConverterFallback::convert() 83 -# Fallback function that displays "Could not convert value" with type 84 information obtained from typeid(). 85 @par Implementing conversion functions 86 To do that you probably need to know a thing or two about the types 87 involved. So, get ready with that. <br> 88 Usually the best way to do it is specialising of the orxonox::ConverterFallback 89 template, like this: 90 @code 91 template <> 92 struct _UtilExport ConverterFallback<std::string, MyType> 93 { 94 static bool convert(MyType* output, const std::string& input) 95 { 96 ... 97 return success; 98 } 99 }; 100 @endcode 101 This piece of code converts an std::string to MyType and returns whether the 102 conversion was successful. You can also use partial specialisation.<br> 103 The advantage with orxonox::ConverterFallback is that it has a low priority 104 meaning that when there is an implicit conversion or an iostream method, that 105 comes first and you don't have to deal with it (and the accompanying 106 function call ambiguity). <br> 107 However sometimes you would like to explicitely replace such a conversion. 108 That's where orxonox::ConverterExplicit comes in handy (for instance we 109 replaced the operator << conversions for Ogre::VectorX with our own functions). 110 @note 111 There has to be an exact type match when using template specialisations. <br> 112 Template specialisations can be defined after including this file. 113 But any implicit cast function or iostream operator has to be included 114 in this file! 115 @par Understanding the Code 116 In order to understand how the templates work, it is probably best to study 117 the functions in order of calling. There are lots of comments explaining 118 what happens, but you'll need to understand a deal about partial template 119 specialisation and function headers are matched in C++. 33 120 */ 34 121 … … 46 133 #include "ImplicitConversion.h" 47 134 48 ////////////////////////////////////49 //// ACTUAL CONVERSION SEQUENCE ////50 ////////////////////////////////////51 /*52 There is a distinct priority when choosing the right conversion function:53 Overwrite:54 1. (Partial) template specialisation of ConverterExplicit::convert()55 Fallbacks:56 2. Any possible implicit conversion. This includes 'FooBar' --> 'int' if FooBar defines operator float().57 3. Global or member operators for stringstream when converting from or to std::string (or FROM const char*)58 4. (Partial) template specialisation of ConverterFallback::convert()59 5. Function that simply displays "Could not convert value" with type information obtained from typeid().60 61 Notes:62 There has to be an exact type match when using template specialisations.63 Template specialisations can be defined after including this file. Any implicit cast function or iostream64 operator has to be declared BEFORE this file gets parsed.65 66 Defining your own functions:67 There are obviously 4 ways to specify a user defined conversion. What should you use?68 69 Usually, ConverterFallback fits quite well. You won't have to deal with the conversion from70 'MyClass' to 'MyClass' by using another explicit template specialisation to avoid ambiguities.71 72 However if you want to overwrite an implicit conversion or an iostream operator, you really need to73 make use of ConverterExplicit. We have to do this for the Ogre classes for instance because they74 define stream operators we don't particulary like.75 */76 77 135 namespace orxonox 78 136 { … … 81 139 /////////////////// 82 140 83 // Default template. No conversion available at all.141 /// Default template. No conversion available at all. 84 142 template <class FromType, class ToType> 85 143 struct ConverterFallback … … 93 151 }; 94 152 95 // If all else fails, try a dynamic_cast for pointer types.153 /// If all else fails, try a dynamic_cast for pointer types. 96 154 template <class FromType, class ToType> 97 155 struct ConverterFallback<FromType*, ToType*> … … 109 167 } 110 168 }; 111 112 ////////////113 // upcast //114 ////////////115 namespace detail116 {117 // perform a static cast if ToType is a base of FromType118 template<class ToType, class FromType>119 FORCEINLINE ToType upcast(FromType input, Loki::Int2Type<true>)120 {121 return static_cast<ToType>(input);122 }123 124 // return zero if ToType is not a base of FromType125 template<class ToType, class FromType>126 FORCEINLINE ToType upcast(FromType input, Loki::Int2Type<false>)127 {128 return 0;129 }130 }131 132 // performs an upcast if ToType is a base of FromType, returns zero otherwise133 template <class ToType, class FromType>134 FORCEINLINE ToType upcast(FromType input)135 {136 enum { probe = ImplicitConversion<FromType, ToType>::exists };137 return detail::upcast<ToType, FromType>(input, Loki::Int2Type<probe>());138 }139 169 } 140 170 … … 144 174 /////////////////////// 145 175 146 // Default template for stringstream 176 /** Fallback template for stringstream 177 @details 178 Neither FromType nor ToType was std::string, therefore 179 delegate to orxonox::ConverterFallback 180 */ 147 181 template <class FromType, class ToType> 148 182 struct ConverterStringStream … … 159 193 ///////////// 160 194 195 /// Extra namespace to avoid exposing the iostream operators in it 161 196 namespace fallbackTemplates 162 197 { 198 /// Fallback operator <<() (delegates to orxonox::ConverterFallback) 163 199 template <class FromType> 164 200 FORCEINLINE bool operator <<(std::ostream& outstream, const FromType& input) … … 175 211 } 176 212 177 // template that evaluates whether we can convert to std::string via ostringstream213 /// Template that evaluates whether we can convert to std::string via ostringstream 178 214 template <class FromType> 179 215 struct ConverterStringStream<FromType, std::string> … … 182 218 { 183 219 using namespace fallbackTemplates; 184 // this operator call only chooses fallbackTemplates::operator<< if there's no other fitting function 220 // this operator call only chooses fallbackTemplates::operator<<() 221 // if there's no other fitting function 185 222 std::ostringstream oss; 223 // Note: std::ostream has operator!() to tell whether any error flag was set 186 224 if (oss << input) 187 225 { … … 201 239 namespace fallbackTemplates 202 240 { 241 /// Fallback operator >>() (delegates to orxonox::ConverterFallback) 203 242 template <class ToType> 204 243 FORCEINLINE bool operator >>(std::istream& instream, ToType& output) 205 244 { 206 return orxonox::ConverterFallback<std::string, ToType>207 ::convert(&output, static_cast<std::istringstream&>(instream).str());245 std::string input(static_cast<std::istringstream&>(instream).str()); 246 return orxonox::ConverterFallback<std::string, ToType>::convert(&output, input); 208 247 } 209 248 } 210 249 211 // template that evaluates whether we can convert from std::string via ostringstream250 /// Template that evaluates whether we can convert from std::string via istringstream 212 251 template <class ToType> 213 252 struct ConverterStringStream<std::string, ToType> … … 216 255 { 217 256 using namespace fallbackTemplates; 257 // this operator call chooses fallbackTemplates::operator>>() 258 // only if there's no other fitting function 218 259 std::istringstream iss(input); 219 // this operator call only chooses fallbackTemplates::operator>> if there's no other fitting function260 // Note: std::istream has operator!() to tell whether any error flag was set 220 261 if (iss >> (*output)) 221 262 { … … 229 270 namespace orxonox 230 271 { 231 232 272 /////////////////// 233 273 // Implicit Cast // 234 274 /////////////////// 235 275 236 // implicit cast not possible, try stringstream conversion next276 /// %Template delegates to ::ConverterStringStream 237 277 template <class FromType, class ToType> 238 278 FORCEINLINE bool convertImplicitely(ToType* output, const FromType& input, Loki::Int2Type<false>) … … 241 281 } 242 282 243 // We can cast implicitely283 /// Makes an implicit cast from \a FromType to \a ToType 244 284 template <class FromType, class ToType> 245 285 FORCEINLINE bool convertImplicitely(ToType* output, const FromType& input, Loki::Int2Type<true>) … … 254 294 //////////////////////////////// 255 295 256 // Default template if no specialisation is available 296 /** Default template if no orxonox::ConverterExplicit is available 297 @details 298 Evaluates whether \a FromType can be implicitly converted to \a ToType 299 by the use the ImplicitConversion magic. 300 */ 257 301 template <class FromType, class ToType> 258 302 struct ConverterExplicit … … 261 305 FORCEINLINE static bool convert(ToType* output, const FromType& input) 262 306 { 263 // Try implict cast and probe first. If a simple cast is not possible, it will not compile 264 // We therefore have to out source it into another template function 307 // Use the probe's value to delegate to the right function 265 308 return convertImplicitely(output, input, Loki::Int2Type<probe>()); 266 309 } … … 275 318 @brief 276 319 Converts any value to any other as long as there exists a conversion. 320 @details 277 321 Otherwise, the conversion will generate a runtime warning and return false. 278 For information about the different conversion methods (user defined too), see the section 279 'Actual conversion sequence' in this file above. 322 @see Convert.h 323 @param output 324 A pointer to the variable where the converted value will be stored 325 @param input 326 The original value 280 327 */ 281 328 template <class FromType, class ToType> … … 291 338 Converts any value to any other as long as there exists a conversion. 292 339 Otherwise, the conversion will generate a runtime warning and return false. 293 For information about the different conversion methods (user defined too), see the section 294 'Actual conversion sequence' in this file above. 295 If the conversion doesn't succeed, 'fallback' is written to '*output'. 340 If the conversion doesn't succeed, \a fallback is written to \a output. 341 @see Convert.h 342 @param output 343 A pointer to the variable where the converted value will be stored 344 @param input 345 The original value 296 346 @param fallback 297 347 A default value that gets written to '*output' if there is no conversion. … … 309 359 } 310 360 311 // Directly returns the converted value, even if the conversion was not successful.361 /// Directly returns the converted value, but uses the fallback on failure. @see convertValue 312 362 template<class FromType, class ToType> 313 FORCEINLINE ToType getConvertedValue(const FromType& input) 363 FORCEINLINE ToType getConvertedValue(const FromType& input, const ToType& fallback) 364 { 365 ToType output; 366 convertValue(&output, input, fallback); 367 return output; 368 } 369 370 /** 371 @brief 372 Converts any value to any other as long as there exists a conversion. 373 @details 374 Use exactly the way you use static_cast, etc. <br> 375 A failed conversion will return a default instance of \a ToType 376 (possibly uninitialised) 377 @see Convert.h 378 @param input 379 The original value 380 */ 381 template<class ToType, class FromType> 382 FORCEINLINE ToType multi_cast(const FromType& input) 314 383 { 315 384 ToType output; … … 318 387 } 319 388 320 // Directly returns the converted value, but uses the fallback on failure.321 template<class FromType, class ToType>322 FORCEINLINE ToType getConvertedValue(const FromType& input, const ToType& fallback)323 {324 ToType output;325 convertValue(&output, input, fallback);326 return output;327 }328 329 // Like getConvertedValue, but the template argument order is in reverse.330 // That means you can call it exactly like static_cast<ToType>(fromTypeValue).331 template<class ToType, class FromType>332 FORCEINLINE ToType multi_cast(const FromType& input)333 {334 ToType output;335 convertValue(&output, input);336 return output;337 }338 339 389 //////////////////////////////// 340 390 // Special string conversions // 341 391 //////////////////////////////// 342 392 343 // Delegateconversion from const char* to std::string393 /// Delegates conversion from const char* to std::string 344 394 template <class ToType> 345 395 struct ConverterExplicit<const char*, ToType> … … 351 401 }; 352 402 353 // These conversions would exhibit ambiguous << or >> operators when using stringstream403 /// Conversion would exhibit ambiguous << or >> operators when using iostream 354 404 template <> 355 405 struct ConverterExplicit<char, std::string> … … 361 411 } 362 412 }; 413 /// Conversion would exhibit ambiguous << or >> operators when using iostream 363 414 template <> 364 415 struct ConverterExplicit<unsigned char, std::string> … … 370 421 } 371 422 }; 423 /// Conversion would exhibit ambiguous << or >> operators when using iostream 372 424 template <> 373 425 struct ConverterExplicit<std::string, char> … … 382 434 } 383 435 }; 436 /// Conversion would exhibit ambiguous << or >> operators when using iostream 384 437 template <> 385 438 struct ConverterExplicit<std::string, unsigned char> … … 396 449 397 450 398 // bool to std::string451 /// Conversion from bool to std::string 399 452 template <> 400 453 struct ConverterExplicit<bool, std::string> … … 410 463 }; 411 464 412 // std::string to bool465 /// Conversion from std::string to bool 413 466 template <> 414 467 struct _UtilExport ConverterExplicit<std::string, bool> -
code/trunk/src/libraries/util/Debug.h
r6443 r7401 29 29 30 30 /** 31 @defgroup COUT COUT(x) output macro 32 @ingroup Util 33 */ 34 35 /** 31 36 @file 37 @ingroup COUT 32 38 @brief 33 Handles different output-levels of errors, warnings, infos and debug information.39 Handles different output-levels of errors, warnings, infos, and debug information. 34 40 35 The COUT(level) macro acts like std::cout, but the output is only performed if the given41 The COUT(level) macro acts like @c std::cout, but the output is only performed if the given 36 42 level is <= the soft debug level. 37 43 … … 39 45 - The hard debug level is used during compile time. It describes the highest allowed output level. 40 46 - The soft debug level is used during runtime and is the maximum of the three configurable 41 output-levels for console, log file and in game shell.47 output-levels for console, log file, and in game shell. 42 48 43 49 The separation between the three devices is done by the OutputHandler. 44 50 51 @anchor COUTlevels 45 52 Possible levels are: 46 0: Very important output47 1: Errors48 2: Warnings49 3: Information50 4: Debug information51 5: More debug information52 6: Crazy debug information53 - 0: Very important output 54 - 1: Errors 55 - 2: Warnings 56 - 3: Information 57 - 4: Debug information 58 - 5: More debug information 59 - 6: Crazy debug information 53 60 54 @example 61 Example: 62 @code 55 63 COUT(0) << "Very important output" << std::endl; 56 64 COUT(1) << "Error: Something went wrong!" << std::endl; … … 58 66 COUT(3) << "Info: It's Monday" << std::endl; 59 67 COUT(4) << "Debug: x is 1.23456" << std::endl; 68 @endcode 60 69 */ 61 70 … … 90 99 /** 91 100 @brief 92 Logs text output: use exactly like std::cout, but specify an output 93 level as argument. 94 @details 95 (a > b ? 0 : c << "text") is equivalent to (a > b ? 0 : (c << "text")) 96 where (a > b ? 0 : ) stands for COUT(x). This should explain how 101 Logs text output: You can use COUT(level) exactly like @c std::cout, but you have to specify an output level as argument. 102 @param level 103 The level of the following output (passed with <tt><< "text"</tt>). Lower levels are more important. See @ref COUTlevels "the description above" for a list of possible output levels. 104 105 Example: 106 @code 107 COUT(3) << "Some info" << std::endl; // Output with level 3 108 @endcode 109 @note 110 <tt>(a > b ? 0 : c << "text")</tt> is equivalent to <tt>(a > b ? 0 : (c << "text")</tt> 111 where <tt>(a > b ? 0 : )</tt> stands for COUT(x). This should explain how 97 112 this macro magic can possibly even work ;) 98 @example 99 COUT(3) << "Some info" << std::endl; 100 @note 101 The ? : operator requires both possible results to have the type of 113 @remarks 114 The <tt>? :</tt> operator requires both possible results to have the type of 102 115 the first. This is achieved by the int conversion operator dummy 103 in the OutputHandler.116 in the @ref orxonox::OutputHandler. 104 117 */ 105 118 #define COUT(level) \ -
code/trunk/src/libraries/util/Exception.cc
r7174 r7401 53 53 { } 54 54 55 /**56 @remarks57 The composed full description gets stored to fullDescription_. But for compliance58 with std::exception, this method has to be const. Hence fullDescription_ is declared59 as mutable.60 */61 55 const std::string& Exception::getFullDescription() const 62 56 { … … 89 83 } 90 84 91 //! Returns the error description92 85 const char* Exception::what() const throw() 93 86 { -
code/trunk/src/libraries/util/Exception.h
r6417 r7401 28 28 29 29 /** 30 @defgroup ExceptionAssertion Exceptions and assertions 31 @ingroup Util 32 */ 33 34 /** 30 35 @file 36 @ingroup ExceptionAssertion 31 37 @brief 32 38 Declaration of facilities to handle exceptions. 39 @details 40 Any exception thrown should inherit from orxonox::Exception. There is a macro 41 \ref CREATE_ORXONOX_EXCEPTION to create a new exception (you can find a list of 42 available exceptions in the docs of this file). <br> 43 Throwing exception is also very simple: 44 @code 45 ThrowException(General, "Something went wrong"); 46 @endcode 47 (\c General is a type of exception, see docs of this file) <br> 48 The exception will automatically contain information about file, line number 49 and function name it occurred in. <br><br> 50 There is also some magic you can do for numbers, etc.: 51 @code 52 ThrowException(General, "Error code: " << myInt << ". more info..."); 53 @endcode 54 It works with an std::ostringstream, so you can feed it all sorts of values. 33 55 */ 34 56 … … 45 67 namespace orxonox 46 68 { 47 /** 48 @brief 49 Base class for all exceptions (derived from std::exception). 69 /** Base class for all exceptions (derived from std::exception). 50 70 @details 51 71 This class provides support for information about the file, the line 52 and the function the error occured. 72 and the function the error occurred. 73 @see Exception.h 53 74 */ 54 75 class _UtilExport Exception : public std::exception … … 60 81 @param description 61 82 Exception description as string. This message is supposed to help developers! 83 @param lineNumber 84 The number of the code-line in which the exception occurred 85 @param filename 86 The file in which the exception occurred 87 @param functionName 88 The function in which the exception occurred 62 89 */ 63 90 Exception(const std::string& description, unsigned int lineNumber, … … 68 95 //! Needed for compatibility with std::exception 69 96 virtual ~Exception() throw() { } 97 //! Returns the error description 70 98 const char* what() const throw(); 71 99 72 //! Returns a full description with type, line, file and function 100 /** Returns a full description with type, line, file and function 101 @remarks 102 The composed full description gets stored to fullDescription_. But for compliance 103 with std::exception, this method has to be const. Hence fullDescription_ is declared 104 as mutable. 105 */ 73 106 virtual const std::string& getFullDescription() const; 74 107 //! Returns the string name of the exception type … … 101 134 }; 102 135 103 //! Creates a new type of exception that inherits from tracker::Exception136 //! Creates a new type of exception that inherits from orxonox::Exception 104 137 #define CREATE_ORXONOX_EXCEPTION(ExceptionName) \ 105 138 class ExceptionName##Exception : public Exception \ … … 123 156 // Creates all possible exception types. 124 157 // If you want to add a new type, simply copy and adjust a new line here. 125 #ifndef DOXYGEN_SHOULD_SKIP_THIS126 158 CREATE_ORXONOX_EXCEPTION(General); 127 159 CREATE_ORXONOX_EXCEPTION(FileNotFound); … … 136 168 CREATE_ORXONOX_EXCEPTION(NoGraphics); 137 169 CREATE_ORXONOX_EXCEPTION(AbortLoading); 138 #endif139 170 140 /** 141 @brief 142 Helper function that forwards an exception and displays the message. 171 /** Helper function that forwards an exception and displays the message. 143 172 @details 144 173 This is necessary because only when using 'throw' the objects storage is managed. … … 152 181 } 153 182 154 /** 155 @brief 156 Throws an exception and logs a message beforehand. 183 /** Throws an exception and logs a message beforehand. 157 184 @param type 158 185 Type of the exception as literal (General, Initialisation, etc.) 159 186 @param description 160 187 Exception description as string 188 @see Exception.h 161 189 */ 162 190 #define ThrowException(type, description) \ -
code/trunk/src/libraries/util/ExprParser.h
r6417 r7401 28 28 29 29 /** 30 @file 31 @brief Declaration of FloatParser 30 @file 31 @ingroup Util 32 @brief Declaration of FloatParser 32 33 */ 33 34 … … 42 43 namespace orxonox 43 44 { 45 /** Parser for expressions like \c "3 * cos(5 + 4) / a" where \a a is a predeclared 46 variable. 47 @par Usage 48 Using it is rather simple: 49 @code 50 std::string str("3 + 4"); 51 ExprParser expr; 52 expr.parse(str); 53 if (expr.getSuccess()) 54 { 55 if (!expr.getRemains().empty()) 56 { 57 COUT(2) << "Warning: Expression could not be parsed to the end! Remains: '" << expr.getRemains() << '\'' << std::endl; 58 } 59 double result = expr.getResult(); 60 } 61 else 62 COUT(1) << "Error: Cannot calculate expression: Parse error." << std::endl; 63 @endcode 64 getRemains() returns the expression after what could be parsed. For instance 65 \c "2*3 text" will return \c "text" as remains. 66 @details 67 The implementation of this class is really old and sort of a trial for 68 a first C++ class by Reto. That explains why it looks more like C than 69 C++... Also some of the variable names are in German. <br> 70 Explaining how it works exactly is probably not possible anymore, but it 71 is based on recursively parsing the expression character by character. 72 That much I can remember. 73 @par Functions, operators and variables supported 74 - Variables: 75 - e 76 - pi 77 - Functions: 78 - sin, asin, sinh, asinh 79 - cos, acos, cosh, acosh 80 - tan, atan, tanh, atanh 81 - int, floor, ceil, abs, sign 82 - pow, sqrt, exp, ln, log 83 - mod, div 84 - min, max 85 - radians, degrees 86 - Operators: 87 - +, -, ! (unary) 88 - +, -, *, /, %, ^, |, &, !, <, >, !=, <=, >=, = 89 @note 90 Operators may not be very consistent with C++ rules, but using the class 91 for plus and minus should be perfectly ok. 92 */ 44 93 class _UtilExport ExprParser 45 94 { -
code/trunk/src/libraries/util/ImplicitConversion.h
r7305 r7401 29 29 /** 30 30 @file 31 @ingroup Util 31 32 @brief Declaration of various helper templates. 32 33 */ -
code/trunk/src/libraries/util/Math.cc
r7284 r7401 91 91 @param mydirection My viewing direction 92 92 @param otherposition The position of the other object 93 @return The angle 94 95 @example96 If the other object is exactly in front of me, the function returns 0.97 If the other object is exactly behind me, the function returns pi.98 If the other object is exactly right/left to me (or above/below), the function returns pi/2.93 @return The angle in radian 94 95 Examples: 96 - If the other object is exactly in front of me, the function returns 0. 97 - If the other object is exactly behind me, the function returns pi. 98 - If the other object is exactly right/left to me (or above/below), the function returns pi/2. 99 99 */ 100 100 float getAngle(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& otherposition) … … 116 116 @return The viewing direction 117 117 118 @example119 If the other object is exactly in front of me, the function returns Vector2(0, 0).120 If the other object is exactly at my left, the function returns Vector2(-1, 0).121 If the other object is exactly at my right, the function returns Vector2(1, 0).122 If the other object is only a bit at my right, the function still returns Vector2(1, 0).123 If the other object is exactly above me, the function returns Vector2(0, 1).118 Examples: 119 - If the other object is exactly in front of me, the function returns <tt>Vector2(0, 0)</tt>. 120 - If the other object is exactly at my left, the function returns <tt>Vector2(-1, 0)</tt>. 121 - If the other object is exactly at my right, the function returns <tt>Vector2(1, 0)</tt>. 122 - If the other object is only a bit at my right, the function still returns <tt>Vector2(1, 0)</tt>. 123 - If the other object is exactly above me, the function returns <tt>Vector2(0, 1)</tt>. 124 124 */ 125 125 orxonox::Vector2 get2DViewdirection(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition) … … 156 156 @return The viewing direction 157 157 158 @example159 If the other object is exactly in front of me, the function returns Vector2(0, 0).160 If the other object is exactly at my left, the function returns Vector2(-0.5, 0).161 If the other object is exactly at my right, the function returns Vector2(0.5, 0).162 If the other object is only a bit at my right, the function still returns Vector2(0.01, 0).163 If the other object is exactly above me, the function returns Vector2(0, 0.5).158 Examples: 159 - If the other object is exactly in front of me, the function returns <tt>Vector2(0, 0)</tt>. 160 - If the other object is exactly at my left, the function returns <tt>Vector2(-0.5, 0)</tt>. 161 - If the other object is exactly at my right, the function returns <tt>Vector2(0.5, 0)</tt>. 162 - If the other object is only a bit at my right, the function still returns <tt>Vector2(0.01, 0)</tt>. 163 - If the other object is exactly above me, the function returns <tt>Vector2(0, 0.5)</tt>. 164 164 */ 165 165 orxonox::Vector2 get2DViewcoordinates(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition) … … 220 220 } 221 221 222 /** 223 @brief Returns a unique number. This function will never return the same value twice. 224 */ 222 225 unsigned long getUniqueNumber() 223 226 { -
code/trunk/src/libraries/util/Math.h
r7184 r7401 28 28 29 29 /** 30 @defgroup Math Mathematical functions 31 @ingroup Util 32 */ 33 34 /** 30 35 @file 36 @ingroup Math 31 37 @brief Declaration and implementation of several math-functions, typedefs of some Ogre::Math classes to the orxonox namespace. 32 38 */ … … 62 68 namespace math 63 69 { 64 const float pi = 3.14159265f; 65 const float pi_2 = 1.57079633f; 66 const float pi_4 = 7.85398163e-1f; 67 const float e = 2.71828183f; 68 const float sqrt2 = 1.41421356f; 69 const float sqrt2_2 = 7.07106781e-1f; 70 71 const double pi_d = 3.14159265358979324; 72 const double pi_2_d = 1.57079632679489662; 73 const double pi_4_d = 7.85398163397448310e-1; 74 const double e_d = 2.71828182845904524; 75 const double sqrt2_d = 1.41421356237309505; 76 const double sqrt2_2_d = 7.07106781186547524e-1; 70 const float pi = 3.14159265f; ///< PI 71 const float pi_2 = 1.57079633f; ///< PI / 2 72 const float pi_4 = 7.85398163e-1f; ///< PI / 4 73 const float e = 2.71828183f; ///< e 74 const float sqrt2 = 1.41421356f; ///< sqrt(2) 75 const float sqrt2_2 = 7.07106781e-1f; ///< sqrt(2) / 2 76 77 const double pi_d = 3.14159265358979324; ///< PI (double) 78 const double pi_2_d = 1.57079632679489662; ///< PI / 2 (double) 79 const double pi_4_d = 7.85398163397448310e-1; ///< PI / 4 (double) 80 const double e_d = 2.71828182845904524; ///< e (double) 81 const double sqrt2_d = 1.41421356237309505; ///< sqrt(2) (double) 82 const double sqrt2_2_d = 7.07106781186547524e-1; ///< sqrt(2) / 2 (double) 77 83 } 78 84 … … 101 107 102 108 /** 103 @brief Keeps a value between a lower and an upper limit. 109 @brief Keeps a value between a lower and an upper limit. Values beyond these limits are limited to either @a min or @a max. 104 110 @param x The value 105 111 @param min The lower limit … … 119 125 120 126 /** 121 @brief Returns the square value (x^2).127 @brief Returns the squared value (x^2). 122 128 */ 123 129 template <typename T> … … 128 134 129 135 /** 130 @brief Returns the cube value (x^3).136 @brief Returns the cubed value (x^3). 131 137 */ 132 138 template <typename T> … … 137 143 138 144 /** 139 @brief Rounds the value .145 @brief Rounds the value to the nearest integer. 140 146 */ 141 147 template <typename T> … … 149 155 @param x The value 150 156 @param max The operand 157 158 The built in modulo operator % yields a strange behavior with negative values. 159 This function corrects this - the result is guaranteed to lie always between 160 zero and (max-1). 161 162 Example: 163 @code 164 int var = 11 % 10; // 1 165 int var = -1 % 10; // -1 166 167 int var = mod(11, 10); // 1 168 int var = mod(-1, 10); // 9 169 @endcode 151 170 */ 152 171 template <typename T> … … 159 178 } 160 179 180 /** 181 @brief Returns a "zero" value for the given type. 182 @note This is the default template of the zeroise() function. The template is spezialized for each supported type. 183 184 The exact return value of the function depends on the type. For @c int this is 0, 185 for @c float it's 0.0f. For a @c std::string the function returns "" and for 186 @c Vector3 you get <tt>Vector3(0, 0, 0)</tt>. 187 */ 161 188 template <typename T> 162 189 inline T zeroise() … … 192 219 template <> inline orxonox::Quaternion zeroise<orxonox::Quaternion>() { return orxonox::Quaternion (0, 0, 0, 0); } 193 220 194 //! Provides zero value symbols that can be returned as reference 221 /** 222 @brief Provides zero value symbols that can be returned as reference 223 @see zeroise() 224 */ 195 225 template <typename T> 196 226 struct NilValue … … 207 237 /** 208 238 @brief Interpolates between two values for a time between 0 and 1. 209 @param time The time is a value between 0 and 1 - the function returns start if time is 0 and end if time is 1 and interpolates iftime is between 0 and 1.210 @param start The value at time = 0211 @param end The value at time = 1212 @return The interpolat ionat a given time239 @param time The time is a value between 0 and 1 - the function returns @a start if @a time is 0, @a end if @a time is 1, and interpolates if @a time is between 0 and 1. 240 @param start The value at @a time = 0 241 @param end The value at @a time = 1 242 @return The interpolated value at a given time 213 243 */ 214 244 template <typename T> … … 220 250 /** 221 251 @brief Interpolates smoothly between two values for a time between 0 and 1. The function starts slowly, increases faster and stops slowly again. 222 @param time The time is a value between 0 and 1 - the function returns start if time is 0 and end if time is 1 and interpolates iftime is between 0 and 1.223 @param start The value at time = 0224 @param end The value at time = 1225 @return The smoothed interpolationat a given time252 @param time The time is a value between 0 and 1 - the function returns @a start if @a time is 0, @a end if @a time is 1, and interpolates if @a time is between 0 and 1. 253 @param start The value at @a time = 0 254 @param end The value at @a time = 1 255 @return The interpolated value at a given time 226 256 */ 227 257 template <typename T> … … 232 262 233 263 /** 234 @brief Returns a random number between 0 and almost 1: 0 <= rnd < 1.264 @brief Returns a random number between 0 and almost 1: <tt>0 <= rnd < 1</tt>. 235 265 */ 236 266 inline float rnd() … … 240 270 241 271 /** 242 @brief Returns a random number between 0 and almost max: 0 <= rnd < max.272 @brief Returns a random number between 0 and almost @a max: <tt>0 <= rnd < max</tt>. 243 273 @param max The maximum 244 274 */ … … 249 279 250 280 /** 251 @brief Returns a random number between min and almost max: min <= rnd < max.281 @brief Returns a random number between @a min and almost @a max: <tt>min <= rnd < max</tt>. 252 282 @param min The minimum 253 283 @param max The maximum … … 268 298 _UtilExport unsigned long getUniqueNumber(); 269 299 300 /** 301 @brief A Vector class containing two integers @a x and @a y. 302 */ 270 303 class IntVector2 271 304 { … … 277 310 }; 278 311 312 /** 313 @brief A Vector class containing three integers @a x, @a y, and @a z. 314 */ 279 315 class IntVector3 280 316 { -
code/trunk/src/libraries/util/MathConvert.h
r6417 r7401 28 28 29 29 /** 30 @file 31 @brief 32 Math conversion functions. Definitions are in Math.cc 30 @file 31 @ingroup Convert 32 @brief 33 Conversion functions for Math types like Ogre::Vector3 (definitions are in Math.cc) 33 34 */ 34 35 … … 46 47 //////////////////// 47 48 48 // Vector2 to std::string49 /// Ogre::Vector2 to std::string conversion 49 50 template <> 50 51 struct ConverterExplicit<orxonox::Vector2, std::string> … … 62 63 }; 63 64 64 // Vector3 to std::string65 /// Ogre::Vector3 to std::string conversion 65 66 template <> 66 67 struct ConverterExplicit<orxonox::Vector3, std::string> … … 78 79 }; 79 80 80 // Vector4 to std::string81 /// Ogre::Vector4 to std::string conversion 81 82 template <> 82 83 struct ConverterExplicit<orxonox::Vector4, std::string> … … 94 95 }; 95 96 96 // Quaternion to std::string97 /// Ogre::Quaternion to std::string conversion 97 98 template <> 98 99 struct ConverterExplicit<orxonox::Quaternion, std::string> … … 110 111 }; 111 112 112 // ColourValue to std::string113 /// Ogre::ColourValue to std::string conversion 113 114 template <> 114 115 struct ConverterExplicit<orxonox::ColourValue, std::string> … … 131 132 //////////////////// 132 133 133 // std::string to Vector2134 /// std::string to Ogre::Vector2 conversion 134 135 template <> struct _UtilExport ConverterFallback<std::string, orxonox::Vector2> 135 136 { static bool convert(orxonox::Vector2* output, const std::string& input); }; 136 // std::string to Vector3137 /// std::string to Ogre::Vector3 conversion 137 138 template <> struct _UtilExport ConverterFallback<std::string, orxonox::Vector3> 138 139 { static bool convert(orxonox::Vector3* output, const std::string& input); }; 139 // std::string to Vector4140 /// std::string to Ogre::Vector4 conversion 140 141 template <> struct _UtilExport ConverterFallback<std::string, orxonox::Vector4> 141 142 { static bool convert(orxonox::Vector4* output, const std::string& input); }; 142 // std::string to Quaternion143 /// std::string to Ogre::Quaternion conversion 143 144 template <> struct _UtilExport ConverterFallback<std::string, orxonox::Quaternion> 144 145 { static bool convert(orxonox::Quaternion* output, const std::string& input); }; 145 // std::string to ColourValue146 /// std::string to Ogre::ColourValue conversion 146 147 template <> struct _UtilExport ConverterFallback<std::string, orxonox::ColourValue> 147 148 { static bool convert(orxonox::ColourValue* output, const std::string& input); }; … … 152 153 /////////////////////////////// 153 154 154 // From Radian155 /// Delegates conversions from Radian to conversions from float 155 156 template <class ToType> 156 157 struct ConverterFallback<orxonox::Radian, ToType> … … 162 163 }; 163 164 164 // From Degree165 /// Delegates conversions from Degree to conversions from float 165 166 template <class ToType> 166 167 struct ConverterFallback<orxonox::Degree, ToType> … … 172 173 }; 173 174 174 // To Radian175 /// Delegates conversions to Radian to conversions to float 175 176 template <class FromType> 176 177 struct ConverterFallback<FromType, orxonox::Radian> … … 189 190 }; 190 191 191 // To Degree192 /// Delegates conversions to Degree to conversions to float 192 193 template <class FromType> 193 194 struct ConverterFallback<FromType, orxonox::Degree> -
code/trunk/src/libraries/util/MultiType.cc
r5738 r7401 159 159 } 160 160 161 MultiType::operator char() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Char ) ? (static_cast<MT_Value<char> *>(this->value_))->value_ : (*this->value_)) : 0; } / ** @brief Returns the current value, converted to the requested type. */162 MultiType::operator unsigned char() const { return (this->value_) ? ((this->value_->type_ == MT_Type::UnsignedChar ) ? (static_cast<MT_Value<unsigned char> *>(this->value_))->value_ : (*this->value_)) : 0; } / ** @brief Returns the current value, converted to the requested type. */163 MultiType::operator short() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Short ) ? (static_cast<MT_Value<short> *>(this->value_))->value_ : (*this->value_)) : 0; } / ** @brief Returns the current value, converted to the requested type. */164 MultiType::operator unsigned short() const { return (this->value_) ? ((this->value_->type_ == MT_Type::UnsignedShort ) ? (static_cast<MT_Value<unsigned short> *>(this->value_))->value_ : (*this->value_)) : 0; } / ** @brief Returns the current value, converted to the requested type. */165 MultiType::operator int() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Int ) ? (static_cast<MT_Value<int> *>(this->value_))->value_ : (*this->value_)) : 0; } / ** @brief Returns the current value, converted to the requested type. */166 MultiType::operator unsigned int() const { return (this->value_) ? ((this->value_->type_ == MT_Type::UnsignedInt ) ? (static_cast<MT_Value<unsigned int> *>(this->value_))->value_ : (*this->value_)) : 0; } / ** @brief Returns the current value, converted to the requested type. */167 MultiType::operator long() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Long ) ? (static_cast<MT_Value<long> *>(this->value_))->value_ : (*this->value_)) : 0; } / ** @brief Returns the current value, converted to the requested type. */168 MultiType::operator unsigned long() const { return (this->value_) ? ((this->value_->type_ == MT_Type::UnsignedLong ) ? (static_cast<MT_Value<unsigned long> *>(this->value_))->value_ : (*this->value_)) : 0; } / ** @brief Returns the current value, converted to the requested type. */169 MultiType::operator long long() const { return (this->value_) ? ((this->value_->type_ == MT_Type::LongLong ) ? (static_cast<MT_Value<long long> *>(this->value_))->value_ : (*this->value_)) : 0; } / ** @brief Returns the current value, converted to the requested type. */170 MultiType::operator unsigned long long() const { return (this->value_) ? ((this->value_->type_ == MT_Type::UnsignedLongLong) ? (static_cast<MT_Value<unsigned long long> *>(this->value_))->value_ : (*this->value_)) : 0; } / ** @brief Returns the current value, converted to the requested type. */171 MultiType::operator float() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Float ) ? (static_cast<MT_Value<float> *>(this->value_))->value_ : (*this->value_)) : 0; } / ** @brief Returns the current value, converted to the requested type. */172 MultiType::operator double() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Double ) ? (static_cast<MT_Value<double> *>(this->value_))->value_ : (*this->value_)) : 0; } / ** @brief Returns the current value, converted to the requested type. */173 MultiType::operator long double() const { return (this->value_) ? ((this->value_->type_ == MT_Type::LongDouble ) ? (static_cast<MT_Value<long double> *>(this->value_))->value_ : (*this->value_)) : 0; } / ** @brief Returns the current value, converted to the requested type. */174 MultiType::operator bool() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Bool ) ? (static_cast<MT_Value<bool> *>(this->value_))->value_ : (*this->value_)) : 0; } / ** @brief Returns the current value, converted to the requested type. */175 MultiType::operator void*() const { return (this->value_) ? ((this->value_->type_ == MT_Type::VoidPointer ) ? (static_cast<MT_Value<void*> *>(this->value_))->value_ : (*this->value_)) : 0; } / ** @brief Returns the current value, converted to the requested type. */176 MultiType::operator std::string() const { return (this->value_) ? ((this->value_->type_ == MT_Type::String ) ? (static_cast<MT_Value<std::string> *>(this->value_))->value_ : (*this->value_)) : NilValue<std::string>(); } / ** @brief Returns the current value, converted to the requested type. */177 MultiType::operator orxonox::Vector2() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Vector2 ) ? (static_cast<MT_Value<orxonox::Vector2> *>(this->value_))->value_ : (*this->value_)) : NilValue<orxonox::Vector2>(); } / ** @brief Returns the current value, converted to the requested type. */178 MultiType::operator orxonox::Vector3() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Vector3 ) ? (static_cast<MT_Value<orxonox::Vector3> *>(this->value_))->value_ : (*this->value_)) : NilValue<orxonox::Vector3>(); } / ** @brief Returns the current value, converted to the requested type. */179 MultiType::operator orxonox::Vector4() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Vector4 ) ? (static_cast<MT_Value<orxonox::Vector4> *>(this->value_))->value_ : (*this->value_)) : NilValue<orxonox::Vector4>(); } / ** @brief Returns the current value, converted to the requested type. */180 MultiType::operator orxonox::ColourValue() const { return (this->value_) ? ((this->value_->type_ == MT_Type::ColourValue ) ? (static_cast<MT_Value<orxonox::ColourValue>*>(this->value_))->value_ : (*this->value_)) : NilValue<orxonox::ColourValue>(); } / ** @brief Returns the current value, converted to the requested type. */181 MultiType::operator orxonox::Quaternion() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Quaternion ) ? (static_cast<MT_Value<orxonox::Quaternion> *>(this->value_))->value_ : (*this->value_)) : NilValue<orxonox::Quaternion>(); } / ** @brief Returns the current value, converted to the requested type. */182 MultiType::operator orxonox::Radian() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Radian ) ? (static_cast<MT_Value<orxonox::Radian> *>(this->value_))->value_ : (*this->value_)) : NilValue<orxonox::Radian>(); } / ** @brief Returns the current value, converted to the requested type. */183 MultiType::operator orxonox::Degree() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Degree ) ? (static_cast<MT_Value<orxonox::Degree> *>(this->value_))->value_ : (*this->value_)) : NilValue<orxonox::Degree>(); } / ** @brief Returns the current value, converted to the requested type. */184 185 template <> void MultiType::createNewValueContainer(const char& value) { this->value_ = new MT_Value<char> (value, MT_Type::Char ); } / ** @brief Creates a new value container for the given type. */186 template <> void MultiType::createNewValueContainer(const unsigned char& value) { this->value_ = new MT_Value<unsigned char> (value, MT_Type::UnsignedChar ); } / ** @brief Creates a new value container for the given type. */187 template <> void MultiType::createNewValueContainer(const short& value) { this->value_ = new MT_Value<short> (value, MT_Type::Short ); } / ** @brief Creates a new value container for the given type. */188 template <> void MultiType::createNewValueContainer(const unsigned short& value) { this->value_ = new MT_Value<unsigned short> (value, MT_Type::UnsignedShort ); } / ** @brief Creates a new value container for the given type. */189 template <> void MultiType::createNewValueContainer(const int& value) { this->value_ = new MT_Value<int> (value, MT_Type::Int ); } / ** @brief Creates a new value container for the given type. */190 template <> void MultiType::createNewValueContainer(const unsigned int& value) { this->value_ = new MT_Value<unsigned int> (value, MT_Type::UnsignedInt ); } / ** @brief Creates a new value container for the given type. */191 template <> void MultiType::createNewValueContainer(const long& value) { this->value_ = new MT_Value<long> (value, MT_Type::Long ); } / ** @brief Creates a new value container for the given type. */192 template <> void MultiType::createNewValueContainer(const unsigned long& value) { this->value_ = new MT_Value<unsigned long> (value, MT_Type::UnsignedLong ); } / ** @brief Creates a new value container for the given type. */193 template <> void MultiType::createNewValueContainer(const long long& value) { this->value_ = new MT_Value<long long> (value, MT_Type::LongLong ); } / ** @brief Creates a new value container for the given type. */194 template <> void MultiType::createNewValueContainer(const unsigned long long& value) { this->value_ = new MT_Value<unsigned long long> (value, MT_Type::UnsignedLongLong); } / ** @brief Creates a new value container for the given type. */195 template <> void MultiType::createNewValueContainer(const float& value) { this->value_ = new MT_Value<float> (value, MT_Type::Float ); } / ** @brief Creates a new value container for the given type. */196 template <> void MultiType::createNewValueContainer(const double& value) { this->value_ = new MT_Value<double> (value, MT_Type::Double ); } / ** @brief Creates a new value container for the given type. */197 template <> void MultiType::createNewValueContainer(const long double& value) { this->value_ = new MT_Value<long double> (value, MT_Type::LongDouble ); } / ** @brief Creates a new value container for the given type. */198 template <> void MultiType::createNewValueContainer(const bool& value) { this->value_ = new MT_Value<bool> (value, MT_Type::Bool ); } / ** @brief Creates a new value container for the given type. */199 template <> void MultiType::createNewValueContainer( void* const& value) { this->value_ = new MT_Value<void*> (value, MT_Type::VoidPointer ); } / ** @brief Creates a new value container for the given type. */200 template <> void MultiType::createNewValueContainer(const std::string& value) { this->value_ = new MT_Value<std::string> (value, MT_Type::String ); } / ** @brief Creates a new value container for the given type. */201 template <> void MultiType::createNewValueContainer(const orxonox::Vector2& value) { this->value_ = new MT_Value<orxonox::Vector2> (value, MT_Type::Vector2 ); } / ** @brief Creates a new value container for the given type. */202 template <> void MultiType::createNewValueContainer(const orxonox::Vector3& value) { this->value_ = new MT_Value<orxonox::Vector3> (value, MT_Type::Vector3 ); } / ** @brief Creates a new value container for the given type. */203 template <> void MultiType::createNewValueContainer(const orxonox::Vector4& value) { this->value_ = new MT_Value<orxonox::Vector4> (value, MT_Type::Vector4 ); } / ** @brief Creates a new value container for the given type. */204 template <> void MultiType::createNewValueContainer(const orxonox::ColourValue& value) { this->value_ = new MT_Value<orxonox::ColourValue>(value, MT_Type::ColourValue ); } / ** @brief Creates a new value container for the given type. */205 template <> void MultiType::createNewValueContainer(const orxonox::Quaternion& value) { this->value_ = new MT_Value<orxonox::Quaternion> (value, MT_Type::Quaternion ); } / ** @brief Creates a new value container for the given type. */206 template <> void MultiType::createNewValueContainer(const orxonox::Radian& value) { this->value_ = new MT_Value<orxonox::Radian> (value, MT_Type::Radian ); } / ** @brief Creates a new value container for the given type. */207 template <> void MultiType::createNewValueContainer(const orxonox::Degree& value) { this->value_ = new MT_Value<orxonox::Degree> (value, MT_Type::Degree ); } / ** @brief Creates a new value container for the given type. */161 MultiType::operator char() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Char ) ? (static_cast<MT_Value<char> *>(this->value_))->value_ : (*this->value_)) : 0; } ///< Returns the current value, converted to the requested type. 162 MultiType::operator unsigned char() const { return (this->value_) ? ((this->value_->type_ == MT_Type::UnsignedChar ) ? (static_cast<MT_Value<unsigned char> *>(this->value_))->value_ : (*this->value_)) : 0; } ///< Returns the current value, converted to the requested type. 163 MultiType::operator short() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Short ) ? (static_cast<MT_Value<short> *>(this->value_))->value_ : (*this->value_)) : 0; } ///< Returns the current value, converted to the requested type. 164 MultiType::operator unsigned short() const { return (this->value_) ? ((this->value_->type_ == MT_Type::UnsignedShort ) ? (static_cast<MT_Value<unsigned short> *>(this->value_))->value_ : (*this->value_)) : 0; } ///< Returns the current value, converted to the requested type. 165 MultiType::operator int() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Int ) ? (static_cast<MT_Value<int> *>(this->value_))->value_ : (*this->value_)) : 0; } ///< Returns the current value, converted to the requested type. 166 MultiType::operator unsigned int() const { return (this->value_) ? ((this->value_->type_ == MT_Type::UnsignedInt ) ? (static_cast<MT_Value<unsigned int> *>(this->value_))->value_ : (*this->value_)) : 0; } ///< Returns the current value, converted to the requested type. 167 MultiType::operator long() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Long ) ? (static_cast<MT_Value<long> *>(this->value_))->value_ : (*this->value_)) : 0; } ///< Returns the current value, converted to the requested type. 168 MultiType::operator unsigned long() const { return (this->value_) ? ((this->value_->type_ == MT_Type::UnsignedLong ) ? (static_cast<MT_Value<unsigned long> *>(this->value_))->value_ : (*this->value_)) : 0; } ///< Returns the current value, converted to the requested type. 169 MultiType::operator long long() const { return (this->value_) ? ((this->value_->type_ == MT_Type::LongLong ) ? (static_cast<MT_Value<long long> *>(this->value_))->value_ : (*this->value_)) : 0; } ///< Returns the current value, converted to the requested type. 170 MultiType::operator unsigned long long() const { return (this->value_) ? ((this->value_->type_ == MT_Type::UnsignedLongLong) ? (static_cast<MT_Value<unsigned long long> *>(this->value_))->value_ : (*this->value_)) : 0; } ///< Returns the current value, converted to the requested type. 171 MultiType::operator float() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Float ) ? (static_cast<MT_Value<float> *>(this->value_))->value_ : (*this->value_)) : 0; } ///< Returns the current value, converted to the requested type. 172 MultiType::operator double() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Double ) ? (static_cast<MT_Value<double> *>(this->value_))->value_ : (*this->value_)) : 0; } ///< Returns the current value, converted to the requested type. 173 MultiType::operator long double() const { return (this->value_) ? ((this->value_->type_ == MT_Type::LongDouble ) ? (static_cast<MT_Value<long double> *>(this->value_))->value_ : (*this->value_)) : 0; } ///< Returns the current value, converted to the requested type. 174 MultiType::operator bool() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Bool ) ? (static_cast<MT_Value<bool> *>(this->value_))->value_ : (*this->value_)) : 0; } ///< Returns the current value, converted to the requested type. 175 MultiType::operator void*() const { return (this->value_) ? ((this->value_->type_ == MT_Type::VoidPointer ) ? (static_cast<MT_Value<void*> *>(this->value_))->value_ : (*this->value_)) : 0; } ///< Returns the current value, converted to the requested type. 176 MultiType::operator std::string() const { return (this->value_) ? ((this->value_->type_ == MT_Type::String ) ? (static_cast<MT_Value<std::string> *>(this->value_))->value_ : (*this->value_)) : NilValue<std::string>(); } ///< Returns the current value, converted to the requested type. 177 MultiType::operator orxonox::Vector2() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Vector2 ) ? (static_cast<MT_Value<orxonox::Vector2> *>(this->value_))->value_ : (*this->value_)) : NilValue<orxonox::Vector2>(); } ///< Returns the current value, converted to the requested type. 178 MultiType::operator orxonox::Vector3() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Vector3 ) ? (static_cast<MT_Value<orxonox::Vector3> *>(this->value_))->value_ : (*this->value_)) : NilValue<orxonox::Vector3>(); } ///< Returns the current value, converted to the requested type. 179 MultiType::operator orxonox::Vector4() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Vector4 ) ? (static_cast<MT_Value<orxonox::Vector4> *>(this->value_))->value_ : (*this->value_)) : NilValue<orxonox::Vector4>(); } ///< Returns the current value, converted to the requested type. 180 MultiType::operator orxonox::ColourValue() const { return (this->value_) ? ((this->value_->type_ == MT_Type::ColourValue ) ? (static_cast<MT_Value<orxonox::ColourValue>*>(this->value_))->value_ : (*this->value_)) : NilValue<orxonox::ColourValue>(); } ///< Returns the current value, converted to the requested type. 181 MultiType::operator orxonox::Quaternion() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Quaternion ) ? (static_cast<MT_Value<orxonox::Quaternion> *>(this->value_))->value_ : (*this->value_)) : NilValue<orxonox::Quaternion>(); } ///< Returns the current value, converted to the requested type. 182 MultiType::operator orxonox::Radian() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Radian ) ? (static_cast<MT_Value<orxonox::Radian> *>(this->value_))->value_ : (*this->value_)) : NilValue<orxonox::Radian>(); } ///< Returns the current value, converted to the requested type. 183 MultiType::operator orxonox::Degree() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Degree ) ? (static_cast<MT_Value<orxonox::Degree> *>(this->value_))->value_ : (*this->value_)) : NilValue<orxonox::Degree>(); } ///< Returns the current value, converted to the requested type. 184 185 template <> void MultiType::createNewValueContainer(const char& value) { this->value_ = new MT_Value<char> (value, MT_Type::Char ); } ///< Creates a new value container for the given type. 186 template <> void MultiType::createNewValueContainer(const unsigned char& value) { this->value_ = new MT_Value<unsigned char> (value, MT_Type::UnsignedChar ); } ///< Creates a new value container for the given type. 187 template <> void MultiType::createNewValueContainer(const short& value) { this->value_ = new MT_Value<short> (value, MT_Type::Short ); } ///< Creates a new value container for the given type. 188 template <> void MultiType::createNewValueContainer(const unsigned short& value) { this->value_ = new MT_Value<unsigned short> (value, MT_Type::UnsignedShort ); } ///< Creates a new value container for the given type. 189 template <> void MultiType::createNewValueContainer(const int& value) { this->value_ = new MT_Value<int> (value, MT_Type::Int ); } ///< Creates a new value container for the given type. 190 template <> void MultiType::createNewValueContainer(const unsigned int& value) { this->value_ = new MT_Value<unsigned int> (value, MT_Type::UnsignedInt ); } ///< Creates a new value container for the given type. 191 template <> void MultiType::createNewValueContainer(const long& value) { this->value_ = new MT_Value<long> (value, MT_Type::Long ); } ///< Creates a new value container for the given type. 192 template <> void MultiType::createNewValueContainer(const unsigned long& value) { this->value_ = new MT_Value<unsigned long> (value, MT_Type::UnsignedLong ); } ///< Creates a new value container for the given type. 193 template <> void MultiType::createNewValueContainer(const long long& value) { this->value_ = new MT_Value<long long> (value, MT_Type::LongLong ); } ///< Creates a new value container for the given type. 194 template <> void MultiType::createNewValueContainer(const unsigned long long& value) { this->value_ = new MT_Value<unsigned long long> (value, MT_Type::UnsignedLongLong); } ///< Creates a new value container for the given type. 195 template <> void MultiType::createNewValueContainer(const float& value) { this->value_ = new MT_Value<float> (value, MT_Type::Float ); } ///< Creates a new value container for the given type. 196 template <> void MultiType::createNewValueContainer(const double& value) { this->value_ = new MT_Value<double> (value, MT_Type::Double ); } ///< Creates a new value container for the given type. 197 template <> void MultiType::createNewValueContainer(const long double& value) { this->value_ = new MT_Value<long double> (value, MT_Type::LongDouble ); } ///< Creates a new value container for the given type. 198 template <> void MultiType::createNewValueContainer(const bool& value) { this->value_ = new MT_Value<bool> (value, MT_Type::Bool ); } ///< Creates a new value container for the given type. 199 template <> void MultiType::createNewValueContainer( void* const& value) { this->value_ = new MT_Value<void*> (value, MT_Type::VoidPointer ); } ///< Creates a new value container for the given type. 200 template <> void MultiType::createNewValueContainer(const std::string& value) { this->value_ = new MT_Value<std::string> (value, MT_Type::String ); } ///< Creates a new value container for the given type. 201 template <> void MultiType::createNewValueContainer(const orxonox::Vector2& value) { this->value_ = new MT_Value<orxonox::Vector2> (value, MT_Type::Vector2 ); } ///< Creates a new value container for the given type. 202 template <> void MultiType::createNewValueContainer(const orxonox::Vector3& value) { this->value_ = new MT_Value<orxonox::Vector3> (value, MT_Type::Vector3 ); } ///< Creates a new value container for the given type. 203 template <> void MultiType::createNewValueContainer(const orxonox::Vector4& value) { this->value_ = new MT_Value<orxonox::Vector4> (value, MT_Type::Vector4 ); } ///< Creates a new value container for the given type. 204 template <> void MultiType::createNewValueContainer(const orxonox::ColourValue& value) { this->value_ = new MT_Value<orxonox::ColourValue>(value, MT_Type::ColourValue ); } ///< Creates a new value container for the given type. 205 template <> void MultiType::createNewValueContainer(const orxonox::Quaternion& value) { this->value_ = new MT_Value<orxonox::Quaternion> (value, MT_Type::Quaternion ); } ///< Creates a new value container for the given type. 206 template <> void MultiType::createNewValueContainer(const orxonox::Radian& value) { this->value_ = new MT_Value<orxonox::Radian> (value, MT_Type::Radian ); } ///< Creates a new value container for the given type. 207 template <> void MultiType::createNewValueContainer(const orxonox::Degree& value) { this->value_ = new MT_Value<orxonox::Degree> (value, MT_Type::Degree ); } ///< Creates a new value container for the given type. 208 208 } -
code/trunk/src/libraries/util/MultiType.h
r7284 r7401 28 28 29 29 /** 30 @defgroup MultiType MultiType 31 @ingroup Util 32 */ 33 34 /** 30 35 @file 36 @ingroup MultiType 31 37 @brief Declaration of the MultiType and some helper constructs. 32 38 39 @anchor MultiTypeExamples 40 33 41 The MultiType can hold a value of one of the following types: 34 - all primitives 35 - all pointers 36 - st ring42 - all primitives (int, float, bool, etc.) 43 - all pointers (void* and T*) 44 - std::string 37 45 - Vector2, Vector3, Vector4 38 46 - Quaternion … … 40 48 - Radian, Degree 41 49 42 The MultiType has a "type" determined by the first assigned value, either through 43 - the constructor, 44 - the assignment operator= or 45 - setValue(value). 46 If you assign another value of another type, the MultiType keeps "it's" type and 47 converts the new value to this type. 50 The MultiType has an internal "type" determined by the first assigned value, using one of these ways: 51 - @ref orxonox::MultiType::MultiType "The constructor" 52 - The assignment operator= (orxonox::MultiType::operator=()) 53 - @ref orxonox::MultiType::setValue() "setValue(value)" 54 55 If you assign another value of another type, the MultiType keeps "its" type and 56 converts the new value to the old type. 48 57 49 58 If you want to change the type, there are three possibilities: 50 - convert<T>() set's the type to T and converts the currently assigned value51 - setType<T>() set's the type to T and resets the value59 - @ref orxonox::MultiType::convert "convert<T>()" sets the type to T and converts the currently assigned value 60 - @ref orxonox::MultiType::setType "setType<T>()" sets the type to T and resets the value to zero using zeroise<T>() 52 61 - setValue<T>(value) assigns a new value and changes the type to T. 53 62 54 @example 55 MultiType a = 10;; // a has now the type int and the value 10 63 Examples: 64 @code 65 MultiType a = 10; // a has now the type int and the value 10 56 66 a.setValue("3.14"); // a has still the type int and "3.14" gets converted, therefore the value is now 3 57 a.setValue<float>("3.14"); // a has now the type float and "3.14" gets converted to 3.14 58 a.convert<bool>(); // converts 3.14 to bool, which is true67 a.setValue<float>("3.14"); // a has now the type float and "3.14" gets converted to 3.14f 68 a.convert<bool>(); // converts 3.14f to bool, which is true 59 69 a = false; // assigns false, this is equivalent to a.setValue(false) 70 @endcode 71 72 You can pass a MultiType to a function as an argument, even if the argument is 73 not of type MultiType. This works, because the MultiType is automatically converted 74 to the right type. 75 76 Example: 77 @code 78 void myfunction(int value) 79 { 80 COUT(0) << "doubled value is " << (2 * value) << std::endl; 81 } 82 83 MultiType a = "50"; // Note: We assigned a string 84 myfunction(a); // a is converted to int and passed to the function, which prints "value is 100" 85 @endcode 86 87 Note however that it is of course quite expensive to convert values, especially std::string <-> value. 88 So if you can, always assign a value with the right type to avoid conversion. 60 89 61 90 @note … … 127 156 - Radian, Degree 128 157 129 The internal type of a MultiType is determined by the first assigned value, but can be 130 changed by using setType<T>(), convert<T>() or setValue<T>(value). If a value gets assigned 131 the normal way (operator=, setValue(value)), the value gets converted to the current internal 132 type of the MultiType. 158 For more information and some examples see the description @ref MultiTypeExamples "here". 159 160 @see MultiType.h 133 161 */ 134 162 class _UtilExport MultiType … … 153 181 virtual bool assimilate(const MultiType& other) = 0; 154 182 155 / ** @brief Returns the type of the current value. */183 /// Returns the type of the current value. 156 184 const MT_Type::Value& getType() const { return this->type_; } 157 185 158 / ** @brief Checks whether the value is a default one. */186 /// Checks whether the value is a default one. 159 187 bool hasDefaultValue() const { return this->bHasDefaultValue_; } 160 188 … … 237 265 virtual uint8_t getSize() const=0; 238 266 239 MT_Type::Value type_; // !< The type of the current value240 bool bHasDefaultValue_; // !< True if the last conversion wasn't successful267 MT_Type::Value type_; ///< The type of the current value 268 bool bHasDefaultValue_; ///< True if the last conversion wasn't successful 241 269 }; 242 270 243 271 public: 244 inline MultiType() : value_(0) {} / ** @brief Default constructor: Assigns no value and no type. The type will be determined by the first assignment of a value. */245 inline MultiType(const char& value) : value_(0) { this->assignValue(value); } / ** @brief Constructor: Assigns the given value and sets the type. */246 inline MultiType(const unsigned char& value) : value_(0) { this->assignValue(value); } / ** @brief Constructor: Assigns the given value and sets the type. */247 inline MultiType(const short& value) : value_(0) { this->assignValue(value); } / ** @brief Constructor: Assigns the given value and sets the type. */248 inline MultiType(const unsigned short& value) : value_(0) { this->assignValue(value); } / ** @brief Constructor: Assigns the given value and sets the type. */249 inline MultiType(const int& value) : value_(0) { this->assignValue(value); } / ** @brief Constructor: Assigns the given value and sets the type. */250 inline MultiType(const unsigned int& value) : value_(0) { this->assignValue(value); } / ** @brief Constructor: Assigns the given value and sets the type. */251 inline MultiType(const long& value) : value_(0) { this->assignValue(value); } / ** @brief Constructor: Assigns the given value and sets the type. */252 inline MultiType(const unsigned long& value) : value_(0) { this->assignValue(value); } / ** @brief Constructor: Assigns the given value and sets the type. */253 inline MultiType(const long long& value) : value_(0) { this->assignValue(value); } / ** @brief Constructor: Assigns the given value and sets the type. */254 inline MultiType(const unsigned long long& value) : value_(0) { this->assignValue(value); } / ** @brief Constructor: Assigns the given value and sets the type. */255 inline MultiType(const float& value) : value_(0) { this->assignValue(value); } / ** @brief Constructor: Assigns the given value and sets the type. */256 inline MultiType(const double& value) : value_(0) { this->assignValue(value); } / ** @brief Constructor: Assigns the given value and sets the type. */257 inline MultiType(const long double& value) : value_(0) { this->assignValue(value); } / ** @brief Constructor: Assigns the given value and sets the type. */258 inline MultiType(const bool& value) : value_(0) { this->assignValue(value); } / ** @brief Constructor: Assigns the given value and sets the type. */259 inline MultiType( void* const& value) : value_(0) { this->assignValue(value); } / ** @brief Constructor: Assigns the given value and sets the type. */260 inline MultiType(const std::string& value) : value_(0) { this->assignValue(value); } / ** @brief Constructor: Assigns the given value and sets the type. */261 inline MultiType(const orxonox::Vector2& value) : value_(0) { this->assignValue(value); } / ** @brief Constructor: Assigns the given value and sets the type. */262 inline MultiType(const orxonox::Vector3& value) : value_(0) { this->assignValue(value); } / ** @brief Constructor: Assigns the given value and sets the type. */263 inline MultiType(const orxonox::Vector4& value) : value_(0) { this->assignValue(value); } / ** @brief Constructor: Assigns the given value and sets the type. */264 inline MultiType(const orxonox::ColourValue& value) : value_(0) { this->assignValue(value); } / ** @brief Constructor: Assigns the given value and sets the type. */265 inline MultiType(const orxonox::Quaternion& value) : value_(0) { this->assignValue(value); } / ** @brief Constructor: Assigns the given value and sets the type. */266 inline MultiType(const orxonox::Radian& value) : value_(0) { this->assignValue(value); } / ** @brief Constructor: Assigns the given value and sets the type. */267 inline MultiType(const orxonox::Degree& value) : value_(0) { this->assignValue(value); } / ** @brief Constructor: Assigns the given value and sets the type. */268 inline MultiType(const orxonox::mbool& value) : value_(0) { this->assignValue((bool)value); } / ** @brief Constructor: Assigns the given mbool and converts it to bool. */269 inline MultiType(const char* value) : value_(0) { this->setValue(std::string(value)); } / ** @brief Constructor: Converts the char array to a std::string, assigns the value and sets the type. */270 inline MultiType(const MultiType& other) : value_(0) { this->setValue(other); } / ** @brief Copyconstructor: Assigns value and type of the other MultiType. */271 inline MultiType(MT_Type::Value type) : value_(0) { this->setType(type); } / ** @brief Constructor: Sets the type, the next assignment will determine the value. */272 273 / ** @brief Destructor: Deletes the MT_Value. */272 inline MultiType() : value_(0) {} ///< Default constructor: Assigns no value and no type. The type will be determined by the first assignment of a value. 273 inline MultiType(const char& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type. 274 inline MultiType(const unsigned char& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type. 275 inline MultiType(const short& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type. 276 inline MultiType(const unsigned short& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type. 277 inline MultiType(const int& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type. 278 inline MultiType(const unsigned int& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type. 279 inline MultiType(const long& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type. 280 inline MultiType(const unsigned long& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type. 281 inline MultiType(const long long& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type. 282 inline MultiType(const unsigned long long& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type. 283 inline MultiType(const float& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type. 284 inline MultiType(const double& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type. 285 inline MultiType(const long double& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type. 286 inline MultiType(const bool& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type. 287 inline MultiType( void* const& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type. 288 inline MultiType(const std::string& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type. 289 inline MultiType(const orxonox::Vector2& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type. 290 inline MultiType(const orxonox::Vector3& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type. 291 inline MultiType(const orxonox::Vector4& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type. 292 inline MultiType(const orxonox::ColourValue& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type. 293 inline MultiType(const orxonox::Quaternion& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type. 294 inline MultiType(const orxonox::Radian& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type. 295 inline MultiType(const orxonox::Degree& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type. 296 inline MultiType(const orxonox::mbool& value) : value_(0) { this->assignValue((bool)value); } ///< Constructor: Assigns the given mbool and converts it to bool. 297 inline MultiType(const char* value) : value_(0) { this->setValue(std::string(value)); } ///< Constructor: Converts the char array to a std::string, assigns the value and sets the type. 298 inline MultiType(const MultiType& other) : value_(0) { this->setValue(other); } ///< Copyconstructor: Assigns value and type of the other MultiType. 299 inline MultiType(MT_Type::Value type) : value_(0) { this->setType(type); } ///< Constructor: Sets the type, the next assignment will determine the value. 300 301 /// Destructor: Deletes the MT_Value. 274 302 inline ~MultiType() { if (this->value_) { delete this->value_; } } 275 303 276 template <typename V> inline MultiType& operator=(const V& value) { this->setValue(value); return (*this); } / ** @brief Assigns a new value. The value will be converted to the current type of the MultiType. */277 template <typename V> inline MultiType& operator=(V* value) { this->setValue(value); return (*this); } / ** @brief Assigns a pointer. */278 inline MultiType& operator=(const MultiType& other) { this->setValue(other); return (*this); } / ** @brief Assigns the value of the other MultiType and converts it to the current type of the MultiType. */279 inline MultiType& operator=(MT_Type::Value type) { this->setType(type); return (*this); } / ** @brief Resets the value and changes the type. */304 template <typename V> inline MultiType& operator=(const V& value) { this->setValue(value); return (*this); } ///< Assigns a new value. The value will be converted to the current type of the MultiType. 305 template <typename V> inline MultiType& operator=(V* value) { this->setValue(value); return (*this); } ///< Assigns a pointer. 306 inline MultiType& operator=(const MultiType& other) { this->setValue(other); return (*this); } ///< Assigns the value of the other MultiType and converts it to the current type of the MultiType. 307 inline MultiType& operator=(MT_Type::Value type) { this->setType(type); return (*this); } ///< Resets the value and changes the type. 280 308 281 309 inline bool setValue(const char& value); … … 303 331 inline bool setValue(const orxonox::Degree& value); 304 332 inline bool setValue(const char* value); 305 / ** @brief Assigns a pointer. */333 /// Assigns a pointer. 306 334 template <typename V> inline bool setValue(V* value) 307 335 { … … 311 339 return this->assignValue (static_cast<void*>(const_cast<typename Loki::TypeTraits<V>::UnqualifiedType*>(value))); 312 340 } 313 / ** @brief Assigns the value of the other MultiType and converts it to the current type. */341 /// Assigns the value of the other MultiType and converts it to the current type. 314 342 bool setValue(const MultiType& other) { if (this->value_) { return this->value_->assimilate(other); } else { if (other.value_) { this->value_ = other.value_->clone(); } return true; } } 315 / ** @brief Changes the type to T and assigns the new value (which might be of another type than T - it gets converted). */343 /// Changes the type to T and assigns the new value (which might be of another type than T - it gets converted). 316 344 template <typename T, typename V> inline bool setValue(const V& value) { this->setType<T>(); return this->setValue(value); } 317 345 318 346 319 / ** @brief Copies the other MultiType by assigning value and type. */347 /// Copies the other MultiType by assigning value and type. 320 348 inline void copy(const MultiType& other) { if (this == &other) { return; } if (this->value_) { delete this->value_; } this->value_ = (other.value_) ? other.value_->clone() : 0; } 321 349 322 template <typename T> inline bool convert() { return this->setValue<T>((typename Loki::TypeTraits<T>::UnqualifiedReferredType)(*this)); } /** @brief Converts the current value to type T. */ 323 inline bool convert(const MultiType& other) { return this->convert(other.getType()); } /** @brief Converts the current value to the type of the other MultiType. */ 350 /// Converts the current value to type T. 351 template <typename T> inline bool convert() { return this->setValue<T>((typename Loki::TypeTraits<T>::UnqualifiedReferredType)(*this)); } 352 /// Converts the current value to the type of the other MultiType. 353 inline bool convert(const MultiType& other) { return this->convert(other.getType()); } 324 354 bool convert(MT_Type::Value type); 325 355 326 / ** @brief Current content gets deleted. New type is MT_Type::Null */356 /// Current content gets deleted. New type is MT_Type::Null 327 357 inline void reset() { if (this->value_) delete this->value_; this->value_ = 0; } 328 / ** @brief Current content gets overridden with default zero value */358 /// Current content gets overridden with default zero value 329 359 inline void resetValue() { if (this->value_) this->value_->reset(); } 330 360 331 template <typename T> inline void setType() { this->assignValue(typename Loki::TypeTraits<T>::UnqualifiedReferredType()); } /** @brief Resets the value and changes the internal type to T. */ 332 inline void setType(const MultiType& other) { this->setType(other.getType()); } /** @brief Resets the value and changes the internal type to the type of the other MultiType. */ 333 inline void setType(MT_Type::Value type) { this->reset(); this->convert(type); this->resetValue(); } /** @brief Resets the value and changes the internal type to the given type. */ 334 335 /** @brief Returns the current type. */ 361 /// Resets the value and changes the internal type to T. 362 template <typename T> inline void setType() { this->assignValue(typename Loki::TypeTraits<T>::UnqualifiedReferredType()); } 363 /// Resets the value and changes the internal type to the type of the other MultiType. 364 inline void setType(const MultiType& other) { this->setType(other.getType()); } 365 /// Resets the value and changes the internal type to the given type. 366 inline void setType(MT_Type::Value type) { this->reset(); this->convert(type); this->resetValue(); } 367 368 /// Returns the current type. 336 369 inline MT_Type::Value getType() const { return (this->value_) ? this->value_->type_ : MT_Type::Null; } 337 / ** @brief Returns true if the current type equals the given type. */370 /// Returns true if the current type equals the given type. 338 371 inline bool isType(MT_Type::Value type) const { return (this->value_) ? (this->value_->type_ == type) : (type == MT_Type::Null); } 339 / ** @brief Returns true if the current type is T. */372 /// Returns true if the current type is T. 340 373 template <typename T> inline bool isType() const { return false; } // Only works for specialized values - see below 341 374 std::string getTypename() const; 342 375 343 / ** @brief Saves the value of the MT to a bytestream (pointed at by mem) and increases mem pointer by size of MT */376 /// Saves the value of the MT to a bytestream (pointed at by mem) and increases mem pointer by size of MT 344 377 inline void exportData(uint8_t*& mem) const { assert(sizeof(MT_Type::Value)<=8); *static_cast<uint8_t*>(mem) = this->getType(); mem+=sizeof(uint8_t); this->value_->exportData(mem); } 345 / ** @brief Loads the value of the MT from a bytestream (pointed at by mem) and increases mem pointer by size of MT */378 /// Loads the value of the MT from a bytestream (pointed at by mem) and increases mem pointer by size of MT 346 379 inline void importData(uint8_t*& mem) { assert(sizeof(MT_Type::Value)<=8); this->setType(static_cast<MT_Type::Value>(*static_cast<uint8_t*>(mem))); mem+=sizeof(uint8_t); this->value_->importData(mem); } 347 / ** @brief Saves the value of the MT to a bytestream and increases pointer to bytestream by size of MT */380 /// Saves the value of the MT to a bytestream and increases pointer to bytestream by size of MT 348 381 inline uint8_t*& operator << (uint8_t*& mem) { importData(mem); return mem; } 349 / ** @brief Loads the value of the MT to a bytestream and increases pointer to bytestream by size of MT */382 /// Loads the value of the MT to a bytestream and increases pointer to bytestream by size of MT 350 383 inline void operator >> (uint8_t*& mem) const { exportData(mem); } 351 384 inline uint32_t getNetworkSize() const { assert(this->value_); return this->value_->getSize() + sizeof(uint8_t); } 352 385 353 / ** @brief Checks whether the value is a default one. */386 /// Checks whether the value is a default one (assigned after a failed conversion) 354 387 bool hasDefaultValue() const { return this->value_->hasDefaultValue(); } 355 388 356 / ** @brief Checks if the MT contains no value. */389 /// Checks if the MT contains no value. 357 390 bool null() const { return (!this->value_); } 358 391 … … 380 413 operator orxonox::Radian() const; 381 414 operator orxonox::Degree() const; 382 / ** @brief Returns the current value, converted to a T* pointer. */415 /// Returns the current value, converted to a T* pointer. 383 416 template <class T> operator T*() const { return (static_cast<T*>(this->operator void*())); } 384 417 385 inline bool getValue(char* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */386 inline bool getValue(unsigned char* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */387 inline bool getValue(short* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */388 inline bool getValue(unsigned short* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */389 inline bool getValue(int* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */390 inline bool getValue(unsigned int* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */391 inline bool getValue(long* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */392 inline bool getValue(unsigned long* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */393 inline bool getValue(long long* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */394 inline bool getValue(unsigned long long* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */395 inline bool getValue(float* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */396 inline bool getValue(double* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */397 inline bool getValue(long double* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */398 inline bool getValue(bool* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */399 inline bool getValue(void** value) const { if (this->value_) { return this->value_->getValue(value); } return false; } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */400 inline bool getValue(std::string* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */401 inline bool getValue(orxonox::Vector2* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */402 inline bool getValue(orxonox::Vector3* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */403 inline bool getValue(orxonox::Vector4* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */404 inline bool getValue(orxonox::ColourValue* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */405 inline bool getValue(orxonox::Quaternion* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */406 inline bool getValue(orxonox::Radian* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */407 inline bool getValue(orxonox::Degree* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */408 409 inline char getChar() const { return this->operator char(); } / ** @brief Returns the current value, converted to the requested type. */410 inline unsigned char getUnsignedChar() const { return this->operator unsigned char(); } / ** @brief Returns the current value, converted to the requested type. */411 inline short getShort() const { return this->operator short(); } / ** @brief Returns the current value, converted to the requested type. */412 inline unsigned short getUnsignedShort() const { return this->operator unsigned short(); } / ** @brief Returns the current value, converted to the requested type. */413 inline int getInt() const { return this->operator int(); } / ** @brief Returns the current value, converted to the requested type. */414 inline unsigned int getUnsignedInt() const { return this->operator unsigned int(); } / ** @brief Returns the current value, converted to the requested type. */415 inline long getLong() const { return this->operator long(); } / ** @brief Returns the current value, converted to the requested type. */416 inline unsigned long getUnsignedLong() const { return this->operator unsigned long(); } / ** @brief Returns the current value, converted to the requested type. */417 inline long long getLongLong() const { return this->operator long long(); } / ** @brief Returns the current value, converted to the requested type. */418 inline unsigned long long getUnsignedLongLong() const { return this->operator unsigned long long(); } / ** @brief Returns the current value, converted to the requested type. */419 inline float getFloat() const { return this->operator float(); } / ** @brief Returns the current value, converted to the requested type. */420 inline double getDouble() const { return this->operator double(); } / ** @brief Returns the current value, converted to the requested type. */421 inline long double getLongDouble() const { return this->operator long double(); } / ** @brief Returns the current value, converted to the requested type. */422 inline bool getBool() const { return this->operator bool(); } / ** @brief Returns the current value, converted to the requested type. */423 inline void* getVoid() const { return this->operator void*(); } / ** @brief Returns the current value, converted to the requested type. */424 inline std::string getString() const { return this->operator std::string(); } / ** @brief Returns the current value, converted to the requested type. */425 inline orxonox::Vector2 getVector2() const { return this->operator orxonox::Vector2(); } / ** @brief Returns the current value, converted to the requested type. */426 inline orxonox::Vector3 getVector3() const { return this->operator orxonox::Vector3(); } / ** @brief Returns the current value, converted to the requested type. */427 inline orxonox::Vector4 getVector4() const { return this->operator orxonox::Vector4(); } / ** @brief Returns the current value, converted to the requested type. */428 inline orxonox::ColourValue getColourValue() const { return this->operator orxonox::ColourValue(); } / ** @brief Returns the current value, converted to the requested type. */429 inline orxonox::Quaternion getQuaternion() const { return this->operator orxonox::Quaternion(); } / ** @brief Returns the current value, converted to the requested type. */430 inline orxonox::Radian getRadian() const { return this->operator orxonox::Radian(); } / ** @brief Returns the current value, converted to the requested type. */431 inline orxonox::Degree getDegree() const { return this->operator orxonox::Degree(); } / ** @brief Returns the current value, converted to the requested type. */432 template <typename T> inline T* getPointer() const { return static_cast<T*>(this->getVoid()); } / ** @brief Returns the current value, converted to a T* pointer. */418 inline bool getValue(char* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 419 inline bool getValue(unsigned char* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 420 inline bool getValue(short* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 421 inline bool getValue(unsigned short* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 422 inline bool getValue(int* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 423 inline bool getValue(unsigned int* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 424 inline bool getValue(long* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 425 inline bool getValue(unsigned long* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 426 inline bool getValue(long long* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 427 inline bool getValue(unsigned long long* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 428 inline bool getValue(float* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 429 inline bool getValue(double* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 430 inline bool getValue(long double* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 431 inline bool getValue(bool* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 432 inline bool getValue(void** value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 433 inline bool getValue(std::string* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 434 inline bool getValue(orxonox::Vector2* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 435 inline bool getValue(orxonox::Vector3* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 436 inline bool getValue(orxonox::Vector4* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 437 inline bool getValue(orxonox::ColourValue* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 438 inline bool getValue(orxonox::Quaternion* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 439 inline bool getValue(orxonox::Radian* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 440 inline bool getValue(orxonox::Degree* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 441 442 inline char getChar() const { return this->operator char(); } ///< Returns the current value, converted to the requested type. 443 inline unsigned char getUnsignedChar() const { return this->operator unsigned char(); } ///< Returns the current value, converted to the requested type. 444 inline short getShort() const { return this->operator short(); } ///< Returns the current value, converted to the requested type. 445 inline unsigned short getUnsignedShort() const { return this->operator unsigned short(); } ///< Returns the current value, converted to the requested type. 446 inline int getInt() const { return this->operator int(); } ///< Returns the current value, converted to the requested type. 447 inline unsigned int getUnsignedInt() const { return this->operator unsigned int(); } ///< Returns the current value, converted to the requested type. 448 inline long getLong() const { return this->operator long(); } ///< Returns the current value, converted to the requested type. 449 inline unsigned long getUnsignedLong() const { return this->operator unsigned long(); } ///< Returns the current value, converted to the requested type. 450 inline long long getLongLong() const { return this->operator long long(); } ///< Returns the current value, converted to the requested type. 451 inline unsigned long long getUnsignedLongLong() const { return this->operator unsigned long long(); } ///< Returns the current value, converted to the requested type. 452 inline float getFloat() const { return this->operator float(); } ///< Returns the current value, converted to the requested type. 453 inline double getDouble() const { return this->operator double(); } ///< Returns the current value, converted to the requested type. 454 inline long double getLongDouble() const { return this->operator long double(); } ///< Returns the current value, converted to the requested type. 455 inline bool getBool() const { return this->operator bool(); } ///< Returns the current value, converted to the requested type. 456 inline void* getVoid() const { return this->operator void*(); } ///< Returns the current value, converted to the requested type. 457 inline std::string getString() const { return this->operator std::string(); } ///< Returns the current value, converted to the requested type. 458 inline orxonox::Vector2 getVector2() const { return this->operator orxonox::Vector2(); } ///< Returns the current value, converted to the requested type. 459 inline orxonox::Vector3 getVector3() const { return this->operator orxonox::Vector3(); } ///< Returns the current value, converted to the requested type. 460 inline orxonox::Vector4 getVector4() const { return this->operator orxonox::Vector4(); } ///< Returns the current value, converted to the requested type. 461 inline orxonox::ColourValue getColourValue() const { return this->operator orxonox::ColourValue(); } ///< Returns the current value, converted to the requested type. 462 inline orxonox::Quaternion getQuaternion() const { return this->operator orxonox::Quaternion(); } ///< Returns the current value, converted to the requested type. 463 inline orxonox::Radian getRadian() const { return this->operator orxonox::Radian(); } ///< Returns the current value, converted to the requested type. 464 inline orxonox::Degree getDegree() const { return this->operator orxonox::Degree(); } ///< Returns the current value, converted to the requested type. 465 template <typename T> inline T* getPointer() const { return static_cast<T*>(this->getVoid()); } ///< Returns the current value, converted to a T* pointer. 433 466 434 467 private: 435 inline bool assignValue(const char& value) { if (this->value_ && this->value_->type_ == MT_Type::Char) { return this->value_->setValue(value); } else { this->changeValueContainer<char>(value); return true; } } / ** @brief Assigns a new value by changing type and creating a new container. */436 inline bool assignValue(const unsigned char& value) { if (this->value_ && this->value_->type_ == MT_Type::UnsignedChar) { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned char>(value); return true; } } / ** @brief Assigns a new value by changing type and creating a new container. */437 inline bool assignValue(const short& value) { if (this->value_ && this->value_->type_ == MT_Type::Short) { return this->value_->setValue(value); } else { this->changeValueContainer<short>(value); return true; } } / ** @brief Assigns a new value by changing type and creating a new container. */438 inline bool assignValue(const unsigned short& value) { if (this->value_ && this->value_->type_ == MT_Type::UnsignedShort) { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned short>(value); return true; } } / ** @brief Assigns a new value by changing type and creating a new container. */439 inline bool assignValue(const int& value) { if (this->value_ && this->value_->type_ == MT_Type::Int) { return this->value_->setValue(value); } else { this->changeValueContainer<int>(value); return true; } } / ** @brief Assigns a new value by changing type and creating a new container. */440 inline bool assignValue(const unsigned int& value) { if (this->value_ && this->value_->type_ == MT_Type::UnsignedInt) { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned int>(value); return true; } } / ** @brief Assigns a new value by changing type and creating a new container. */441 inline bool assignValue(const long& value) { if (this->value_ && this->value_->type_ == MT_Type::Long) { return this->value_->setValue(value); } else { this->changeValueContainer<long>(value); return true; } } / ** @brief Assigns a new value by changing type and creating a new container. */442 inline bool assignValue(const unsigned long& value) { if (this->value_ && this->value_->type_ == MT_Type::UnsignedLong) { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned long>(value); return true; } } / ** @brief Assigns a new value by changing type and creating a new container. */443 inline bool assignValue(const long long& value) { if (this->value_ && this->value_->type_ == MT_Type::LongLong) { return this->value_->setValue(value); } else { this->changeValueContainer<long long>(value); return true; } } / ** @brief Assigns a new value by changing type and creating a new container. */444 inline bool assignValue(const unsigned long long& value) { if (this->value_ && this->value_->type_ == MT_Type::UnsignedLongLong) { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned long long>(value); return true; } } / ** @brief Assigns a new value by changing type and creating a new container. */445 inline bool assignValue(const float& value) { if (this->value_ && this->value_->type_ == MT_Type::Float) { return this->value_->setValue(value); } else { this->changeValueContainer<float>(value); return true; } } / ** @brief Assigns a new value by changing type and creating a new container. */446 inline bool assignValue(const double& value) { if (this->value_ && this->value_->type_ == MT_Type::Double) { return this->value_->setValue(value); } else { this->changeValueContainer<double>(value); return true; } } / ** @brief Assigns a new value by changing type and creating a new container. */447 inline bool assignValue(const long double& value) { if (this->value_ && this->value_->type_ == MT_Type::LongDouble) { return this->value_->setValue(value); } else { this->changeValueContainer<long double>(value); return true; } } / ** @brief Assigns a new value by changing type and creating a new container. */448 inline bool assignValue(const bool& value) { if (this->value_ && this->value_->type_ == MT_Type::Bool) { return this->value_->setValue(value); } else { this->changeValueContainer<bool>(value); return true; } } / ** @brief Assigns a new value by changing type and creating a new container. */449 inline bool assignValue( void* const& value) { if (this->value_ && this->value_->type_ == MT_Type::VoidPointer) { return this->value_->setValue(value); } else { this->changeValueContainer<void*>(value); return true; } } / ** @brief Assigns a new value by changing type and creating a new container. */450 inline bool assignValue(const std::string& value) { if (this->value_ && this->value_->type_ == MT_Type::String) { return this->value_->setValue(value); } else { this->changeValueContainer<std::string>(value); return true; } } / ** @brief Assigns a new value by changing type and creating a new container. */451 inline bool assignValue(const orxonox::Vector2& value) { if (this->value_ && this->value_->type_ == MT_Type::Vector2) { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector2>(value); return true; } } / ** @brief Assigns a new value by changing type and creating a new container. */452 inline bool assignValue(const orxonox::Vector3& value) { if (this->value_ && this->value_->type_ == MT_Type::Vector3) { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector3>(value); return true; } } / ** @brief Assigns a new value by changing type and creating a new container. */453 inline bool assignValue(const orxonox::Vector4& value) { if (this->value_ && this->value_->type_ == MT_Type::Vector4) { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector4>(value); return true; } } / ** @brief Assigns a new value by changing type and creating a new container. */454 inline bool assignValue(const orxonox::ColourValue& value) { if (this->value_ && this->value_->type_ == MT_Type::ColourValue) { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::ColourValue>(value); return true; } } / ** @brief Assigns a new value by changing type and creating a new container. */455 inline bool assignValue(const orxonox::Quaternion& value) { if (this->value_ && this->value_->type_ == MT_Type::Quaternion) { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Quaternion>(value); return true; } } / ** @brief Assigns a new value by changing type and creating a new container. */456 inline bool assignValue(const orxonox::Radian& value) { if (this->value_ && this->value_->type_ == MT_Type::Radian) { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Radian>(value); return true; } } / ** @brief Assigns a new value by changing type and creating a new container. */457 inline bool assignValue(const orxonox::Degree& value) { if (this->value_ && this->value_->type_ == MT_Type::Degree) { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Degree>(value); return true; } } / ** @brief Assigns a new value by changing type and creating a new container. */458 459 / ** @brief Changes the value container. */468 inline bool assignValue(const char& value) { if (this->value_ && this->value_->type_ == MT_Type::Char) { return this->value_->setValue(value); } else { this->changeValueContainer<char>(value); return true; } } ///< Assigns a new value by changing type and creating a new container. 469 inline bool assignValue(const unsigned char& value) { if (this->value_ && this->value_->type_ == MT_Type::UnsignedChar) { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned char>(value); return true; } } ///< Assigns a new value by changing type and creating a new container. 470 inline bool assignValue(const short& value) { if (this->value_ && this->value_->type_ == MT_Type::Short) { return this->value_->setValue(value); } else { this->changeValueContainer<short>(value); return true; } } ///< Assigns a new value by changing type and creating a new container. 471 inline bool assignValue(const unsigned short& value) { if (this->value_ && this->value_->type_ == MT_Type::UnsignedShort) { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned short>(value); return true; } } ///< Assigns a new value by changing type and creating a new container. 472 inline bool assignValue(const int& value) { if (this->value_ && this->value_->type_ == MT_Type::Int) { return this->value_->setValue(value); } else { this->changeValueContainer<int>(value); return true; } } ///< Assigns a new value by changing type and creating a new container. 473 inline bool assignValue(const unsigned int& value) { if (this->value_ && this->value_->type_ == MT_Type::UnsignedInt) { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned int>(value); return true; } } ///< Assigns a new value by changing type and creating a new container. 474 inline bool assignValue(const long& value) { if (this->value_ && this->value_->type_ == MT_Type::Long) { return this->value_->setValue(value); } else { this->changeValueContainer<long>(value); return true; } } ///< Assigns a new value by changing type and creating a new container. 475 inline bool assignValue(const unsigned long& value) { if (this->value_ && this->value_->type_ == MT_Type::UnsignedLong) { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned long>(value); return true; } } ///< Assigns a new value by changing type and creating a new container. 476 inline bool assignValue(const long long& value) { if (this->value_ && this->value_->type_ == MT_Type::LongLong) { return this->value_->setValue(value); } else { this->changeValueContainer<long long>(value); return true; } } ///< Assigns a new value by changing type and creating a new container. 477 inline bool assignValue(const unsigned long long& value) { if (this->value_ && this->value_->type_ == MT_Type::UnsignedLongLong) { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned long long>(value); return true; } } ///< Assigns a new value by changing type and creating a new container. 478 inline bool assignValue(const float& value) { if (this->value_ && this->value_->type_ == MT_Type::Float) { return this->value_->setValue(value); } else { this->changeValueContainer<float>(value); return true; } } ///< Assigns a new value by changing type and creating a new container. 479 inline bool assignValue(const double& value) { if (this->value_ && this->value_->type_ == MT_Type::Double) { return this->value_->setValue(value); } else { this->changeValueContainer<double>(value); return true; } } ///< Assigns a new value by changing type and creating a new container. 480 inline bool assignValue(const long double& value) { if (this->value_ && this->value_->type_ == MT_Type::LongDouble) { return this->value_->setValue(value); } else { this->changeValueContainer<long double>(value); return true; } } ///< Assigns a new value by changing type and creating a new container. 481 inline bool assignValue(const bool& value) { if (this->value_ && this->value_->type_ == MT_Type::Bool) { return this->value_->setValue(value); } else { this->changeValueContainer<bool>(value); return true; } } ///< Assigns a new value by changing type and creating a new container. 482 inline bool assignValue( void* const& value) { if (this->value_ && this->value_->type_ == MT_Type::VoidPointer) { return this->value_->setValue(value); } else { this->changeValueContainer<void*>(value); return true; } } ///< Assigns a new value by changing type and creating a new container. 483 inline bool assignValue(const std::string& value) { if (this->value_ && this->value_->type_ == MT_Type::String) { return this->value_->setValue(value); } else { this->changeValueContainer<std::string>(value); return true; } } ///< Assigns a new value by changing type and creating a new container. 484 inline bool assignValue(const orxonox::Vector2& value) { if (this->value_ && this->value_->type_ == MT_Type::Vector2) { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector2>(value); return true; } } ///< Assigns a new value by changing type and creating a new container. 485 inline bool assignValue(const orxonox::Vector3& value) { if (this->value_ && this->value_->type_ == MT_Type::Vector3) { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector3>(value); return true; } } ///< Assigns a new value by changing type and creating a new container. 486 inline bool assignValue(const orxonox::Vector4& value) { if (this->value_ && this->value_->type_ == MT_Type::Vector4) { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector4>(value); return true; } } ///< Assigns a new value by changing type and creating a new container. 487 inline bool assignValue(const orxonox::ColourValue& value) { if (this->value_ && this->value_->type_ == MT_Type::ColourValue) { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::ColourValue>(value); return true; } } ///< Assigns a new value by changing type and creating a new container. 488 inline bool assignValue(const orxonox::Quaternion& value) { if (this->value_ && this->value_->type_ == MT_Type::Quaternion) { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Quaternion>(value); return true; } } ///< Assigns a new value by changing type and creating a new container. 489 inline bool assignValue(const orxonox::Radian& value) { if (this->value_ && this->value_->type_ == MT_Type::Radian) { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Radian>(value); return true; } } ///< Assigns a new value by changing type and creating a new container. 490 inline bool assignValue(const orxonox::Degree& value) { if (this->value_ && this->value_->type_ == MT_Type::Degree) { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Degree>(value); return true; } } ///< Assigns a new value by changing type and creating a new container. 491 492 /// Changes the value container. 460 493 template <typename T> inline void changeValueContainer(const T& value) { if (this->value_) { delete this->value_; } this->createNewValueContainer<T>(value); } 461 / ** @brief Creates a new value container (works only with specialized types). */494 /// Creates a new value container (works only with specialized types). 462 495 template <typename T> void createNewValueContainer(const T& value) { /* STATIC ASSERT */ *****value; return false; } 463 496 … … 465 498 }; 466 499 467 / ** @brief Puts the MultiType on a stream by using the native << operator of the current type. */500 /// Puts the MultiType on a stream by using the native << operator of the current type. 468 501 _UtilExport inline std::ostream& operator<<(std::ostream& outstream, const MultiType& mt) { if (mt.value_) { mt.value_->toString(outstream); } return outstream; } 469 502 470 template <> inline bool MultiType::isType<char>() const { return (this->value_ && this->value_->type_ == MT_Type::Char); } /** @brief Returns true if the current type equals the given type. */ 471 template <> inline bool MultiType::isType<unsigned char>() const { return (this->value_ && this->value_->type_ == MT_Type::UnsignedChar); } /** @brief Returns true if the current type equals the given type. */ 472 template <> inline bool MultiType::isType<short>() const { return (this->value_ && this->value_->type_ == MT_Type::Short); } /** @brief Returns true if the current type equals the given type. */ 473 template <> inline bool MultiType::isType<unsigned short>() const { return (this->value_ && this->value_->type_ == MT_Type::UnsignedShort); } /** @brief Returns true if the current type equals the given type. */ 474 template <> inline bool MultiType::isType<int>() const { return (this->value_ && this->value_->type_ == MT_Type::Int); } /** @brief Returns true if the current type equals the given type. */ 475 template <> inline bool MultiType::isType<unsigned int>() const { return (this->value_ && this->value_->type_ == MT_Type::UnsignedInt); } /** @brief Returns true if the current type equals the given type. */ 476 template <> inline bool MultiType::isType<long>() const { return (this->value_ && this->value_->type_ == MT_Type::Long); } /** @brief Returns true if the current type equals the given type. */ 477 template <> inline bool MultiType::isType<unsigned long>() const { return (this->value_ && this->value_->type_ == MT_Type::UnsignedLong); } /** @brief Returns true if the current type equals the given type. */ 478 template <> inline bool MultiType::isType<long long>() const { return (this->value_ && this->value_->type_ == MT_Type::LongLong); } /** @brief Returns true if the current type equals the given type. */ 479 template <> inline bool MultiType::isType<unsigned long long>() const { return (this->value_ && this->value_->type_ == MT_Type::UnsignedLongLong); } /** @brief Returns true if the current type equals the given type. */ 480 template <> inline bool MultiType::isType<float>() const { return (this->value_ && this->value_->type_ == MT_Type::Float); } /** @brief Returns true if the current type equals the given type. */ 481 template <> inline bool MultiType::isType<double>() const { return (this->value_ && this->value_->type_ == MT_Type::Double); } /** @brief Returns true if the current type equals the given type. */ 482 template <> inline bool MultiType::isType<long double>() const { return (this->value_ && this->value_->type_ == MT_Type::LongDouble); } /** @brief Returns true if the current type equals the given type. */ 483 template <> inline bool MultiType::isType<bool>() const { return (this->value_ && this->value_->type_ == MT_Type::Bool); } /** @brief Returns true if the current type equals the given type. */ 484 template <> inline bool MultiType::isType<void*>() const { return (this->value_ && this->value_->type_ == MT_Type::VoidPointer); } /** @brief Returns true if the current type equals the given type. */ 485 template <> inline bool MultiType::isType<std::string>() const { return (this->value_ && this->value_->type_ == MT_Type::String); } /** @brief Returns true if the current type equals the given type. */ 486 template <> inline bool MultiType::isType<orxonox::Vector2>() const { return (this->value_ && this->value_->type_ == MT_Type::Vector2); } /** @brief Returns true if the current type equals the given type. */ 487 template <> inline bool MultiType::isType<orxonox::Vector3>() const { return (this->value_ && this->value_->type_ == MT_Type::Vector3); } /** @brief Returns true if the current type equals the given type. */ 488 template <> inline bool MultiType::isType<orxonox::Vector4>() const { return (this->value_ && this->value_->type_ == MT_Type::Vector4); } /** @brief Returns true if the current type equals the given type. */ 489 template <> inline bool MultiType::isType<orxonox::ColourValue>() const { return (this->value_ && this->value_->type_ == MT_Type::ColourValue); } /** @brief Returns true if the current type equals the given type. */ 490 template <> inline bool MultiType::isType<orxonox::Quaternion>() const { return (this->value_ && this->value_->type_ == MT_Type::Quaternion); } /** @brief Returns true if the current type equals the given type. */ 491 template <> inline bool MultiType::isType<orxonox::Radian>() const { return (this->value_ && this->value_->type_ == MT_Type::Radian); } /** @brief Returns true if the current type equals the given type. */ 492 template <> inline bool MultiType::isType<orxonox::Degree>() const { return (this->value_ && this->value_->type_ == MT_Type::Degree); } /** @brief Returns true if the current type equals the given type. */ 493 494 template <> inline bool MultiType::convert<void>() { this->reset(); return true; } /** @brief Deletes the content, type becomes MT_Type::Null. */ 503 template <> inline bool MultiType::isType<char>() const { return (this->value_ && this->value_->type_ == MT_Type::Char); } ///< Returns true if the current type equals the given type. 504 template <> inline bool MultiType::isType<unsigned char>() const { return (this->value_ && this->value_->type_ == MT_Type::UnsignedChar); } ///< Returns true if the current type equals the given type. 505 template <> inline bool MultiType::isType<short>() const { return (this->value_ && this->value_->type_ == MT_Type::Short); } ///< Returns true if the current type equals the given type. 506 template <> inline bool MultiType::isType<unsigned short>() const { return (this->value_ && this->value_->type_ == MT_Type::UnsignedShort); } ///< Returns true if the current type equals the given type. 507 template <> inline bool MultiType::isType<int>() const { return (this->value_ && this->value_->type_ == MT_Type::Int); } ///< Returns true if the current type equals the given type. 508 template <> inline bool MultiType::isType<unsigned int>() const { return (this->value_ && this->value_->type_ == MT_Type::UnsignedInt); } ///< Returns true if the current type equals the given type. 509 template <> inline bool MultiType::isType<long>() const { return (this->value_ && this->value_->type_ == MT_Type::Long); } ///< Returns true if the current type equals the given type. 510 template <> inline bool MultiType::isType<unsigned long>() const { return (this->value_ && this->value_->type_ == MT_Type::UnsignedLong); } ///< Returns true if the current type equals the given type. 511 template <> inline bool MultiType::isType<long long>() const { return (this->value_ && this->value_->type_ == MT_Type::LongLong); } ///< Returns true if the current type equals the given type. 512 template <> inline bool MultiType::isType<unsigned long long>() const { return (this->value_ && this->value_->type_ == MT_Type::UnsignedLongLong); } ///< Returns true if the current type equals the given type. 513 template <> inline bool MultiType::isType<float>() const { return (this->value_ && this->value_->type_ == MT_Type::Float); } ///< Returns true if the current type equals the given type. 514 template <> inline bool MultiType::isType<double>() const { return (this->value_ && this->value_->type_ == MT_Type::Double); } ///< Returns true if the current type equals the given type. 515 template <> inline bool MultiType::isType<long double>() const { return (this->value_ && this->value_->type_ == MT_Type::LongDouble); } ///< Returns true if the current type equals the given type. 516 template <> inline bool MultiType::isType<bool>() const { return (this->value_ && this->value_->type_ == MT_Type::Bool); } ///< Returns true if the current type equals the given type. 517 template <> inline bool MultiType::isType<void*>() const { return (this->value_ && this->value_->type_ == MT_Type::VoidPointer); } ///< Returns true if the current type equals the given type. 518 template <> inline bool MultiType::isType<std::string>() const { return (this->value_ && this->value_->type_ == MT_Type::String); } ///< Returns true if the current type equals the given type. 519 template <> inline bool MultiType::isType<orxonox::Vector2>() const { return (this->value_ && this->value_->type_ == MT_Type::Vector2); } ///< Returns true if the current type equals the given type. 520 template <> inline bool MultiType::isType<orxonox::Vector3>() const { return (this->value_ && this->value_->type_ == MT_Type::Vector3); } ///< Returns true if the current type equals the given type. 521 template <> inline bool MultiType::isType<orxonox::Vector4>() const { return (this->value_ && this->value_->type_ == MT_Type::Vector4); } ///< Returns true if the current type equals the given type. 522 template <> inline bool MultiType::isType<orxonox::ColourValue>() const { return (this->value_ && this->value_->type_ == MT_Type::ColourValue); } ///< Returns true if the current type equals the given type. 523 template <> inline bool MultiType::isType<orxonox::Quaternion>() const { return (this->value_ && this->value_->type_ == MT_Type::Quaternion); } ///< Returns true if the current type equals the given type. 524 template <> inline bool MultiType::isType<orxonox::Radian>() const { return (this->value_ && this->value_->type_ == MT_Type::Radian); } ///< Returns true if the current type equals the given type. 525 template <> inline bool MultiType::isType<orxonox::Degree>() const { return (this->value_ && this->value_->type_ == MT_Type::Degree); } ///< Returns true if the current type equals the given type. 526 527 /// Deletes the content, type becomes MT_Type::Null. 528 template <> inline bool MultiType::convert<void>() { this->reset(); return true; } 495 529 496 530 // Specialization to avoid ambiguities with the conversion operator 497 template <> inline bool MultiType::convert<std::string>() { return this->setValue<std::string> (this->operator std::string()); } / ** @brief Converts the current value to the given type. */498 template <> inline bool MultiType::convert<orxonox::Vector2>() { return this->setValue<orxonox::Vector2> (this->operator orxonox::Vector2()); } / ** @brief Converts the current value to the given type. */499 template <> inline bool MultiType::convert<orxonox::Vector3>() { return this->setValue<orxonox::Vector3> (this->operator orxonox::Vector3()); } / ** @brief Converts the current value to the given type. */500 template <> inline bool MultiType::convert<orxonox::Vector4>() { return this->setValue<orxonox::Vector4> (this->operator orxonox::Vector4()); } / ** @brief Converts the current value to the given type. */501 template <> inline bool MultiType::convert<orxonox::ColourValue>() { return this->setValue<orxonox::ColourValue>(this->operator orxonox::ColourValue()); } / ** @brief Converts the current value to the given type. */502 template <> inline bool MultiType::convert<orxonox::Quaternion>() { return this->setValue<orxonox::Quaternion> (this->operator orxonox::Quaternion()); } / ** @brief Converts the current value to the given type. */503 template <> inline bool MultiType::convert<orxonox::Radian>() { return this->setValue<orxonox::Radian> (this->operator orxonox::Radian()); } / ** @brief Converts the current value to the given type. */504 template <> inline bool MultiType::convert<orxonox::Degree>() { return this->setValue<orxonox::Degree> (this->operator orxonox::Degree()); } / ** @brief Converts the current value to the given type. */531 template <> inline bool MultiType::convert<std::string>() { return this->setValue<std::string> (this->operator std::string()); } ///< Converts the current value to the given type. 532 template <> inline bool MultiType::convert<orxonox::Vector2>() { return this->setValue<orxonox::Vector2> (this->operator orxonox::Vector2()); } ///< Converts the current value to the given type. 533 template <> inline bool MultiType::convert<orxonox::Vector3>() { return this->setValue<orxonox::Vector3> (this->operator orxonox::Vector3()); } ///< Converts the current value to the given type. 534 template <> inline bool MultiType::convert<orxonox::Vector4>() { return this->setValue<orxonox::Vector4> (this->operator orxonox::Vector4()); } ///< Converts the current value to the given type. 535 template <> inline bool MultiType::convert<orxonox::ColourValue>() { return this->setValue<orxonox::ColourValue>(this->operator orxonox::ColourValue()); } ///< Converts the current value to the given type. 536 template <> inline bool MultiType::convert<orxonox::Quaternion>() { return this->setValue<orxonox::Quaternion> (this->operator orxonox::Quaternion()); } ///< Converts the current value to the given type. 537 template <> inline bool MultiType::convert<orxonox::Radian>() { return this->setValue<orxonox::Radian> (this->operator orxonox::Radian()); } ///< Converts the current value to the given type. 538 template <> inline bool MultiType::convert<orxonox::Degree>() { return this->setValue<orxonox::Degree> (this->operator orxonox::Degree()); } ///< Converts the current value to the given type. 505 539 506 540 // Specialization to avoid ambiguities with the conversion operator 507 template <> inline bool MultiType::convert<const std::string&>() { return this->convert<std::string>(); } / ** @brief Converts the current value to the given type. */508 template <> inline bool MultiType::convert<const orxonox::Vector2&>() { return this->convert<orxonox::Vector2>(); } / ** @brief Converts the current value to the given type. */509 template <> inline bool MultiType::convert<const orxonox::Vector3&>() { return this->convert<orxonox::Vector3>(); } / ** @brief Converts the current value to the given type. */510 template <> inline bool MultiType::convert<const orxonox::Vector4&>() { return this->convert<orxonox::Vector4>(); } / ** @brief Converts the current value to the given type. */511 template <> inline bool MultiType::convert<const orxonox::ColourValue&>() { return this->convert<orxonox::ColourValue>(); } / ** @brief Converts the current value to the given type. */512 template <> inline bool MultiType::convert<const orxonox::Quaternion&>() { return this->convert<orxonox::Quaternion>(); } / ** @brief Converts the current value to the given type. */513 template <> inline bool MultiType::convert<const orxonox::Radian&>() { return this->convert<orxonox::Radian>(); } / ** @brief Converts the current value to the given type. */514 template <> inline bool MultiType::convert<const orxonox::Degree&>() { return this->convert<orxonox::Degree>(); } / ** @brief Converts the current value to the given type. */541 template <> inline bool MultiType::convert<const std::string&>() { return this->convert<std::string>(); } ///< Converts the current value to the given type. 542 template <> inline bool MultiType::convert<const orxonox::Vector2&>() { return this->convert<orxonox::Vector2>(); } ///< Converts the current value to the given type. 543 template <> inline bool MultiType::convert<const orxonox::Vector3&>() { return this->convert<orxonox::Vector3>(); } ///< Converts the current value to the given type. 544 template <> inline bool MultiType::convert<const orxonox::Vector4&>() { return this->convert<orxonox::Vector4>(); } ///< Converts the current value to the given type. 545 template <> inline bool MultiType::convert<const orxonox::ColourValue&>() { return this->convert<orxonox::ColourValue>(); } ///< Converts the current value to the given type. 546 template <> inline bool MultiType::convert<const orxonox::Quaternion&>() { return this->convert<orxonox::Quaternion>(); } ///< Converts the current value to the given type. 547 template <> inline bool MultiType::convert<const orxonox::Radian&>() { return this->convert<orxonox::Radian>(); } ///< Converts the current value to the given type. 548 template <> inline bool MultiType::convert<const orxonox::Degree&>() { return this->convert<orxonox::Degree>(); } ///< Converts the current value to the given type. 515 549 516 550 template <> _UtilExport void MultiType::createNewValueContainer(const char& value); … … 538 572 template <> _UtilExport void MultiType::createNewValueContainer(const orxonox::Degree& value); 539 573 540 inline bool MultiType::setValue(const char& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 541 inline bool MultiType::setValue(const unsigned char& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 542 inline bool MultiType::setValue(const short& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 543 inline bool MultiType::setValue(const unsigned short& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 544 inline bool MultiType::setValue(const int& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 545 inline bool MultiType::setValue(const unsigned int& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 546 inline bool MultiType::setValue(const long& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 547 inline bool MultiType::setValue(const unsigned long& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 548 inline bool MultiType::setValue(const long long& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 549 inline bool MultiType::setValue(const unsigned long long& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 550 inline bool MultiType::setValue(const float& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 551 inline bool MultiType::setValue(const double& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 552 inline bool MultiType::setValue(const long double& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 553 inline bool MultiType::setValue(const bool& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 554 inline bool MultiType::setValue( void* const& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 555 inline bool MultiType::setValue(const std::string& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 556 inline bool MultiType::setValue(const orxonox::Vector2& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 557 inline bool MultiType::setValue(const orxonox::Vector3& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 558 inline bool MultiType::setValue(const orxonox::Vector4& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 559 inline bool MultiType::setValue(const orxonox::ColourValue& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 560 inline bool MultiType::setValue(const orxonox::Quaternion& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 561 inline bool MultiType::setValue(const orxonox::Radian& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 562 inline bool MultiType::setValue(const orxonox::Degree& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 563 564 inline bool MultiType::setValue(const char* value) { if (this->value_) { return this->value_->setValue(std::string(value)); } else { return this->assignValue(std::string(value)); } } /** @brief Assigns the given value and converts it to the current type. */ 574 inline bool MultiType::setValue(const char& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type. 575 inline bool MultiType::setValue(const unsigned char& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type. 576 inline bool MultiType::setValue(const short& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type. 577 inline bool MultiType::setValue(const unsigned short& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type. 578 inline bool MultiType::setValue(const int& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type. 579 inline bool MultiType::setValue(const unsigned int& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type. 580 inline bool MultiType::setValue(const long& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type. 581 inline bool MultiType::setValue(const unsigned long& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type. 582 inline bool MultiType::setValue(const long long& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type. 583 inline bool MultiType::setValue(const unsigned long long& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type. 584 inline bool MultiType::setValue(const float& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type. 585 inline bool MultiType::setValue(const double& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type. 586 inline bool MultiType::setValue(const long double& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type. 587 inline bool MultiType::setValue(const bool& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type. 588 inline bool MultiType::setValue( void* const& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type. 589 inline bool MultiType::setValue(const std::string& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type. 590 inline bool MultiType::setValue(const orxonox::Vector2& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type. 591 inline bool MultiType::setValue(const orxonox::Vector3& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type. 592 inline bool MultiType::setValue(const orxonox::Vector4& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type. 593 inline bool MultiType::setValue(const orxonox::ColourValue& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type. 594 inline bool MultiType::setValue(const orxonox::Quaternion& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type. 595 inline bool MultiType::setValue(const orxonox::Radian& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type. 596 inline bool MultiType::setValue(const orxonox::Degree& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type. 597 598 /// Assigns the given value and converts it to the current type. 599 inline bool MultiType::setValue(const char* value) { if (this->value_) { return this->value_->setValue(std::string(value)); } else { return this->assignValue(std::string(value)); } } 565 600 } 566 601 -
code/trunk/src/libraries/util/MultiTypeValue.h
r6417 r7401 29 29 /** 30 30 @file 31 @ingroup MultiType 31 32 @brief Declaration and Implementation of the MT_Value<T> class. 32 33 … … 53 54 { 54 55 public: 55 / ** @brief Constructor: Assigns the value and the type identifier. */56 /// Constructor: Assigns the value and the type identifier. 56 57 MT_Value(const T& value, MT_Type::Value type) : MT_ValueBase(type), value_(value) {} 57 58 58 / ** @brief Creates a copy of itself. */59 /// Creates a copy of itself. 59 60 inline MT_ValueBase* clone() const { return new MT_Value<T>(this->value_, this->type_); } 60 61 61 / ** @brief Resets the current value to the default. */62 /// Resets the current value to the default. 62 63 inline void reset() { this->value_ = zeroise<T>(); bHasDefaultValue_ = true; } 63 64 64 /** @brief Assigns the value of the other MultiType, converted to T. @param other The other MultiType */ 65 /** 66 @brief Assigns the value of the other MultiType, converted to T. 67 @param other The other MultiType 68 */ 65 69 inline bool assimilate(const MultiType& other) 66 70 { … … 76 80 } 77 81 78 inline bool getValue(char* value) const { return convertValue<T, char >(value, value_, 0); } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */79 inline bool getValue(unsigned char* value) const { return convertValue<T, unsigned char >(value, value_, 0); } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */80 inline bool getValue(short* value) const { return convertValue<T, short >(value, value_, 0); } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */81 inline bool getValue(unsigned short* value) const { return convertValue<T, unsigned short >(value, value_, 0); } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */82 inline bool getValue(int* value) const { return convertValue<T, int >(value, value_, 0); } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */83 inline bool getValue(unsigned int* value) const { return convertValue<T, unsigned int >(value, value_, 0); } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */84 inline bool getValue(long* value) const { return convertValue<T, long >(value, value_, 0); } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */85 inline bool getValue(unsigned long* value) const { return convertValue<T, unsigned long >(value, value_, 0); } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */86 inline bool getValue(long long* value) const { return convertValue<T, long long >(value, value_, 0); } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */87 inline bool getValue(unsigned long long* value) const { return convertValue<T, unsigned long long >(value, value_, 0); } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */88 inline bool getValue(float* value) const { return convertValue<T, float >(value, value_, 0); } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */89 inline bool getValue(double* value) const { return convertValue<T, double >(value, value_, 0); } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */90 inline bool getValue(long double* value) const { return convertValue<T, long double >(value, value_, 0); } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */91 inline bool getValue(bool* value) const { return convertValue<T, bool >(value, value_, 0); } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */92 inline bool getValue(void** value) const { return convertValue<T, void* >(value, value_, 0); } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */93 inline bool getValue(std::string* value) const { return convertValue<T, std::string >(value, value_, zeroise<std::string> ()); } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */94 inline bool getValue(orxonox::Vector2* value) const { return convertValue<T, orxonox::Vector2 >(value, value_, zeroise<orxonox::Vector2> ()); } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */95 inline bool getValue(orxonox::Vector3* value) const { return convertValue<T, orxonox::Vector3 >(value, value_, zeroise<orxonox::Vector3> ()); } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */96 inline bool getValue(orxonox::Vector4* value) const { return convertValue<T, orxonox::Vector4 >(value, value_, zeroise<orxonox::Vector4> ()); } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */97 inline bool getValue(orxonox::ColourValue* value) const { return convertValue<T, orxonox::ColourValue>(value, value_, zeroise<orxonox::ColourValue>()); } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */98 inline bool getValue(orxonox::Quaternion* value) const { return convertValue<T, orxonox::Quaternion >(value, value_, zeroise<orxonox::Quaternion> ()); } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */99 inline bool getValue(orxonox::Radian* value) const { return convertValue<T, orxonox::Radian >(value, value_, zeroise<orxonox::Radian> ()); } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */100 inline bool getValue(orxonox::Degree* value) const { return convertValue<T, orxonox::Degree >(value, value_, zeroise<orxonox::Degree> ()); } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */101 102 inline bool setValue(const char& value) { return !(bHasDefaultValue_ = !convertValue<char , T>(&value_, value, zeroise<T>())); } / ** @brief Assigns the value by converting it to T. */103 inline bool setValue(const unsigned char& value) { return !(bHasDefaultValue_ = !convertValue<unsigned char , T>(&value_, value, zeroise<T>())); } / ** @brief Assigns the value by converting it to T. */104 inline bool setValue(const short& value) { return !(bHasDefaultValue_ = !convertValue<short , T>(&value_, value, zeroise<T>())); } / ** @brief Assigns the value by converting it to T. */105 inline bool setValue(const unsigned short& value) { return !(bHasDefaultValue_ = !convertValue<unsigned short , T>(&value_, value, zeroise<T>())); } / ** @brief Assigns the value by converting it to T. */106 inline bool setValue(const int& value) { return !(bHasDefaultValue_ = !convertValue<int , T>(&value_, value, zeroise<T>())); } / ** @brief Assigns the value by converting it to T. */107 inline bool setValue(const unsigned int& value) { return !(bHasDefaultValue_ = !convertValue<unsigned int , T>(&value_, value, zeroise<T>())); } / ** @brief Assigns the value by converting it to T. */108 inline bool setValue(const long& value) { return !(bHasDefaultValue_ = !convertValue<long , T>(&value_, value, zeroise<T>())); } / ** @brief Assigns the value by converting it to T. */109 inline bool setValue(const unsigned long& value) { return !(bHasDefaultValue_ = !convertValue<unsigned long , T>(&value_, value, zeroise<T>())); } / ** @brief Assigns the value by converting it to T. */110 inline bool setValue(const long long& value) { return !(bHasDefaultValue_ = !convertValue<long long , T>(&value_, value, zeroise<T>())); } / ** @brief Assigns the value by converting it to T. */111 inline bool setValue(const unsigned long long& value) { return !(bHasDefaultValue_ = !convertValue<unsigned long long , T>(&value_, value, zeroise<T>())); } / ** @brief Assigns the value by converting it to T. */112 inline bool setValue(const float& value) { return !(bHasDefaultValue_ = !convertValue<float , T>(&value_, value, zeroise<T>())); } / ** @brief Assigns the value by converting it to T. */113 inline bool setValue(const double& value) { return !(bHasDefaultValue_ = !convertValue<double , T>(&value_, value, zeroise<T>())); } / ** @brief Assigns the value by converting it to T. */114 inline bool setValue(const long double& value) { return !(bHasDefaultValue_ = !convertValue<long double , T>(&value_, value, zeroise<T>())); } / ** @brief Assigns the value by converting it to T. */115 inline bool setValue(const bool& value) { return !(bHasDefaultValue_ = !convertValue<bool , T>(&value_, value, zeroise<T>())); } / ** @brief Assigns the value by converting it to T. */116 inline bool setValue( void* const& value) { return !(bHasDefaultValue_ = !convertValue<void* , T>(&value_, value, zeroise<T>())); } / ** @brief Assigns the value by converting it to T. */117 inline bool setValue(const std::string& value) { return !(bHasDefaultValue_ = !convertValue<std::string , T>(&value_, value, zeroise<T>())); } / ** @brief Assigns the value by converting it to T. */118 inline bool setValue(const orxonox::Vector2& value) { return !(bHasDefaultValue_ = !convertValue<orxonox::Vector2 , T>(&value_, value, zeroise<T>())); } / ** @brief Assigns the value by converting it to T. */119 inline bool setValue(const orxonox::Vector3& value) { return !(bHasDefaultValue_ = !convertValue<orxonox::Vector3 , T>(&value_, value, zeroise<T>())); } / ** @brief Assigns the value by converting it to T. */120 inline bool setValue(const orxonox::Vector4& value) { return !(bHasDefaultValue_ = !convertValue<orxonox::Vector4 , T>(&value_, value, zeroise<T>())); } / ** @brief Assigns the value by converting it to T. */121 inline bool setValue(const orxonox::ColourValue& value) { return !(bHasDefaultValue_ = !convertValue<orxonox::ColourValue, T>(&value_, value, zeroise<T>())); } / ** @brief Assigns the value by converting it to T. */122 inline bool setValue(const orxonox::Quaternion& value) { return !(bHasDefaultValue_ = !convertValue<orxonox::Quaternion , T>(&value_, value, zeroise<T>())); } / ** @brief Assigns the value by converting it to T. */123 inline bool setValue(const orxonox::Radian& value) { return !(bHasDefaultValue_ = !convertValue<orxonox::Radian , T>(&value_, value, zeroise<T>())); } / ** @brief Assigns the value by converting it to T. */124 inline bool setValue(const orxonox::Degree& value) { return !(bHasDefaultValue_ = !convertValue<orxonox::Degree , T>(&value_, value, zeroise<T>())); } / ** @brief Assigns the value by converting it to T. */125 126 inline operator char() const { return getConvertedValue<T, char> (this->value_, 0); } / ** @brief Returns the current value, converted to the requested type. */127 inline operator unsigned char() const { return getConvertedValue<T, unsigned char> (this->value_, 0); } / ** @brief Returns the current value, converted to the requested type. */128 inline operator short() const { return getConvertedValue<T, short> (this->value_, 0); } / ** @brief Returns the current value, converted to the requested type. */129 inline operator unsigned short() const { return getConvertedValue<T, unsigned short> (this->value_, 0); } / ** @brief Returns the current value, converted to the requested type. */130 inline operator int() const { return getConvertedValue<T, int> (this->value_, 0); } / ** @brief Returns the current value, converted to the requested type. */131 inline operator unsigned int() const { return getConvertedValue<T, unsigned int> (this->value_, 0); } / ** @brief Returns the current value, converted to the requested type. */132 inline operator long() const { return getConvertedValue<T, long> (this->value_, 0); } / ** @brief Returns the current value, converted to the requested type. */133 inline operator unsigned long() const { return getConvertedValue<T, unsigned long> (this->value_, 0); } / ** @brief Returns the current value, converted to the requested type. */134 inline operator long long() const { return getConvertedValue<T, long long> (this->value_, 0); } / ** @brief Returns the current value, converted to the requested type. */135 inline operator unsigned long long() const { return getConvertedValue<T, unsigned long long> (this->value_, 0); } / ** @brief Returns the current value, converted to the requested type. */136 inline operator float() const { return getConvertedValue<T, float> (this->value_, 0); } / ** @brief Returns the current value, converted to the requested type. */137 inline operator double() const { return getConvertedValue<T, double> (this->value_, 0); } / ** @brief Returns the current value, converted to the requested type. */138 inline operator long double() const { return getConvertedValue<T, long double> (this->value_, 0); } / ** @brief Returns the current value, converted to the requested type. */139 inline operator bool() const { return getConvertedValue<T, bool> (this->value_, 0); } / ** @brief Returns the current value, converted to the requested type. */140 inline operator void*() const { return getConvertedValue<T, void*> (this->value_, 0); } / ** @brief Returns the current value, converted to the requested type. */141 inline operator std::string() const { return getConvertedValue<T, std::string> (this->value_, NilValue<std::string >()); } / ** @brief Returns the current value, converted to the requested type. */142 inline operator orxonox::Vector2() const { return getConvertedValue<T, orxonox::Vector2> (this->value_, NilValue<orxonox::Vector2 >()); } / ** @brief Returns the current value, converted to the requested type. */143 inline operator orxonox::Vector3() const { return getConvertedValue<T, orxonox::Vector3> (this->value_, NilValue<orxonox::Vector3 >()); } / ** @brief Returns the current value, converted to the requested type. */144 inline operator orxonox::Vector4() const { return getConvertedValue<T, orxonox::Vector4> (this->value_, NilValue<orxonox::Vector4 >()); } / ** @brief Returns the current value, converted to the requested type. */145 inline operator orxonox::ColourValue() const { return getConvertedValue<T, orxonox::ColourValue>(this->value_, NilValue<orxonox::ColourValue>()); } / ** @brief Returns the current value, converted to the requested type. */146 inline operator orxonox::Quaternion() const { return getConvertedValue<T, orxonox::Quaternion> (this->value_, NilValue<orxonox::Quaternion >()); } / ** @brief Returns the current value, converted to the requested type. */147 inline operator orxonox::Radian() const { return getConvertedValue<T, orxonox::Radian> (this->value_, NilValue<orxonox::Radian >()); } / ** @brief Returns the current value, converted to the requested type. */148 inline operator orxonox::Degree() const { return getConvertedValue<T, orxonox::Degree> (this->value_, NilValue<orxonox::Degree >()); } / ** @brief Returns the current value, converted to the requested type. */149 150 / ** @brief Puts the current value on the stream */82 inline bool getValue(char* value) const { return convertValue<T, char >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 83 inline bool getValue(unsigned char* value) const { return convertValue<T, unsigned char >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 84 inline bool getValue(short* value) const { return convertValue<T, short >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 85 inline bool getValue(unsigned short* value) const { return convertValue<T, unsigned short >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 86 inline bool getValue(int* value) const { return convertValue<T, int >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 87 inline bool getValue(unsigned int* value) const { return convertValue<T, unsigned int >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 88 inline bool getValue(long* value) const { return convertValue<T, long >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 89 inline bool getValue(unsigned long* value) const { return convertValue<T, unsigned long >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 90 inline bool getValue(long long* value) const { return convertValue<T, long long >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 91 inline bool getValue(unsigned long long* value) const { return convertValue<T, unsigned long long >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 92 inline bool getValue(float* value) const { return convertValue<T, float >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 93 inline bool getValue(double* value) const { return convertValue<T, double >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 94 inline bool getValue(long double* value) const { return convertValue<T, long double >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 95 inline bool getValue(bool* value) const { return convertValue<T, bool >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 96 inline bool getValue(void** value) const { return convertValue<T, void* >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 97 inline bool getValue(std::string* value) const { return convertValue<T, std::string >(value, value_, zeroise<std::string> ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 98 inline bool getValue(orxonox::Vector2* value) const { return convertValue<T, orxonox::Vector2 >(value, value_, zeroise<orxonox::Vector2> ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 99 inline bool getValue(orxonox::Vector3* value) const { return convertValue<T, orxonox::Vector3 >(value, value_, zeroise<orxonox::Vector3> ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 100 inline bool getValue(orxonox::Vector4* value) const { return convertValue<T, orxonox::Vector4 >(value, value_, zeroise<orxonox::Vector4> ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 101 inline bool getValue(orxonox::ColourValue* value) const { return convertValue<T, orxonox::ColourValue>(value, value_, zeroise<orxonox::ColourValue>()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 102 inline bool getValue(orxonox::Quaternion* value) const { return convertValue<T, orxonox::Quaternion >(value, value_, zeroise<orxonox::Quaternion> ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 103 inline bool getValue(orxonox::Radian* value) const { return convertValue<T, orxonox::Radian >(value, value_, zeroise<orxonox::Radian> ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 104 inline bool getValue(orxonox::Degree* value) const { return convertValue<T, orxonox::Degree >(value, value_, zeroise<orxonox::Degree> ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 105 106 inline bool setValue(const char& value) { return !(bHasDefaultValue_ = !convertValue<char , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T. 107 inline bool setValue(const unsigned char& value) { return !(bHasDefaultValue_ = !convertValue<unsigned char , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T. 108 inline bool setValue(const short& value) { return !(bHasDefaultValue_ = !convertValue<short , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T. 109 inline bool setValue(const unsigned short& value) { return !(bHasDefaultValue_ = !convertValue<unsigned short , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T. 110 inline bool setValue(const int& value) { return !(bHasDefaultValue_ = !convertValue<int , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T. 111 inline bool setValue(const unsigned int& value) { return !(bHasDefaultValue_ = !convertValue<unsigned int , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T. 112 inline bool setValue(const long& value) { return !(bHasDefaultValue_ = !convertValue<long , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T. 113 inline bool setValue(const unsigned long& value) { return !(bHasDefaultValue_ = !convertValue<unsigned long , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T. 114 inline bool setValue(const long long& value) { return !(bHasDefaultValue_ = !convertValue<long long , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T. 115 inline bool setValue(const unsigned long long& value) { return !(bHasDefaultValue_ = !convertValue<unsigned long long , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T. 116 inline bool setValue(const float& value) { return !(bHasDefaultValue_ = !convertValue<float , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T. 117 inline bool setValue(const double& value) { return !(bHasDefaultValue_ = !convertValue<double , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T. 118 inline bool setValue(const long double& value) { return !(bHasDefaultValue_ = !convertValue<long double , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T. 119 inline bool setValue(const bool& value) { return !(bHasDefaultValue_ = !convertValue<bool , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T. 120 inline bool setValue( void* const& value) { return !(bHasDefaultValue_ = !convertValue<void* , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T. 121 inline bool setValue(const std::string& value) { return !(bHasDefaultValue_ = !convertValue<std::string , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T. 122 inline bool setValue(const orxonox::Vector2& value) { return !(bHasDefaultValue_ = !convertValue<orxonox::Vector2 , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T. 123 inline bool setValue(const orxonox::Vector3& value) { return !(bHasDefaultValue_ = !convertValue<orxonox::Vector3 , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T. 124 inline bool setValue(const orxonox::Vector4& value) { return !(bHasDefaultValue_ = !convertValue<orxonox::Vector4 , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T. 125 inline bool setValue(const orxonox::ColourValue& value) { return !(bHasDefaultValue_ = !convertValue<orxonox::ColourValue, T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T. 126 inline bool setValue(const orxonox::Quaternion& value) { return !(bHasDefaultValue_ = !convertValue<orxonox::Quaternion , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T. 127 inline bool setValue(const orxonox::Radian& value) { return !(bHasDefaultValue_ = !convertValue<orxonox::Radian , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T. 128 inline bool setValue(const orxonox::Degree& value) { return !(bHasDefaultValue_ = !convertValue<orxonox::Degree , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T. 129 130 inline operator char() const { return getConvertedValue<T, char> (this->value_, 0); } ///< Returns the current value, converted to the requested type. 131 inline operator unsigned char() const { return getConvertedValue<T, unsigned char> (this->value_, 0); } ///< Returns the current value, converted to the requested type. 132 inline operator short() const { return getConvertedValue<T, short> (this->value_, 0); } ///< Returns the current value, converted to the requested type. 133 inline operator unsigned short() const { return getConvertedValue<T, unsigned short> (this->value_, 0); } ///< Returns the current value, converted to the requested type. 134 inline operator int() const { return getConvertedValue<T, int> (this->value_, 0); } ///< Returns the current value, converted to the requested type. 135 inline operator unsigned int() const { return getConvertedValue<T, unsigned int> (this->value_, 0); } ///< Returns the current value, converted to the requested type. 136 inline operator long() const { return getConvertedValue<T, long> (this->value_, 0); } ///< Returns the current value, converted to the requested type. 137 inline operator unsigned long() const { return getConvertedValue<T, unsigned long> (this->value_, 0); } ///< Returns the current value, converted to the requested type. 138 inline operator long long() const { return getConvertedValue<T, long long> (this->value_, 0); } ///< Returns the current value, converted to the requested type. 139 inline operator unsigned long long() const { return getConvertedValue<T, unsigned long long> (this->value_, 0); } ///< Returns the current value, converted to the requested type. 140 inline operator float() const { return getConvertedValue<T, float> (this->value_, 0); } ///< Returns the current value, converted to the requested type. 141 inline operator double() const { return getConvertedValue<T, double> (this->value_, 0); } ///< Returns the current value, converted to the requested type. 142 inline operator long double() const { return getConvertedValue<T, long double> (this->value_, 0); } ///< Returns the current value, converted to the requested type. 143 inline operator bool() const { return getConvertedValue<T, bool> (this->value_, 0); } ///< Returns the current value, converted to the requested type. 144 inline operator void*() const { return getConvertedValue<T, void*> (this->value_, 0); } ///< Returns the current value, converted to the requested type. 145 inline operator std::string() const { return getConvertedValue<T, std::string> (this->value_, NilValue<std::string >()); } ///< Returns the current value, converted to the requested type. 146 inline operator orxonox::Vector2() const { return getConvertedValue<T, orxonox::Vector2> (this->value_, NilValue<orxonox::Vector2 >()); } ///< Returns the current value, converted to the requested type. 147 inline operator orxonox::Vector3() const { return getConvertedValue<T, orxonox::Vector3> (this->value_, NilValue<orxonox::Vector3 >()); } ///< Returns the current value, converted to the requested type. 148 inline operator orxonox::Vector4() const { return getConvertedValue<T, orxonox::Vector4> (this->value_, NilValue<orxonox::Vector4 >()); } ///< Returns the current value, converted to the requested type. 149 inline operator orxonox::ColourValue() const { return getConvertedValue<T, orxonox::ColourValue>(this->value_, NilValue<orxonox::ColourValue>()); } ///< Returns the current value, converted to the requested type. 150 inline operator orxonox::Quaternion() const { return getConvertedValue<T, orxonox::Quaternion> (this->value_, NilValue<orxonox::Quaternion >()); } ///< Returns the current value, converted to the requested type. 151 inline operator orxonox::Radian() const { return getConvertedValue<T, orxonox::Radian> (this->value_, NilValue<orxonox::Radian >()); } ///< Returns the current value, converted to the requested type. 152 inline operator orxonox::Degree() const { return getConvertedValue<T, orxonox::Degree> (this->value_, NilValue<orxonox::Degree >()); } ///< Returns the current value, converted to the requested type. 153 154 /// Puts the current value on the stream 151 155 inline void toString(std::ostream& outstream) const { outstream << this->value_; } 152 156 153 / ** @brief loads data from the bytestream (mem) into the MT and increases the bytestream pointer by the size of the data */157 /// loads data from the bytestream (mem) into the MT and increases the bytestream pointer by the size of the data 154 158 inline void importData( uint8_t*& mem ) { loadAndIncrease( /*(const T&)*/this->value_, mem ); } 155 / ** @brief saves data from the MT into the bytestream (mem) and increases the bytestream pointer by the size of the data */159 /// saves data from the MT into the bytestream (mem) and increases the bytestream pointer by the size of the data 156 160 inline void exportData( uint8_t*& mem ) const { saveAndIncrease( /*(const T&)*/this->value_, mem ); } 157 / ** @brief returns the size of the data that would be saved by exportData */161 /// returns the size of the data that would be saved by exportData 158 162 inline uint8_t getSize() const { return returnSize( this->value_ ); } 159 163 160 T value_; // !< The stored value164 T value_; ///< The stored value 161 165 }; 162 166 -
code/trunk/src/libraries/util/OrxAssert.h
r6105 r7401 29 29 /** 30 30 @file 31 @ingroup ExceptionAssertion 31 32 @brief 32 33 Declaration of custom assertion facilities … … 41 42 #include "OutputHandler.h" 42 43 43 // define an assert macro that can display a message44 44 #ifndef NDEBUG 45 /** Run time assertion like assert(), but with an embedded message. 46 @details 47 The message will be printed as error with COUT(1). <br> 48 You can use the same magic here as you can with \ref ThrowException 49 @code 50 OrxAssert(condition, "Text: " << number << " more text"); 51 @endcode 52 */ 45 53 #define OrxAssert(Assertion, ErrorMessage) \ 46 54 Assertion ? ((void)0) : (void)(orxonox::OutputHandler::getOutStream(1) << ErrorMessage << std::endl); \ -
code/trunk/src/libraries/util/OrxEnum.h
r5738 r7401 28 28 29 29 /** 30 @file 31 @brief 32 Declaration of the OrxEnum class. 30 @file 31 @ingroup Util 33 32 */ 34 33 … … 40 39 namespace orxonox 41 40 { 41 /** Lightweight enumeration class that can be extended at run time. 42 @details 43 The class accepts type int and also defines operator int(). Therefore 44 int and OrxEnum can be used interchangeably so you can extend the content 45 of the enumeration at run time by adding ints. 46 @par Declaring an OrxEnum 47 Write a struct that inherits OrxEnum and use some macros: 48 @code 49 struct MyEnum : OrxEnum<MyEnum> 50 { 51 OrxEnumConstructors(MyEnum); 52 53 static const int Value1 = -1; 54 static const int Value2 = 0; 55 static const int Value3 = Value2 + 10; 56 }; 57 @endcode 58 */ 42 59 template <class T> 43 60 struct OrxEnum … … 45 62 public: 46 63 OrxEnum() { } 47 OrxEnum(int type) 64 OrxEnum(int type) { type_ = type; } 48 65 OrxEnum(const T& instance) { type_ = instance.type_; } 49 66 50 operator int() 67 operator int() { return type_; } 51 68 T& operator =(int type) { type_ = type; return *this; } 52 69 bool operator <(const T& right) const { return (type_ < right.type_); } … … 59 76 } 60 77 78 /// See orxonox::OrxEnum for more info 61 79 #define OrxEnumConstructors(enumName) \ 62 80 enumName() { } \ -
code/trunk/src/libraries/util/OutputHandler.cc
r6417 r7401 67 67 @brief 68 68 Gets temporary log path and starts the log file 69 @param outputHandler70 This is only required to avoid another call to getInstance (this c'tor was71 called from getInstance!)72 69 */ 73 70 LogFileWriter() … … 117 114 118 115 private: 119 std::ofstream logFile_; //! File handle for the log file120 std::string logFilename_; //! Filename of the log file116 std::ofstream logFile_; //!< File handle for the log file 117 std::string logFilename_; //!< Filename of the log file 121 118 }; 122 119 … … 162 159 @brief 163 160 Sets the right soft debug level and registers itself 164 @param outputHandler165 This is only required to avoid another call to getInstance (this c'tor was166 called from getInstance!)167 161 */ 168 162 MemoryLogWriter() … … 186 180 187 181 private: 188 std::ostringstream buffer_; //! Stream object used to process the output189 std::vector<std::pair<int, std::string> > output_; //! Vector containing ALL output182 std::ostringstream buffer_; //!< Stream object used to process the output 183 std::vector<std::pair<int, std::string> > output_; //!< Vector containing ALL output 190 184 }; 191 185 -
code/trunk/src/libraries/util/OutputHandler.h
r7284 r7401 29 29 /** 30 30 @file 31 @ingroup Util Output 31 32 @brief 32 Declaration of classes related to output (logging) .33 Declaration of classes related to output (logging), most notably OutputHandler and OutputListener. 33 34 */ 34 35 … … 50 51 Denotes different levels of text output (log output) 51 52 52 0, None : Very important output53 1, Error : Errors54 2, Warning: Warnings55 3, Info : Information56 4, Debug : Debug information57 5, Verbose: More debug information58 6, Ultra : Crazy debug information53 - 0, None : Very important output 54 - 1, Error : Errors 55 - 2, Warning: Warnings 56 - 3, Info : Information 57 - 4, Debug : Debug information 58 - 5, Verbose: More debug information 59 - 6, Ultra : Crazy debug information 59 60 */ 60 61 namespace OutputLevel … … 79 80 /** 80 81 @brief 81 The OutputHandler acts like std::cout, but output isn't only shown in the console. 82 83 You can register your own listener for output by inheriting from OutputListner. 82 The OutputHandler acts like @c std::cout, but output isn't only shown in the console. 83 84 Output passed to the OutputHandler is distributed to all registered listeners, 85 for example the console, the logfile, or the ingame shell. 86 87 You can register your own listener for output by inheriting from OutputListener. 84 88 And if you need the output previously processed, iterate over it with 85 OutputHandler::getOutputVector[Begin/End]. 89 OutputHandler::getOutputVectorBegin and OutputHandler::getOutputVectorEnd. 90 86 91 The way to output text is to first set the desired output level with 87 OutputHandler::getOutStream(level) and then use the "<<" operator like with std::cout. 92 @ref getOutStream "OutputHandler::getOutStream(level)" and then use 93 the "<<" operator like with @c std::cout. Alternatively you can use the COUT() macro. 88 94 */ 89 95 class _UtilExport OutputHandler … … 213 219 OutputHandler(); 214 220 ~OutputHandler(); 215 OutputHandler(const OutputHandler& rhs); //!Unused and undefined221 OutputHandler(const OutputHandler& rhs); //!< Copy-constructor: Unused and undefined 216 222 217 223 std::list<OutputListener*> listeners_; //!< Array with all registered output listeners -
code/trunk/src/libraries/util/Scope.cc
r5738 r7401 27 27 */ 28 28 29 /** 30 @file 31 @brief Static linkage of the two maps in orxonox::ScopeManager. 32 */ 33 29 34 #include "Scope.h" 30 35 -
code/trunk/src/libraries/util/Scope.h
r7266 r7401 27 27 */ 28 28 29 /** 30 @file 31 @ingroup SingletonScope 32 @brief Declaration of the classes that are needed to use Scopes: 33 orxonox::Scope, orxonox::ScopeListener, and orxonox::ScopeManager. 34 35 @anchor Scope 36 37 A virtual scope can be represented by an instance of class orxonox::Scope. orxonox::Scope<@a scope> is a template 38 an its template argument defines the name of the virtual scope. See orxonox::ScopeID for an enumeration of the 39 available values for @a scope. The orxonox::Scope object for a given @a scope can be activated or deactivated. 40 Instances of orxonox::ScopeListener can register for a given @a scope and will get a notification if the 41 corresponding orxonox::Scope object changes its state. 42 43 To avoid multiple instances of orxonox::Scope<@a scope> in different libraries, each instance of orxonox::Scope 44 registers in orxonox::ScopeManager, where they are linked statically in the util library. 45 46 Scopes are usually used to control the creation and destruction of Singletons. 47 48 @see orxonox::ScopedSingletonManager 49 @see orxonox::Singleton 50 */ 51 29 52 #ifndef __Util_Scope_H__ 30 53 #define __Util_Scope_H__ … … 42 65 { 43 66 /** 44 @brief The ScopeManager stores the variables of the scope templates in a statically linked context. 67 @brief The ScopeManager stores the variables of the Scope templates in a statically linked context. 68 69 If all Scope objects are managed by this class, they are statically linked in the util library. 70 Without this, a new instance of Scope<T> for each T would be created in every library of Orxonox, 71 which is of course not the desired behavior. 72 73 @see See @ref Scope "this description" for details about the interrelationship of Scope, ScopeListener, and ScopeManager. 45 74 */ 46 75 class _UtilExport ScopeManager … … 56 85 57 86 /** 58 @brief ScopeListeners register themselves in the corresponding scope and wait for notifications. 87 @brief ScopeListeners register themselves in the corresponding Scope and wait for notifications. 88 Notifications are sent if a Scope is activated or deactivated. 89 90 @see See @ref Scope "this description" for details about the interrelationship of Scope, ScopeListener, and ScopeManager. 59 91 */ 60 92 class _UtilExport ScopeListener … … 86 118 Objects inheriting from a ScopeListener are registered in a list (different for each scope). 87 119 If the scope gets activated or deactivated, all objects in this list are notified. 120 121 @see See @ref Scope "this description" for details about the interrelationship of Scope, ScopeListener, and ScopeManager. 88 122 */ 89 123 template <ScopeID::Value scope> … … 130 164 } 131 165 166 //! Deactivates the listeners of this scope in case the scope is destroyed or the construction fails. 132 167 void deactivateListeners() 133 168 { -
code/trunk/src/libraries/util/ScopedSingletonManager.cc
r7284 r7401 27 27 */ 28 28 29 /** 30 @file 31 @brief Static linkage of the ScopedSingletonManager maps. 32 */ 33 29 34 #include "ScopedSingletonManager.h" 30 35 -
code/trunk/src/libraries/util/ScopedSingletonManager.h
r7284 r7401 26 26 * 27 27 */ 28 29 /** 30 @file 31 @ingroup SingletonScope 32 @brief Definition of orxonox::ScopedSingletonManager, orxonox::ClassScopedSingletonManager, and the ManageScopedSingleton macro. 33 34 ScopedSingletonManager is used to create and destroy Singletons that belong to 35 a given Scope. For each one of these singletons, the macro ManageScopedSingleton() 36 has to be called to register the singleton with orxonox::ScopedSingletonManager. 37 38 See @ref SingletonExample "this code" for an example. 39 40 @see orxonox::Singleton 41 @see orxonox::Scope 42 */ 28 43 29 44 #ifndef __ScopedSingletonManager_H__ … … 38 53 #include "util/Singleton.h" 39 54 55 /** 56 @brief Registers an orxonox::Singleton with orxonox::ScopedSingletonManager. 57 @param className The name of the singleton class 58 @param scope The scope in which the singleton should exist 59 @param allowedToFail If true, the singleton is allowed to fail and thus a try-catch block is used when creating the singleton. 60 61 If this macro is called for a singleton, it is registered with ScopedSingletonManager 62 and will thus be created if its scope becomes active and destroyed if is deactivated. 63 */ 40 64 #define ManageScopedSingleton(className, scope, allowedToFail) \ 41 65 className* className::singletonPtr_s = NULL; \ … … 46 70 class OrxonoxClass; 47 71 72 /** 73 @brief Base class of ClassScopedSingletonManager, implements some static functions 74 used to dispatch calls to preUpdate and postUpdate to all instances of this class. 75 It also keeps track of all existing ScopedSingletonManagers and stores them in a 76 map, sorted by the scope they belong to. 77 */ 48 78 class _UtilExport ScopedSingletonManager 49 79 { 50 80 public: 81 /// Constructor: Initializes all the values 51 82 ScopedSingletonManager(const std::string& className, ScopeID::Value scope) 52 83 : className_(className) … … 54 85 { } 55 86 virtual ~ScopedSingletonManager() { } 87 88 /// Adds a new instance of ScopedSingletonManager to the map. 56 89 static void addManager(ScopedSingletonManager* manager); 57 90 91 /// Calls preUpdate in all instances of ScopedSingletonManager that are registered in the map. 58 92 template<ScopeID::Value scope> 59 93 static void preUpdate(const Clock& time) … … 64 98 } 65 99 virtual void preUpdate(const Clock& time) = 0; 100 101 /// Calls postUpdate in all instances of ScopedSingletonManager that are registered in the map. 66 102 template<ScopeID::Value scope> 67 103 static void postUpdate(const Clock& time) … … 78 114 79 115 protected: 80 const std::string className_; 81 const ScopeID::Value scope_; 116 const std::string className_; ///< The name of the scoped singleton class that is managed by this object 117 const ScopeID::Value scope_; ///< The scope of the singleton that is managed by this object 82 118 }; 83 119 120 /** 121 @anchor ClassScopedSingletonManager 122 123 @brief Manages a scoped singleton for a given scope. 124 @param T The managed singleton class 125 @param scope The scope in which the singleton @a T should be active 126 @param allowedToFail If true, a specialization of this template is used, that uses try-catch blocks to handle possible failures. 127 128 This class inherits from ScopeListener for the given scope and thus its functions 129 activated() and deactivated() are called whenever the Scope changes its state. 130 131 If the Scope is activated, a new instance of @a T (which must be a singleton) is created. 132 If the Scope is deactivated, the singleton is destroyed. 133 134 @see Singleton 135 */ 84 136 template <class T, ScopeID::Value scope, bool allowedToFail> 85 137 class ClassScopedSingletonManager : public ScopedSingletonManager, public ScopeListener 86 138 { 87 139 public: 140 //! Constructor: Initializes the singleton pointer and passes the scope to ScopedSingletonManager and ScopeListener 88 141 ClassScopedSingletonManager(const std::string& className) 89 142 : ScopedSingletonManager(className, scope) … … 113 166 } 114 167 168 //! Destroys the singleton instance - overloaded for OrxonoxClass, calls OrxonoxClass::destroy() 115 169 void destroy(OrxonoxClass*) 116 170 { 117 171 singletonPtr_->destroy(); 118 172 } 173 //! Destroys the singleton instance - overloaded for all other pointers, calls delete 119 174 void destroy(void*) 120 175 { … … 139 194 140 195 private: 141 T* singletonPtr_; 196 T* singletonPtr_; ///< Unique instance of the singleton class @a T 142 197 }; 143 198 199 /** 200 @brief This class partially spezializes ClassScopedSingletonManager for classes @a T that are allowed to fail. 201 @param T The managed singleton class 202 @param scope The scope in which the singleton @a T should be active 203 204 Because @a T could fail when being created, this partial spezialization of ClassScopedSingletonManager 205 uses a try-catch block to handle exceptions. 206 207 See @ref ClassScopedSingletonManager for a full documentation of the basis template. 208 */ 144 209 template <class T, ScopeID::Value scope> 145 210 class ClassScopedSingletonManager<T, scope, true> : public ScopedSingletonManager, public ScopeListener 146 211 { 147 212 public: 213 //! Constructor: Initializes the singleton pointer and passes the scope to ScopedSingletonManager and ScopeListener 148 214 ClassScopedSingletonManager(const std::string& className) 149 215 : ScopedSingletonManager(className, scope) … … 180 246 } 181 247 248 //! Destroys the singleton instance - overloaded for OrxonoxClass, calls OrxonoxClass::destroy() 182 249 void destroy(OrxonoxClass* ptr) 183 250 { 184 251 singletonPtr_->destroy(); 185 252 } 253 //! Destroys the singleton instance - overloaded for void*, calls delete 186 254 void destroy(void* ptr) 187 255 { … … 208 276 209 277 private: 210 T* singletonPtr_; 278 T* singletonPtr_; ///< Unique instance of the singleton class @a T 211 279 }; 212 280 } -
code/trunk/src/libraries/util/Serialise.h
r7182 r7401 29 29 /** 30 30 @file 31 @ingroup Util 31 32 @brief Functions to serialise most of the types/classed used in Orxonox 32 33 */ … … 53 54 template <class T> inline bool checkEquality( const T& variable, uint8_t* mem ); 54 55 55 56 56 57 // =========== char* 57 58 58 59 inline uint32_t returnSize( char*& variable ) 59 60 { 60 61 return strlen(variable)+1; 61 62 } 62 63 63 64 inline void saveAndIncrease( char*& variable, uint8_t*& mem ) 64 65 { … … 66 67 mem += returnSize(variable); 67 68 } 68 69 69 70 inline void loadAndIncrease( char*& variable, uint8_t*& mem ) 70 71 { … … 76 77 mem += len; 77 78 } 78 79 79 80 inline bool checkEquality( char*& variable, uint8_t* mem ) 80 81 { 81 82 return strcmp(variable, (char*)mem)==0; 82 83 } 83 84 84 85 // =================== Template specialisation stuff ============= 85 86 … … 423 424 return memcmp(&temp, mem, sizeof(uint64_t))==0; 424 425 } 425 426 426 427 // =========== string 427 428 -
code/trunk/src/libraries/util/SharedPtr.cc
r7284 r7401 27 27 */ 28 28 29 /** 30 @file 31 @brief Static linkage of the SmallObjectAllocator used by SharedPtr. 32 */ 33 29 34 #include "SharedPtr.h" 30 35 31 36 namespace orxonox 32 37 { 33 SmallObjectAllocator& createSharedCounterPool()38 namespace detail 34 39 { 35 static SmallObjectAllocator instance(sizeof(SharedCounterImpl<void>)); 36 return instance; 40 SmallObjectAllocator& createSharedCounterPool() 41 { 42 static SmallObjectAllocator instance(sizeof(SharedCounterImpl<void>)); 43 return instance; 44 } 37 45 } 38 46 } -
code/trunk/src/libraries/util/SharedPtr.h
r7284 r7401 27 27 */ 28 28 29 /** 30 @defgroup SharedPtr SharedPtr<T> 31 @ingroup Util 32 */ 33 34 /** 35 @file 36 @ingroup SharedPtr 37 @brief Definition of the SharedPtr template that is used to manage pointers. 38 39 @anchor SharedPtrExample 40 41 The orxonox::SharedPtr template can be used to manage a pointer to an object 42 that was created with new. The SharedPtr acts like the pointer itself, but it 43 keeps track of the number of references to it. If all references are removed, 44 SharedPtr deletes the managed object automatically. 45 46 Example: 47 48 Classic implementation using new and delete: 49 @code 50 void someFunction() 51 { 52 MyClass* object = new MyClass(); // Create a new instance of MyClass 53 54 object->myFunction(); // Calls MyClass::myFunction() 55 56 delete object; // Delete the object at the end of the scope 57 } 58 @endcode 59 60 The same function using SharedPtr: 61 @code 62 void someFunction() 63 { 64 SharedPtr<MyClass> object = new MyClass(); // Create a new instance of MyClass and store its pointer in a SharedPtr 65 66 object->myFunction(); // Calls MyClass::myFunction() 67 68 } // At the end of the scope, the SharedPtr is destroyed. Because no other SharedPtrs 69 // point at the object, the object itself is also destroyed automatically 70 @endcode 71 72 This is especially handy if you do not know what will happen with an object that was 73 created with new, for example if you pass it to another object. If multiple instances 74 share a pointer to the same object, none of these instances can delete the object 75 without interfering with the other instances. But if none of the instances destroy the 76 object, it will never be destroyed and results in a memory leak. With a SharedPtr 77 however you don't have to think about destroying the object, because the SharedPtr 78 itself keeps track of the references. 79 80 Example: 81 82 Classic implementation using new and delete: 83 @code 84 class OtherClass // Declaration of some class 85 { 86 public: 87 OtherClass(MyClass* object) // Constructor 88 { 89 this->object_ = object; // Assigns the pointer to the member variable object_ 90 } 91 92 ~OtherClass() // Destructor 93 { 94 ??? // What to do with object_? 95 } 96 97 private: 98 MyClass* object_; // A pointer to the object 99 }; 100 101 void someFunction() 102 { 103 MyClass* object = new MyClass(); // Create a new instance of MyClass 104 105 OtherClass* other1 = new OtherClass(object); // Create an instance of OtherClass and pass the object pointer 106 OtherClass* other2 = new OtherClass(object); // " 107 OtherClass* other3 = new OtherClass(object); // " 108 109 ??? // What happens with object now? 110 } 111 @endcode 112 113 If you use SharedPtr<MyClass> instead of a classic MyClass* pointer, the instance of 114 MyClass would be automatically destroyed if all instances of OtherClass are destroyed. 115 You don't need any code in the destructor and you can completely forget about the 116 object, because its managed by the SharedPtr. 117 118 The same code using SharedPtr: 119 @code 120 class OtherClass // Declaration of some class 121 { 122 public: 123 OtherClass(const SharedPtr<MyClass>& object) // Constructor 124 { 125 this->object_ = object; // Assigns the pointer to the member variable object_ 126 } 127 128 private: 129 SharedPtr<MyClass> object_; // A SharedPtr to the object 130 }; 131 132 void someFunction() 133 { 134 SharedPtr<MyClass> object = new MyClass(); // Create a new instance of MyClass 135 136 OtherClass* other1 = new OtherClass(object); // Create an instance of OtherClass and pass the object pointer 137 OtherClass* other2 = new OtherClass(object); // " 138 OtherClass* other3 = new OtherClass(object); // " 139 140 } // The SmartPtr "object" is destroyed at the end of the scope, 141 // but the three instances of OtherClass keep the object alive 142 // until they are all destroyed. 143 @endcode 144 */ 145 29 146 #ifndef _SharedPtr_H__ 30 147 #define _SharedPtr_H__ … … 39 156 namespace orxonox 40 157 { 41 class SharedCounter 42 { 43 public: 44 SharedCounter() : count_(1) {} 45 virtual void destroy() = 0; 46 47 int count_; 48 }; 49 50 template <class T> 51 class SharedCounterImpl : public SharedCounter 52 { 53 public: 54 SharedCounterImpl(T* pointer) : pointer_(pointer) {} 55 56 void destroy() 57 { 58 delete this->pointer_; 59 } 60 61 private: 62 T* pointer_; 63 }; 64 65 _UtilExport SmallObjectAllocator& createSharedCounterPool(); 66 67 FORCEINLINE SmallObjectAllocator& getSharedCounterPool() 68 { 69 static SmallObjectAllocator& instance = createSharedCounterPool(); 70 return instance; 158 namespace detail 159 { 160 /// BaseClass of SharedCounterImpl, has a counter that is initialized with 1 161 class SharedCounter 162 { 163 public: 164 SharedCounter() : count_(1) {} 165 virtual void destroy() = 0; 166 167 int count_; 168 }; 169 170 /// Child class of SharedCounter, keeps a pointer to an object of type T that can be destroyed with destroy() 171 template <class T> 172 class SharedCounterImpl : public SharedCounter 173 { 174 public: 175 SharedCounterImpl(T* pointer) : pointer_(pointer) {} 176 177 void destroy() 178 { 179 delete this->pointer_; 180 } 181 182 private: 183 T* pointer_; 184 }; 185 186 _UtilExport SmallObjectAllocator& createSharedCounterPool(); 187 188 FORCEINLINE SmallObjectAllocator& getSharedCounterPool() 189 { 190 static SmallObjectAllocator& instance = createSharedCounterPool(); 191 return instance; 192 } 71 193 } 72 194 195 /** 196 @brief The SharedPtr template is a utility to manage pointers to an object. 197 @param T The type of the managed object 198 199 SharedPtr acts like a real pointer, except that it keeps track of the number of 200 references to the object. If the the number of references drops to zero, the 201 object is destroyed automatically. 202 203 @see See @ref SharedPtrExample "this description" for some examples and more information. 204 205 @note The number of references is stored in a separate object that is shared 206 among all instances of SharedPtr that point to the same pointer. This object is 207 also responsible for destroying the pointer if the reference counter becomes zero. 208 */ 73 209 template <class T> 74 210 class SharedPtr … … 78 214 79 215 public: 216 /// Default constructor, the pointer is set to NULL. 80 217 inline SharedPtr() : pointer_(0), counter_(0) 81 218 { 82 219 } 83 220 221 /// Constructor, creates a SharedPtr that points to @a pointer, increments the counter. 84 222 inline SharedPtr(T* pointer) : pointer_(pointer), counter_(0) 85 223 { 86 224 if (this->pointer_) 87 225 { 88 void* chunk = getSharedCounterPool().alloc();89 this->counter_ = new (chunk) SharedCounterImpl<T>(this->pointer_);226 void* chunk = detail::getSharedCounterPool().alloc(); 227 this->counter_ = new (chunk) detail::SharedCounterImpl<T>(this->pointer_); 90 228 } 91 229 } 92 230 231 /// Copy-constructor, this SharedPtr now points to the same object like the other SharedPtr, increments the counter. 93 232 inline SharedPtr(const SharedPtr& other) : pointer_(other.pointer_), counter_(other.counter_) 94 233 { … … 97 236 } 98 237 238 /// Copy-constructor for SharedPtr with another template agument, increments the counter. 99 239 template <class O> 100 240 inline SharedPtr(const SharedPtr<O>& other) : pointer_(other.pointer_), counter_(other.counter_) … … 104 244 } 105 245 246 /// Destructor, decrements the counter and deletes the object if the counter becomes zero. 106 247 inline ~SharedPtr() 107 248 { … … 113 254 { 114 255 this->counter_->destroy(); 115 getSharedCounterPool().free(this->counter_);256 detail::getSharedCounterPool().free(this->counter_); 116 257 } 117 258 } 118 259 } 119 260 261 /// Assigns a new object, decrements the counter of the old object, increments the counter of the new object. 120 262 inline SharedPtr& operator=(const SharedPtr& other) 121 263 { … … 124 266 } 125 267 268 /// Assigns a new object with another template argument, decrements the counter of the old object, increments the counter of the new object. 126 269 template <class O> 127 270 inline SharedPtr& operator=(const SharedPtr<O>& other) … … 131 274 } 132 275 276 /// Casts the pointer to another type 133 277 template <class O> 134 278 inline SharedPtr<O> cast() const … … 138 282 } 139 283 284 /// Overloaded -> operator, returns the pointer to the managed object. 140 285 inline T* operator->() const 141 286 { … … 144 289 } 145 290 291 /// Overloaded * operator, returns a reference ot the managed object. 146 292 inline T& operator*() const 147 293 { … … 150 296 } 151 297 298 /// Returns the pointer to the managed object. 152 299 inline T* get() const 153 300 { … … 155 302 } 156 303 304 /// Returns true if the pointer is not NULL. 157 305 inline operator bool() const 158 306 { … … 160 308 } 161 309 310 /// Swaps the pointer and the counter of two instances of SharedPtr with the same template argument. 162 311 inline void swap(SharedPtr& other) 163 312 { … … 167 316 168 317 private: 169 inline SharedPtr(T* pointer, SharedCounter* counter) : pointer_(pointer), counter_(counter) 318 /// Private constructor, used by the cast() function. 319 inline SharedPtr(T* pointer, detail::SharedCounter* counter) : pointer_(pointer), counter_(counter) 170 320 { 171 321 if (this->pointer_) … … 173 323 } 174 324 175 T* pointer_; 176 SharedCounter* counter_;325 T* pointer_; ///< A pointer to the managed object of type @a T 326 detail::SharedCounter* counter_; ///< A pointer to the shared reference counter 177 327 }; 178 328 329 /** 330 @brief A child class of SharedPtr, used to reflect the hierarchy of the underlying class @a T. 331 @param T The type of the managed object 332 @param Parent The type of the SharedPtr that manages the parent class of @a T 333 334 This class is used to reflect the hierarchy of the underlying class @a T. 335 For example the @c Functor classes: While a @c Functor* pointer would be managed by 336 @c SharedPtr<Functor>, the child class @c FunctorStatic is managed by the class 337 <tt>SharedChildPtr<FunctorStatic, SharedPtr<Functor> ></tt>. 338 339 The second template argument @a Parent is used as the parent class of 340 SharedChildPtr. This means that each instance of <tt>SharedChildPtr<T, Parent></tt> 341 can be upcasted to @c Parent. 342 343 So for example this works: 344 @code 345 SharedChildPtr<FunctorStatic, SharedPtr<Functor> > functorStatic = createFunctor(&MyClass::myStaticFunction); 346 SharedPtr<Functor> functor = functorStatic; 347 @endcode 348 349 @note There are some typedefs and more to make the usage of SharedChildPtr easier 350 for the classes Functor and Executor. See FunctorPtr.h and ExecutorPtr.h. The above 351 example could thus be simplified the following way: 352 @code 353 FunctorStaticPtr functorStatic = createFunctor(&MyClass::myStaticFunction); 354 FunctorPtr functor = functorStatic; 355 @endcode 356 357 @see See SharedPtr for more information about the base class SharedPtr. 358 @see See @ref SharedPtrExample "this description" for some examples about how to use SharedPtr. 359 */ 179 360 template <class T, class Parent> 180 361 class SharedChildPtr : public Parent -
code/trunk/src/libraries/util/SignalHandler.h
r5738 r7401 29 29 /** 30 30 @file 31 @ingroup Util 31 32 @brief Declaration of the SignalHandler class. 32 33 */ … … 68 69 typedef std::list<SignalCallbackRec> SignalCallbackList; 69 70 71 /// The SignalHandler is used to catch signals like SIGSEGV and write a backtrace to the logfile. 70 72 class SignalHandler : public Singleton<SignalHandler> 71 73 { … … 99 101 namespace orxonox 100 102 { 103 /// The SignalHandler is used to catch signals like SIGSEGV and write a backtrace to the logfile. Not implemented on Windows. 101 104 class _UtilExport SignalHandler : public Singleton<SignalHandler> 102 105 { -
code/trunk/src/libraries/util/Singleton.h
r7163 r7401 27 27 */ 28 28 29 /** 30 @defgroup SingletonScope Singletons and Scope 31 @ingroup Util 32 */ 33 34 /** 35 @file 36 @ingroup SingletonScope 37 @brief Definition of the Singleton template that is used as base class for classes that allow only one instance. 38 39 @anchor SingletonExample 40 41 Classes that inherit from orxonox::Singleton follow the singleton pattern and thus 42 allow only one instance of the class to exist. This istance is stored in a static 43 variable called @c singletonPtr_s. orxonox::Singleton will access this variable, but 44 it must be implemented in the deriving class. 45 46 Example: 47 @code 48 class TestSingleton : public Singleton<TestSingleton> // inherit from Singleton, pass the own class as template argument 49 { 50 friend class Singleton<TestSingleton>; // friend declaration so Singleton can access singletonPtr_s 51 52 public: 53 TestSingleton(); // public constructor because we may want to manage this singleton 54 // with an orxonox::ScopedSingletonManager (see below) 55 virtual ~TestSingleton(); // public destructor 56 57 void testFunction(); // put your functions here 58 59 private: 60 int testValue_; // put your variables here 61 62 static TestSingleton* singletonPtr_s; // static singleton instance pointer, used by the Singleton template 63 }; 64 @endcode 65 66 And don't forget to initialize the static singleton pointer in the source (*.cc) %file: 67 @code 68 TestSingleton* TestSingleton::singletonPtr_s = NULL; 69 @endcode 70 71 Usually a singleton gets created automatically when it is first used, but it will never 72 be destroyed (unless the singleton explicitly deletes itself). To allow controlled 73 construction and destruction, the singleton can be put within a virtual scope. This is 74 done by registering the singleton class with orxonox::ScopedSingletonManager. To 75 do so, the ManageScopedSingleton() macro has to be called: 76 77 @code 78 ManageScopedSingleton(TestSingleton, ScopeID::Graphics, false); // muste be called in a source (*.cc) file 79 @endcode 80 81 @b Important: If you call ManageScopedSingleton(), you don't have to initialize singletonPtr_s anymore, 82 because that's already done by the macro. 83 84 Now the singleton TestSingleton gets automatically created if the scope Graphics becomes 85 active and also gets destroyed if the scope is deactivated. 86 87 Note that not all singletons must register with a scope, but it's recommended. 88 89 If a class inherits from orxonox::Singleton, it also inherits its functions. The most important 90 function is orxonox::Singleton::getInstance() which returns a reference to the only instance 91 of the singleton. 92 93 Example: 94 @code 95 TestSingleton::TestSingleton() // implement the constructor 96 { 97 this->testValue_ = 15; 98 } 99 100 void TestSingleton::testFunction() // implement testFunction 101 { 102 COUT(0) << "My value is " << this->testValue_ << std::endl; 103 } 104 105 TestSingleton::getInstance().testFunction(); // prints "My value is 15" 106 @endcode 107 */ 108 29 109 #ifndef __Util_Singleton_H__ 30 110 #define __Util_Singleton_H__ … … 42 122 43 123 Usage: 44 Inherit publicly from Singleton<MyClass> and provide access to 45 MyClass::singletonPtr_s. 124 Inherit publicly from Singleton<MyClass> and provide access to MyClass::singletonPtr_s. 46 125 This can easily be done with a friend declaration. 126 127 See @ref SingletonExample "this example" for an exemplary implementation. 47 128 */ 48 129 template <class T> … … 80 161 } 81 162 82 //! Constructor resets the singleton instance pointer163 //! Destructor resets the singleton instance pointer 83 164 ~Singleton() 84 165 { -
code/trunk/src/libraries/util/SmallObjectAllocator.cc
r7284 r7401 27 27 */ 28 28 29 /** 30 @file 31 @brief Implementation of SmallObjectAllocator 32 */ 33 29 34 #include "SmallObjectAllocator.h" 30 35 31 36 namespace orxonox 32 37 { 38 /** 39 @brief Constructor: initializes the allocator and its values. 40 @param objectSize The size in bytes (returned by sizeof()) of the allocated objects 41 @param numObjects The number of objects that are allocated in one block of memory 42 */ 33 43 SmallObjectAllocator::SmallObjectAllocator(size_t objectSize, size_t numObjects) 34 44 { 35 this-> objectSize_ = std::max(objectSize, sizeof(Chunk));36 this->num Objects_ = numObjects;45 this->chunkSize_ = std::max(objectSize, sizeof(Chunk)); // the chunk's size will be the maximum of the object's size and the size of a Chunk object itself 46 this->numChunksPerBlock_ = numObjects; 37 47 this->first_ = 0; 38 48 } 39 49 50 /** 51 @brief Destructor: deletes the allocated memory blocks. 52 */ 40 53 SmallObjectAllocator::~SmallObjectAllocator() 41 54 { … … 44 57 } 45 58 59 /** 60 @brief Helper function, used to set the next_ pointer of a Chunk. 61 */ 46 62 /* static */ void SmallObjectAllocator::setNext(void* chunk, void* next) 47 63 { … … 49 65 } 50 66 67 /** 68 @brief Helper function, returns the next_ pointer of a Chunk 69 */ 51 70 /* static */ void* SmallObjectAllocator::getNext(void* chunk) 52 71 { … … 54 73 } 55 74 75 /** 76 @brief Returns the first free memory chunk or allocates a new block of memory. 77 */ 56 78 void* SmallObjectAllocator::alloc() 57 79 { 80 // get the first free chunk 58 81 void* chunk = this->first_; 59 82 83 // check if the chunk exists 60 84 if (chunk) 61 85 { 86 // yes it does - the first_ pointer now points to the second element in the list 62 87 this->first_ = getNext(chunk); 63 88 } 64 89 else 65 90 { 66 char* block = new char[this->objectSize_ * this->numObjects_]; 91 // no it doesnt - allocate a new block of memory 92 char* block = new char[this->chunkSize_ * this->numChunksPerBlock_]; 67 93 this->blocks_.push_back(block); 68 94 69 for (size_t i = 1; i < this->numObjects_ - 1; ++i) 70 setNext(block + i * this->objectSize_, block + (i + 1) * this->objectSize_); 95 // iterate through the chunks in the new memory block and link them together to a single linked list 96 for (size_t i = 1; i < this->numChunksPerBlock_ - 1; ++i) 97 setNext(block + i * this->chunkSize_, block + (i + 1) * this->chunkSize_); 71 98 72 setNext(block + (this->numObjects_ - 1) * this->objectSize_, 0); 99 // the next_ pointer of the last chunk must point to NULL 100 setNext(block + (this->numChunksPerBlock_ - 1) * this->chunkSize_, 0); 73 101 74 this->first_ = block + this->objectSize_; 102 // The second chunk in the block is assigned to the first_ pointer 103 this->first_ = block + this->chunkSize_; 75 104 105 // The first chunk in the block is returned 76 106 chunk = block; 77 107 } 78 108 109 // return the pointer to the chunk 79 110 return chunk; 80 111 } 81 112 113 /** 114 @brief Puts the memory chunk back on the list of free memory. 115 */ 82 116 void SmallObjectAllocator::free(void* chunk) 83 117 { 118 // The first_ pointer points to the freed chunk, its next_ pointer points to the rest of the list 84 119 setNext(chunk, this->first_); 85 120 this->first_ = chunk; -
code/trunk/src/libraries/util/SmallObjectAllocator.h
r7284 r7401 27 27 */ 28 28 29 /** 30 @defgroup SmallObjectAllocator SmallObjectAllocator 31 @ingroup Util 32 */ 33 34 /** 35 @file 36 @ingroup SmallObjectAllocator 37 @brief Declaration of SmallObjectAllocator 38 39 @anchor SmallObjectAllocatorExample 40 41 The default implementations of new and delete are designed to work with objects of 42 arbitrary size. They are thus not optimal for small objects. 43 @ref orxonox::SmallObjectAllocator "SmallObjectAllocator" allocates a large memory 44 block and divides it into small chunks. These chunks are returned by the function 45 @ref orxonox::SmallObjectAllocator::alloc() "alloc()" and can be used to create a 46 new object using the placement new operator. Instead of delete, the function 47 @ref orxonox::SmallObjectAllocator::free() "free()" is used to give the memory 48 back to SmallObjectAllocator. 49 50 Example: 51 @code 52 SmallObjectAllocator allocator(sizeof(MySmallObject)); // Create an allocator. The size of the memory chunks must equal the size of the desired class 53 54 void* chunk = allocator.alloc(); // Allocate a memory chunk 55 MySmallObject* object = new (chunk) MySmallObject(); // Call the placement new operator 56 57 object->someFunction(); // Do something with the object 58 59 object->~MySmallObject(); // Call the destructor 60 allocator.free(object); // Free the allocated memory 61 @endcode 62 63 @b Important: You have to call the destructor of the object manually, because this 64 is not automatically done by the allocator nor free(). 65 66 @note The destructor can be ignored if it is empty or not implemented. This saves 67 another amount of time. 68 69 @remarks For a distributed usage of SmallObjectAllocator it may be a good idea to 70 create a static function that returns an instance to it. The allocator then works 71 like a singleton and can be accesses from everywhere. 72 */ 73 29 74 #ifndef _SmallObjectAllocator_H__ 30 75 #define _SmallObjectAllocator_H__ … … 35 80 namespace orxonox 36 81 { 82 /** 83 @brief This class is used to allocate and free small objects (usually not polymorphic). 84 85 SmallObjectAllocator provides a fast alternative to new and delete for small objects. 86 87 @see See @ref SmallObjectAllocatorExample "this description" for more information and an example. 88 */ 37 89 class _UtilExport SmallObjectAllocator 38 90 { 91 /// The memory chunk is at the same time an element of a single linked list. 39 92 struct Chunk 40 93 { 41 Chunk* next_; 94 Chunk* next_; ///< A pointer to the next chunk in the list 42 95 }; 43 96 … … 53 106 static void* getNext(void* chunk); 54 107 55 void* first_; 56 size_t objectSize_;57 size_t num Objects_;108 void* first_; ///< A pointer to the first free memory chunk 109 size_t chunkSize_; ///< The size of each chunk (and usually also the size of the created objects) 110 size_t numChunksPerBlock_; ///< The number of chunks per memory block 58 111 59 std::vector<char*> blocks_; 112 std::vector<char*> blocks_; ///< A list of all allocated memory blocks (used to destroy them again) 60 113 }; 61 114 } -
code/trunk/src/libraries/util/StringUtils.cc
r7284 r7401 41 41 namespace orxonox 42 42 { 43 /// A blank string (""). Used to return a blank string by reference. 43 44 std::string BLANKSTRING; 44 45 46 /// Returns a string of a unique number. This function is guaranteed to never return the same string twice. 45 47 std::string getUniqueNumberString() 46 48 { … … 48 50 } 49 51 50 /** 51 @brief Removes all whitespaces from a string. 52 @param str The string to strip 53 */ 52 /// Removes all whitespaces from a string. 54 53 void strip(std::string* str) 55 54 { … … 63 62 } 64 63 65 /** 66 @brief Returns a copy of a string without whitespaces. 67 @param str The string to strip 68 @return The stripped line 69 */ 64 /// Returns a copy of a string without whitespaces. 70 65 std::string getStripped(const std::string& str) 71 66 { … … 75 70 } 76 71 77 /** 78 @brief Returns a copy of a string without trailing whitespaces. 79 @param str The string 80 @return The modified copy 81 */ 72 /// Returns a copy of a string without trailing whitespaces. 82 73 std::string removeTrailingWhitespaces(const std::string& str) 83 74 { … … 90 81 91 82 /** 92 @brief Returns the position of the next quot ein the string, starting with start.83 @brief Returns the position of the next quotation mark in the string, starting with start. 93 84 @param str The string 94 @param start The startposition95 @return The position of the next quot e (std::string::npos if there is no next quote)85 @param start The first position to look at 86 @return The position of the next quotation mark (@c std::string::npos if there is none) 96 87 */ 97 88 size_t getNextQuote(const std::string& str, size_t start) … … 115 106 116 107 /** 117 @brief Returns true if pos is between two quot es.108 @brief Returns true if pos is between two quotation marks. 118 109 @param str The string 119 110 @param pos The position to check 120 @return True if pos is between two quot es111 @return True if pos is between two quotation marks 121 112 */ 122 113 bool isBetweenQuotes(const std::string& str, size_t pos) … … 140 131 } 141 132 142 /** 143 @brief Returns true if the string contains something like '..."between quotes"...'. 144 @param The string 145 @return True if there is something between quotes 146 */ 133 /// Returns true if the string contains something like '..."between quotaton marks"...'. 147 134 bool hasStringBetweenQuotes(const std::string& str) 148 135 { … … 152 139 } 153 140 154 /** 155 @brief If the string contains something like '..."between quotes"...' then 'between quotes' gets returned (without quotes). 156 @param The string 157 @param The string between the quotes 158 */ 141 /// If the string contains something like '..."between quotaton marks"...' then 'between quotaton marks' gets returned, otherwise "". 159 142 std::string getStringBetweenQuotes(const std::string& str) 160 143 { … … 168 151 169 152 /** 170 @brief Removes enclosing quotes if available (including whitespaces at the outside of the quotes). 171 @brief str The string to strip 172 @return The string with removed quotes 153 @brief Removes enclosing quotation marks if available (including whitespaces at the outside of the quotation marks). 154 @return The striped string without quotation marks 173 155 */ 174 156 std::string stripEnclosingQuotes(const std::string& str) … … 208 190 209 191 /** 210 @brief Removes enclosing {braces} (braces must be exactly on the beginning and the end of the string). 211 @param str The string to strip 212 @return The striped string 192 @brief Removes enclosing braces '{' and '}' (the braces must be exactly on the beginning and the end of the string). 193 @return The striped string without braces 213 194 */ 214 195 std::string stripEnclosingBraces(const std::string& str) … … 224 205 /** 225 206 @brief Determines if a string is a comment (starts with a comment-symbol). 226 @param str The string to check227 @return True = it's a comment228 207 229 208 A comment is defined by a leading '#', '%', ';' or '//'. … … 253 232 } 254 233 255 /** 256 @brief Determines if a string is empty (contains only whitespaces). 257 @param str The string to check 258 @return True = it's empty 259 */ 234 /// Determines if a string is empty (contains only whitespaces). 260 235 bool isEmpty(const std::string& str) 261 236 { … … 263 238 } 264 239 265 /** 266 @brief Determines if a string contains only numbers and maximal one '.'. 267 @param str The string to check 268 @return True = it's a number 269 */ 240 /// Determines if a string contains only numbers and maximal one '.'. 270 241 bool isNumeric(const std::string& str) 271 242 { … … 288 259 /** 289 260 @brief Adds backslashes to the given string which makes special chars visible. Existing slashes will be doubled. 290 @param str The string to manipulate 291 @return The string with added slashes 261 262 This function converts all special chars like line breaks, tabs, quotation marks etc. into 263 a human readable format by adding a backslash. So for example "\n" will be converted to 264 "\\" + "n". 265 266 This is usually used when a string is written to a file. 267 268 @see removeSlashes 292 269 */ 293 270 std::string addSlashes(const std::string& str) … … 320 297 /** 321 298 @brief Removes backslashes from the given string. Double backslashes are interpreted as one backslash. 322 @param str The string to manipulate 323 @return The string with removed slashes 299 300 This function removes all backslashes and converts the human readable equivalents of 301 special chars like "\\" + "n" into their real meaning (in this case a line break or "\n"). 302 303 This is usually used when reading a string from a file. 304 305 @see addSlashes 324 306 */ 325 307 std::string removeSlashes(const std::string& str) … … 361 343 } 362 344 363 /** 364 @brief Replaces each char between A and Z with its lowercase equivalent. 365 @param str The string to convert 366 */ 345 /// Replaces each char between A and Z with its lowercase equivalent. 367 346 void lowercase(std::string* str) 368 347 { … … 373 352 } 374 353 375 /** 376 @brief Returns a copy of the given string without uppercase chars. 377 @param str The string 378 @return The copy 379 */ 354 /// Returns a copy of the given string where all chars are converted to lowercase. 380 355 std::string getLowercase(const std::string& str) 381 356 { … … 385 360 } 386 361 387 /** 388 @brief Replaces each char between a and z with its uppercase equivalent. 389 @param str The string to convert 390 */ 362 /// Replaces each char between a and z with its uppercase equivalent. 391 363 void uppercase(std::string* str) 392 364 { … … 397 369 } 398 370 399 /** 400 @brief Returns a copy of the given string without lowercase chars. 401 @param str The string 402 @return The copy 403 */ 371 /// Returns a copy of the given string where all chars are converted to uppercase. 404 372 std::string getUppercase(const std::string& str) 405 373 { … … 411 379 /** 412 380 @brief Compares two strings ignoring different casing. 413 @param s1 First string 414 @param s2 Second string 381 @return s1 == s1 -> returns 0 / s1 < s2 -> returns -1 / s1 >= s2 -> returns 1 415 382 */ 416 383 int nocaseCmp(const std::string& s1, const std::string& s2) … … 438 405 439 406 /** 440 @brief Compares the first 'len'chars of two strings ignoring different casing.407 @brief Compares the first @a len chars of two strings ignoring different casing. 441 408 @param s1 First string 442 409 @param s2 Second string … … 463 430 } 464 431 465 /** 466 @brief Returns true if the string contains a comment, introduced by #, %, ; or //. 432 /// Returns true if the string contains a comment, introduced by #, %, ; or //. 433 bool hasComment(const std::string& str) 434 { 435 return (getCommentPosition(str) != std::string::npos); 436 } 437 438 /// If the string contains a comment, the comment gets returned (including the comment symbol), an empty string otherwise. 439 std::string getComment(const std::string& str) 440 { 441 return str.substr(getCommentPosition(str)); 442 } 443 444 /// If the string contains a comment, the position of the comment-symbol gets returned, @c std::string::npos otherwise. 445 size_t getCommentPosition(const std::string& str) 446 { 447 return getNextCommentPosition(str, 0); 448 } 449 450 /** 451 @brief Returns the position of the next comment-symbol, starting with @a start. 467 452 @param str The string 468 @return True if the string contains a comment 469 */ 470 bool hasComment(const std::string& str) 471 { 472 return (getCommentPosition(str) != std::string::npos); 473 } 474 475 /** 476 @brief If the string contains a comment, the comment gets returned (including the comment symbol), an empty string otherwise. 477 @param str The string 478 @return The comment 479 */ 480 std::string getComment(const std::string& str) 481 { 482 return str.substr(getCommentPosition(str)); 483 } 484 485 /** 486 @brief If the string contains a comment, the position of the comment-symbol gets returned, std::string::npos otherwise. 487 @param str The string 488 @return The position 489 */ 490 size_t getCommentPosition(const std::string& str) 491 { 492 return getNextCommentPosition(str, 0); 493 } 494 495 /** 496 @brief Returns the position of the next comment-symbol, starting with start. 497 @param str The string 498 @param start The startposition 499 @return The position 453 @param start The first position to look at 500 454 */ 501 455 size_t getNextCommentPosition(const std::string& str, size_t start) -
code/trunk/src/libraries/util/StringUtils.h
r7284 r7401 28 28 29 29 /** 30 @defgroup String String functions 31 @ingroup Util 32 */ 33 34 /** 30 35 @file 36 @ingroup String 31 37 @brief Declaration of several string manipulation functions, used in many parts of the game. 32 38 */ -
code/trunk/src/libraries/util/SubString.cc
r7284 r7401 38 38 */ 39 39 40 /** 41 @file 42 @brief Implementation of the SubString class. 43 */ 44 40 45 #include "SubString.h" 41 46 #include <cstdio> 47 #include "Debug.h" 42 48 43 49 namespace orxonox 44 50 { 45 /** 46 * @brief default constructor 47 */ 51 const std::string SubString::WhiteSpaces = " \n\t"; 52 const std::string SubString::WhiteSpacesWithComma = " \n\t,"; 53 const SubString SubString::NullSubString = SubString(); 54 55 /** 56 @brief Default constructor. 57 */ 48 58 SubString::SubString() 49 {} 50 51 52 /** 53 * @brief create a SubString from 54 * @param string the String to Split 55 * @param delimiter the Character at which to split string (delimiter) 56 */ 57 SubString::SubString(const std::string& string, char delimiter) 58 { 59 this->split(string, delimiter); 60 } 61 62 63 /** 64 * @brief Splits a String into multiple splitters. 65 * @param string the String to split 66 * @param delimiters multiple set of characters at what to split. (delimiters) 67 * @param delimiterNeighbours neighbours of the delimiters, that will be erased only when near a delimiter. 68 * @param emptyEntries If empty entries should be allewed or removed. 69 * @param escapeChar The Escape Character that overrides splitters commends and so on... 70 * @param safemode_char within these characters splitting won't happen 71 * @param comment_char the Comment character. 72 */ 73 SubString::SubString(const std::string& string, 74 const std::string& delimiters, const std::string& delimiterNeighbours, bool emptyEntries, 75 char escapeChar, bool removeEscapeChar, char safemode_char, bool removeSafemodeChar, 76 char openparenthesis_char, char closeparenthesis_char, bool removeParenthesisChars, char comment_char) 77 { 78 SubString::splitLine(this->strings, this->bInSafemode, string, delimiters, delimiterNeighbours, emptyEntries, escapeChar, removeEscapeChar, safemode_char, removeSafemodeChar, openparenthesis_char, closeparenthesis_char, removeParenthesisChars, comment_char); 79 } 80 81 /** 82 * @brief creates a SubSet of a SubString. 83 * @param subString the SubString to take a set from. 84 * @param subSetBegin the beginning to the end 85 */ 86 SubString::SubString(const SubString& subString, unsigned int subSetBegin) 87 { 88 for (unsigned int i = subSetBegin; i < subString.size(); i++) 89 { 90 this->strings.push_back(subString[i]); 91 this->bInSafemode.push_back(subString.isInSafemode(i)); 92 } 93 } 94 95 96 /** 97 * @brief creates a SubSet of a SubString. 98 * @param subString the SubString to take a Set from 99 * @param subSetBegin the beginning to the end 100 * @param subSetEnd the end of the SubSet (max subString.size() will be checked internaly) 101 */ 102 SubString::SubString(const SubString& subString, unsigned int subSetBegin, unsigned int subSetEnd) 103 { 104 for (unsigned int i = subSetBegin; i < subString.size() && i < subSetEnd; i++) 105 { 106 this->strings.push_back(subString[i]); 107 this->bInSafemode.push_back(subString.isInSafemode(i)); 108 } 109 } 110 111 /** 112 * @brief creates a Substring from a count and values set. 113 * @param argc: the Arguments Count. 114 * @param argv: Argument Values. 115 */ 59 { 60 } 61 62 /** 63 @brief Splits a string into multiple tokens. 64 @param line The line to split 65 @param delimiters Multiple characters at which to split the line 66 @param delimiterNeighbours Neighbours of the delimiters that will be erased as well (for example white-spaces) 67 @param bAllowEmptyEntries If true, empty tokens are also added to the SubString (if there are two delimiters without a char in between) 68 @param escapeChar The escape character that is used to escape safemode chars (for example if you want to use a quotation mark between two other quotation marks). 69 @param bRemoveEscapeChar If true, the escape char is removed from the tokens 70 @param safemodeChar Within these characters splitting won't happen (usually the quotation marks) 71 @param bRemoveSafemodeChar Removes the safemodeChar from the beginning and the ending of a token 72 @param openparenthesisChar The beginning of a safemode is marked with this (usually an opening brace) 73 @param closeparenthesisChar The ending of a safemode is marked with this (usually a closing brace) 74 @param bRemoveParenthesisChars Removes the parenthesis chars from the beginning and the ending of a token 75 @param commentChar The comment character (used to ignore the part of the line after the comment char). 76 */ 77 SubString::SubString(const std::string& line, 78 const std::string& delimiters, const std::string& delimiterNeighbours, bool bAllowEmptyEntries, 79 char escapeChar, bool bRemoveEscapeChar, char safemodeChar, bool bRemoveSafemodeChar, 80 char openparenthesisChar, char closeparenthesisChar, bool bRemoveParenthesisChars, char commentChar) 81 { 82 SubString::splitLine(this->tokens_, this->bTokenInSafemode_, line, delimiters, delimiterNeighbours, bAllowEmptyEntries, escapeChar, bRemoveEscapeChar, safemodeChar, bRemoveSafemodeChar, openparenthesisChar, closeparenthesisChar, bRemoveParenthesisChars, commentChar); 83 } 84 85 /** 86 @brief creates a new SubString based on a subset of an other SubString. 87 @param other The other SubString 88 @param begin The beginning of the subset 89 90 The subset ranges from the token with index @a begin to the end of the tokens. 91 If @a begin is greater than the greatest index, the new SubString will be empty. 92 */ 93 SubString::SubString(const SubString& other, unsigned int begin) 94 { 95 for (unsigned int i = begin; i < other.size(); ++i) 96 { 97 this->tokens_.push_back(other[i]); 98 this->bTokenInSafemode_.push_back(other.isInSafemode(i)); 99 } 100 } 101 102 /** 103 @brief creates a new SubString based on a subset of an other SubString. 104 @param other The other SubString 105 @param begin The beginning of the subset 106 @param end The end of the subset 107 108 The subset ranges from the token with index @a begin until (but not including) the token with index @a end. 109 If @a begin or @a end are beyond the allowed index, the resulting SubString will be empty. 110 */ 111 SubString::SubString(const SubString& other, unsigned int begin, unsigned int end) 112 { 113 for (unsigned int i = begin; i < std::min(other.size(), end); ++i) 114 { 115 this->tokens_.push_back(other[i]); 116 this->bTokenInSafemode_.push_back(other.isInSafemode(i)); 117 } 118 } 119 120 /** 121 @brief Creates a SubString from a count and values set. 122 @param argc The number of arguments 123 @param argv An array of pointers to the arguments 124 */ 116 125 SubString::SubString(unsigned int argc, const char** argv) 117 126 { 118 127 for(unsigned int i = 0; i < argc; ++i) 119 128 { 120 this-> strings.push_back(std::string(argv[i]));121 this->b InSafemode.push_back(false);122 } 123 } 124 125 /** 126 * @brief removes the object from memory127 129 this->tokens_.push_back(std::string(argv[i])); 130 this->bTokenInSafemode_.push_back(false); 131 } 132 } 133 134 /** 135 @brief Destructor 136 */ 128 137 SubString::~SubString() 129 138 { } 130 139 131 /** @brief An empty String */ 132 // const std::string SubString::emptyString = ""; 133 /** @brief Helper that gets you a String consisting of all White Spaces */ 134 const std::string SubString::WhiteSpaces = " \n\t"; 135 /** @brief Helper that gets you a String consisting of all WhiteSpaces and the Comma */ 136 const std::string SubString::WhiteSpacesWithComma = " \n\t,"; 137 /** An Empty SubString */ 138 const SubString SubString::NullSubString = SubString(); 139 140 /** 141 * @brief stores the Value of subString in this SubString 142 * @param subString will be copied into this String. 143 * @returns this SubString. 144 */ 145 SubString& SubString::operator=(const SubString& subString) 146 { 147 this->strings = subString.strings; 148 this->bInSafemode = subString.bInSafemode; 140 /** 141 @brief Stores the tokens of @a other in this SubString 142 @return This SubString. 143 */ 144 SubString& SubString::operator=(const SubString& other) 145 { 146 this->tokens_ = other.tokens_; 147 this->bTokenInSafemode_ = other.bTokenInSafemode_; 149 148 return *this; 150 149 } 151 150 152 153 /** 154 * @brief comparator. 155 * @param subString the SubString to compare against this one. 156 * @returns true if the Stored Strings match 157 */ 158 bool SubString::operator==(const SubString& subString) const 159 { 160 return ((this->strings == subString.strings) && (this->bInSafemode == subString.bInSafemode)); 161 } 162 163 /** 164 * @brief comparator. 165 * @param subString the SubString to compare against this one. 166 * @returns true if the Stored Strings match 167 */ 168 bool SubString::compare(const SubString& subString) const 169 { 170 return (*this == subString); 171 } 172 173 /** 174 * @brief comparator. 175 * @param subString the SubString to compare against this one. 176 * @param length how many entries to compare. (from 0 to length) 177 * @returns true if the Stored Strings match 178 */ 179 bool SubString::compare(const SubString& subString, unsigned int length) const 180 { 181 if (length > this->size() || length > subString.size()) 151 /** 152 @brief Compares this SubString to another SubString and returns true if they contain the same values. 153 */ 154 bool SubString::operator==(const SubString& other) const 155 { 156 return ((this->tokens_ == other.tokens_) && (this->bTokenInSafemode_ == other.bTokenInSafemode_)); 157 } 158 159 /** 160 @copydoc operator== 161 */ 162 bool SubString::compare(const SubString& other) const 163 { 164 return (*this == other); 165 } 166 167 /** 168 @brief Compares this SubString to another SubString and returns true if the first @a length values match. 169 @param other The other SubString 170 @param length How many tokens to compare 171 */ 172 bool SubString::compare(const SubString& other, unsigned int length) const 173 { 174 if (length > this->size() || length > other.size()) 182 175 return false; 183 176 184 for (unsigned int i = 0; i < length; i++)185 if ((this-> strings[i] != subString.strings[i]) || (this->bInSafemode[i] != subString.bInSafemode[i]))177 for (unsigned int i = 0; i < length; ++i) 178 if ((this->tokens_[i] != other.tokens_[i]) || (this->bTokenInSafemode_[i] != other.bTokenInSafemode_[i])) 186 179 return false; 187 180 return true; 188 181 } 189 182 190 191 /** 192 * @brief append operator 193 * @param subString the String to append. 194 * @returns a SubString where this and subString are appended. 195 */ 196 SubString SubString::operator+(const SubString& subString) const 197 { 198 return SubString(*this) += subString; 199 } 200 201 202 /** 203 * @brief append operator. 204 * @param subString append subString to this SubString. 205 * @returns this substring appended with subString 206 */ 207 SubString& SubString::operator+=(const SubString& subString) 208 { 209 for (unsigned int i = 0; i < subString.size(); i++) 210 { 211 this->strings.push_back(subString[i]); 212 this->bInSafemode.push_back(subString.isInSafemode(i)); 183 /** 184 @brief Concatenates the tokens of two SubStrings and returns the resulting new SubString 185 @return A new SubString that contains the tokens of this and the other SubString 186 */ 187 SubString SubString::operator+(const SubString& other) const 188 { 189 return SubString(*this) += other; 190 } 191 192 /** 193 @brief Appends the tokens of @a other to this SubString 194 @return This SubString 195 */ 196 SubString& SubString::operator+=(const SubString& other) 197 { 198 for (unsigned int i = 0; i < other.size(); ++i) 199 { 200 this->tokens_.push_back(other[i]); 201 this->bTokenInSafemode_.push_back(other.isInSafemode(i)); 213 202 } 214 203 return *this; 215 204 } 216 205 217 218 /** 219 * @brief Split the String at 220 * @param string where to split 221 * @param splitter delimiter. 222 */ 223 unsigned int SubString::split(const std::string& string, char splitter) 224 { 225 this->strings.clear(); 226 this->bInSafemode.clear(); 227 char split[2]; 228 split[0] = splitter; 229 split[1] = '\0'; 230 SubString::splitLine(this->strings, this->bInSafemode, string, split); 231 return strings.size(); 232 } 233 234 235 /** 236 * @brief Splits a String into multiple splitters. 237 * @param string the String to split 238 * @param delimiters multiple set of characters at what to split. (delimiters) 239 * @param delimiterNeighbours: Neighbours to the Delimiters that will be erased too. 240 * @param emptyEntries: If empty entries are added to the List of SubStrings 241 * @param escapeChar The Escape Character that overrides splitters commends and so on... 242 * @param safemode_char within these characters splitting won't happen 243 * @param comment_char the Comment character. 244 */ 245 unsigned int SubString::split(const std::string& string, 246 const std::string& delimiters, const std::string& delimiterNeighbours, bool emptyEntries, 247 char escapeChar, bool removeExcapeChar, char safemode_char, bool removeSafemodeChar, 248 char openparenthesis_char, char closeparenthesis_char, bool removeParenthesisChars, char comment_char) 249 { 250 this->strings.clear(); 251 this->bInSafemode.clear(); 252 SubString::splitLine(this->strings, this->bInSafemode, string, delimiters, delimiterNeighbours, emptyEntries, escapeChar, removeExcapeChar, safemode_char, removeSafemodeChar, openparenthesis_char, closeparenthesis_char, removeParenthesisChars, comment_char); 253 return this->strings.size(); 254 } 255 256 257 /** 258 * @brief joins together all Strings of this Substring. 259 * @param delimiter the String between the subStrings. 260 * @returns the joined String. 261 */ 206 /** 207 @copydoc SubString(const std::string&,const std::string&,const std::string&,bool,char,bool,char,bool,char,char,bool,char) 208 */ 209 unsigned int SubString::split(const std::string& line, 210 const std::string& delimiters, const std::string& delimiterNeighbours, bool bAllowEmptyEntries, 211 char escapeChar, bool bRemoveEscapeChar, char safemodeChar, bool bRemoveSafemodeChar, 212 char openparenthesisChar, char closeparenthesisChar, bool bRemoveParenthesisChars, char commentChar) 213 { 214 this->tokens_.clear(); 215 this->bTokenInSafemode_.clear(); 216 SubString::splitLine(this->tokens_, this->bTokenInSafemode_, line, delimiters, delimiterNeighbours, bAllowEmptyEntries, escapeChar, bRemoveEscapeChar, safemodeChar, bRemoveSafemodeChar, openparenthesisChar, closeparenthesisChar, bRemoveParenthesisChars, commentChar); 217 return this->tokens_.size(); 218 } 219 220 /** 221 @brief Joins the tokens of this SubString using the given delimiter and returns a string. 222 @param delimiter This delimiter will be placed between each two tokens 223 @return The joined string. 224 */ 262 225 std::string SubString::join(const std::string& delimiter) const 263 226 { 264 if (!this-> strings.empty())265 { 266 std::string retVal = this-> strings[0];267 for (unsigned int i = 1; i < this-> strings.size(); i++)268 retVal += delimiter + this-> strings[i];227 if (!this->tokens_.empty()) 228 { 229 std::string retVal = this->tokens_[0]; 230 for (unsigned int i = 1; i < this->tokens_.size(); ++i) 231 retVal += delimiter + this->tokens_[i]; 269 232 return retVal; 270 233 } … … 273 236 } 274 237 275 276 /** 277 * @brief creates a SubSet of a SubString. 278 * @param subSetBegin the beginning to the end 279 * @returns the SubSet 280 * 281 * This function is added for your convenience, and does the same as 282 * SubString::SubString(const SubString& subString, unsigned int subSetBegin) 283 */ 284 SubString SubString::subSet(unsigned int subSetBegin) const 285 { 286 return SubString(*this, subSetBegin); 287 } 288 289 290 /** 291 * @brief creates a SubSet of a SubString. 292 * @param subSetBegin the beginning to 293 * @param subSetEnd the end of the SubSet to select (if bigger than subString.size() it will be downset.) 294 * @returns the SubSet 295 * 296 * This function is added for your convenience, and does the same as 297 * SubString::SubString(const SubString& subString, unsigned int subSetBegin) 298 */ 299 SubString SubString::subSet(unsigned int subSetBegin, unsigned int subSetEnd) const 300 { 301 return SubString(*this, subSetBegin, subSetEnd); 302 } 303 304 305 /** 306 * @brief splits line into tokens and stores them in ret. 307 * @param ret the Array, where the Splitted strings will be stored in 308 * to the beginning of the current token is stored 309 * @param line the inputLine to split 310 * @param delimiters a String of Delimiters (here the input will be splitted) 311 * @param delimiterNeighbours Neighbours to the Delimiter, that will be removed if they are to the left or the right of a Delimiter. 312 * @param emptyEntries: if empty Strings are added to the List of Strings. 313 * @param escape_char: Escape carater (escapes splitters) 314 * @param safemode_char: the beginning of the safemode is marked with this 315 * @param removeSafemodeChar removes the safemode_char from the beginning and the ending of a token 316 * @param openparenthesis_char the beginning of a safemode is marked with this 317 * @param closeparenthesis_char the ending of a safemode is marked with this 318 * @param removeParenthesisChars removes the parenthesis from the beginning and the ending of a token 319 * @param comment_char: the beginning of a comment is marked with this: (until the end of a Line) 320 * @param start_state: the Initial state on how to parse the String. 321 * @return SPLIT_LINE_STATE the parser was in when returning 322 * 323 * This is the Actual Splitting Algorithm from Clemens Wacha 324 * Supports delimiters, escape characters, 325 * ignores special characters between safemode_char and between comment_char and linend '\n'. 326 */ 238 /** 239 @brief Creates a subset of this SubString. 240 @param begin The beginning of the subset 241 @return A new SubString containing the defined subset. 242 243 The subset ranges from the token with index @a begin to the end of the tokens. 244 If @a begin is greater than the greatest index, the new SubString will be empty. 245 246 This function is added for your convenience, and does the same as 247 SubString::SubString(const SubString& other, unsigned int begin) 248 */ 249 SubString SubString::subSet(unsigned int begin) const 250 { 251 return SubString(*this, begin); 252 } 253 254 /** 255 @brief Creates a subset of this SubString. 256 @param begin The beginning of the subset 257 @param end The ending of the subset 258 @return A new SubString containing the defined subset. 259 260 The subset ranges from the token with index @a begin until (but not including) the token with index @a end. 261 If @a begin or @a end are beyond the allowed index, the resulting SubString will be empty. 262 263 This function is added for your convenience, and does the same as 264 SubString::SubString(const SubString& other, unsigned int begin, unsigned int end) 265 */ 266 SubString SubString::subSet(unsigned int begin, unsigned int end) const 267 { 268 return SubString(*this, begin, end); 269 } 270 271 /** 272 @copydoc SubString(const std::string&,const std::string&,const std::string&,bool,char,bool,char,bool,char,char,bool,char) 273 @param tokens The array, where the splitted strings will be stored in 274 @param bTokenInSafemode A vector wich stores for each character of the string if it is in safemode or not 275 @param start_state The internal state of the parser 276 277 This is the actual splitting algorithm from Clemens Wacha. 278 Supports delimiters, escape characters, ignores special characters between safemodeChar and between commentChar and line end "\n". 279 280 Extended by Orxonox to support parenthesis as additional safe-mode. 281 */ 327 282 SubString::SPLIT_LINE_STATE 328 SubString::splitLine(std::vector<std::string>& ret,329 std::vector<bool>& b InSafemode,283 SubString::splitLine(std::vector<std::string>& tokens, 284 std::vector<bool>& bTokenInSafemode, 330 285 const std::string& line, 331 286 const std::string& delimiters, 332 287 const std::string& delimiterNeighbours, 333 bool emptyEntries,334 char escape _char,335 bool removeExcapeChar,336 char safemode _char,337 bool removeSafemodeChar,338 char openparenthesis _char,339 char closeparenthesis _char,340 bool removeParenthesisChars,341 char comment _char,288 bool bAllowEmptyEntries, 289 char escapeChar, 290 bool bRemoveEscapeChar, 291 char safemodeChar, 292 bool bRemoveSafemodeChar, 293 char openparenthesisChar, 294 char closeparenthesisChar, 295 bool bRemoveParenthesisChars, 296 char commentChar, 342 297 SPLIT_LINE_STATE start_state) 343 298 { … … 349 304 bool inSafemode = false; 350 305 351 if(start_state != SL_NORMAL && ret.size() > 0)352 { 353 token = ret[ret.size()-1];354 ret.pop_back();355 } 356 if(start_state != SL_NORMAL && b InSafemode.size() > 0)357 { 358 inSafemode = b InSafemode[bInSafemode.size()-1];359 b InSafemode.pop_back();306 if(start_state != SL_NORMAL && tokens.size() > 0) 307 { 308 token = tokens[tokens.size()-1]; 309 tokens.pop_back(); 310 } 311 if(start_state != SL_NORMAL && bTokenInSafemode.size() > 0) 312 { 313 inSafemode = bTokenInSafemode[bTokenInSafemode.size()-1]; 314 bTokenInSafemode.pop_back(); 360 315 } 361 316 … … 365 320 { 366 321 case SL_NORMAL: 367 if(line[i] == escape _char)322 if(line[i] == escapeChar) 368 323 { 369 324 state = SL_ESCAPE; 370 if (! removeExcapeChar)325 if (!bRemoveEscapeChar) 371 326 token += line[i]; 372 } 373 else if(line[i] == safemode_char) 327 fallBackNeighbours = 0; 328 } 329 else if(line[i] == safemodeChar) 374 330 { 375 331 state = SL_SAFEMODE; 376 332 inSafemode = true; 377 if (! removeSafemodeChar)333 if (!bRemoveSafemodeChar) 378 334 token += line[i]; 379 } 380 else if(line[i] == openparenthesis_char) 335 fallBackNeighbours = 0; 336 } 337 else if(line[i] == openparenthesisChar) 381 338 { 382 339 state = SL_PARENTHESES; 383 340 inSafemode = true; 384 if (! removeParenthesisChars)341 if (!bRemoveParenthesisChars) 385 342 token += line[i]; 386 } 387 else if(line[i] == comment_char) 343 fallBackNeighbours = 0; 344 } 345 else if(line[i] == commentChar) 388 346 { 389 347 if (fallBackNeighbours > 0) 390 348 token = token.substr(0, token.size() - fallBackNeighbours); 391 /// FINISH 392 if(emptyEntries || token.size() > 0) 349 fallBackNeighbours = 0; 350 // FINISH 351 if(bAllowEmptyEntries || token.size() > 0) 393 352 { 394 ret.push_back(token);353 tokens.push_back(token); 395 354 token.clear(); 396 b InSafemode.push_back(inSafemode);355 bTokenInSafemode.push_back(inSafemode); 397 356 inSafemode = false; 398 357 } … … 405 364 if (fallBackNeighbours > 0) 406 365 token = token.substr(0, token.size() - fallBackNeighbours); 407 /// FINISH 408 if(emptyEntries || token.size() > 0) 366 fallBackNeighbours = 0; 367 // FINISH 368 if(bAllowEmptyEntries || token.size() > 0) 409 369 { 410 ret.push_back(token);370 tokens.push_back(token); 411 371 token.clear(); 412 b InSafemode.push_back(inSafemode);372 bTokenInSafemode.push_back(inSafemode); 413 373 inSafemode = false; 414 374 } … … 423 383 else 424 384 { 425 i++;385 ++i; 426 386 continue; 427 387 } … … 433 393 break; 434 394 case SL_ESCAPE: 435 if (! removeSafemodeChar)395 if (!bRemoveSafemodeChar) 436 396 token += line[i]; 437 397 else … … 450 410 break; 451 411 case SL_SAFEMODE: 452 if(line[i] == safemode _char)412 if(line[i] == safemodeChar) 453 413 { 454 414 state = SL_NORMAL; 455 if (! removeSafemodeChar)415 if (!bRemoveSafemodeChar) 456 416 token += line[i]; 457 417 } 458 else if(line[i] == escape _char)418 else if(line[i] == escapeChar) 459 419 { 460 420 state = SL_SAFEESCAPE; … … 480 440 481 441 case SL_PARENTHESES: 482 if(line[i] == closeparenthesis _char)442 if(line[i] == closeparenthesisChar) 483 443 { 484 444 state = SL_NORMAL; 485 if (! removeParenthesisChars)445 if (!bRemoveParenthesisChars) 486 446 token += line[i]; 487 447 } 488 else if(line[i] == escape _char)448 else if(line[i] == escapeChar) 489 449 { 490 450 state = SL_PARENTHESESESCAPE; … … 512 472 if(line[i] == '\n') 513 473 { 514 // /FINISH474 // FINISH 515 475 if(token.size() > 0) 516 476 { 517 ret.push_back(token);477 tokens.push_back(token); 518 478 token.clear(); 519 b InSafemode.push_back(inSafemode);479 bTokenInSafemode.push_back(inSafemode); 520 480 inSafemode = false; 521 481 } … … 532 492 break; 533 493 } 534 i++;535 } 536 537 // /FINISH494 ++i; 495 } 496 497 // FINISH 538 498 if (fallBackNeighbours > 0) 539 499 token = token.substr(0, token.size() - fallBackNeighbours); 540 if( emptyEntries || token.size() > 0)541 { 542 ret.push_back(token);500 if(bAllowEmptyEntries || token.size() > 0) 501 { 502 tokens.push_back(token); 543 503 token.clear(); 544 b InSafemode.push_back(inSafemode);504 bTokenInSafemode.push_back(inSafemode); 545 505 inSafemode = false; 546 506 } … … 548 508 } 549 509 550 551 /** 552 * @brief Some nice debug information about this SubString 553 */ 510 /** 511 @brief Some nice debug information about this SubString. 512 */ 554 513 void SubString::debug() const 555 514 { 556 printf("Substring-information::count=%d ::", this->strings.size());557 for (unsigned int i = 0; i < this-> strings.size(); i++)558 printf("s%d='%s'::", i, this->strings[i].c_str());559 printf("\n");515 COUT(0) << "Substring-information::count=" << this->tokens_.size() << " ::"; 516 for (unsigned int i = 0; i < this->tokens_.size(); ++i) 517 COUT(0) << "s" << i << "='" << this->tokens_[i].c_str() << "'::"; 518 COUT(0) << std::endl; 560 519 } 561 520 } -
code/trunk/src/libraries/util/SubString.h
r7284 r7401 37 37 */ 38 38 39 /*! 40 * @file 41 * @brief a small class to get the parts of a string separated by commas 42 * 43 * This class is also identified as a Tokenizer. It splits up one long 44 * String into multiple small ones by a designated Delimiter. 45 * 46 * Substring is Advanced, and it is possible, to split a string by ',' 47 * but also removing leading and trailing spaces around the comma. 48 * 49 * @example 50 * Split the String std::string st = "1345, The new empire , is , orxonox" 51 * is splitted with: 52 * SubString(st, ',', " \n\t") 53 * into 54 * "1345", "The new empire", "is", "orxonox" 55 * As you can see, the useless spaces around ',' were removed. 56 */ 39 /** 40 @file 41 @ingroup String 42 @brief A helper class to split a string into several tokens. 43 44 @anchor SubStringExample 45 46 The class SubString can be used to split an std::string into multiple tokens, using 47 a delimiter. SubString allows different options, for example to remove whitespaces 48 around the delimiters or different safe-mode chars, like quotation marks and braces. 49 50 You can access the tokens of the SubString using the [] operator like an array. 51 SubString also supports to join the tokens (or a subset of the tokens) again using 52 @ref orxonox::SubString::join() "join()". It's even possible to get a subset of the 53 SubString as another SubString using @ref orxonox::SubString::subSet() "subSet()". 54 55 Example: 56 @code 57 std::string text = "This is a test, \"Hello \\\" World\" and vector {1, 2, 3}"; 58 SubString tokens(text, SubString::WhiteSpaces, "", false, '\\', true, '"', true, '{', '}', true, '\0'); 59 60 for (unsigned int i = 0; i < tokens.size(); ++i) 61 COUT(0) << i << ": " << tokens[i] << std::endl; 62 @endcode 63 64 The output of this code is: 65 - 0: This 66 - 1: is 67 - 2: a 68 - 3: test, 69 - 4: Hello " World 70 - 5: and 71 - 6: vector 72 - 7: 1, 2, 3 73 74 The string was split using the delimiter " ". A string between quotation mark is not 75 split, the same holds for strings between '{' and '}'. Note how the quotation marks and 76 the braces were removed from the tokens, because the corresponding argument is 'true'. 77 78 Also note that the comma after "test" in token 3 is still there - it is neither part of the 79 delimiters SubString::WhiteSpaces nor part of the delimiterNeighbours parameter, so it 80 remains a part of the token. 81 */ 57 82 58 83 #ifndef __SubString_H__ … … 66 91 namespace orxonox 67 92 { 68 //! A class that can load one string and split it in multipe ones69 93 /** 70 * SubString is a very Powerfull way to create a SubSet from a String 71 * It can be used, to Split strings append them and join them again. 72 */ 94 @brief A class that splits a string into multiple tokens using different options. 95 96 The string is split into multiple tokens using a delimiter. Different options like 97 escape character, quotation marks, and more can be used to satisfy your needs. 98 99 See @ref SubStringExample "this description" for an example. 100 */ 73 101 class _UtilExport SubString 74 102 { 75 public:76 //! An enumerator for the State the Parser is in77 typedef enum{103 /// An enumerator for the internal state of the parser 104 enum SPLIT_LINE_STATE 105 { 78 106 SL_NORMAL, //!< Normal state 79 107 SL_ESCAPE, //!< After an escape character 80 SL_SAFEMODE, //!< In safe mode ( between "" mostly).108 SL_SAFEMODE, //!< In safe mode (usually between quotation marks). 81 109 SL_SAFEESCAPE, //!< In safe mode with the internal escape character, that escapes even the savemode character. 82 110 SL_COMMENT, //!< In Comment mode. 83 111 SL_PARENTHESES, //!< Between parentheses (usually '{' and '}') 84 112 SL_PARENTHESESESCAPE, //!< Between parentheses with the internal escape character, that escapes even the closing paranthesis character. 85 } SPLIT_LINE_STATE; 86 113 }; 87 114 88 115 public: 89 116 SubString(); 90 SubString(const std::string& string, char delimiter = ','); 91 SubString(const std::string& string, 92 const std::string& delimiters, const std::string& delimiterNeighbours = "", bool emptyEntries=false, 93 char escapeChar ='\\', bool removeEscapeChar = true, char safemode_char = '"', bool removeSafemodeChar = true, 94 char openparenthesis_char = '{', char closeparenthesis_char = '}', bool removeParenthesisChars = true, char comment_char = '\0'); 117 SubString(const std::string& line, 118 const std::string& delimiters = SubString::WhiteSpaces, 119 const std::string& delimiterNeighbours = "", 120 bool bAllowEmptyEntries=false, 121 char escapeChar ='\\', 122 bool bRemoveEscapeChar = true, 123 char safemodeChar = '"', 124 bool bRemoveSafemodeChar = true, 125 char openparenthesisChar = '{', 126 char closeparenthesisChar = '}', 127 bool bRemoveParenthesisChars = true, 128 char commentChar = '\0'); 95 129 SubString(unsigned int argc, const char** argv); 96 /** @brief create a Substring as a copy of another one. @param subString the SubString to copy. */ 97 SubString(const SubString& subString) { *this = subString; }; 98 SubString(const SubString& subString, unsigned int subSetBegin); 99 SubString(const SubString& subString, unsigned int subSetBegin, unsigned int subSetEnd); 130 SubString(const SubString& other, unsigned int begin); 131 SubString(const SubString& other, unsigned int begin, unsigned int end); 100 132 ~SubString(); 101 133 102 134 // operate on the SubString 103 SubString& operator=(const SubString& subString);104 bool operator==(const SubString& subString) const;105 bool compare(const SubString& subString) const;106 bool compare(const SubString& subString, unsigned int length) const;107 SubString operator+(const SubString& subString) const;108 SubString& operator+=(const SubString& subString);109 / ** @param subString the String to append @returns appended String. @brief added for convenience */110 SubString& append(const SubString subString) { return (*this += subString); };135 SubString& operator=(const SubString& other); 136 bool operator==(const SubString& other) const; 137 bool compare(const SubString& other) const; 138 bool compare(const SubString& other, unsigned int length) const; 139 SubString operator+(const SubString& other) const; 140 SubString& operator+=(const SubString& other); 141 /// Appends the tokens of another SubString to this. @return This SubString. 142 inline SubString& append(const SubString& other) { return (*this += other); } 111 143 112 144 ///////////////////////////////////////// 113 145 // Split and Join the any String. /////// 114 unsigned int split(const std::string& string = "", char delimiter = ','); 115 unsigned int split(const std::string& string, 116 const std::string& delimiters, const std::string& delimiterNeighbours = "", bool emptyEntries = false, 117 char escapeChar ='\\', bool removeExcapeChar = true, char safemode_char = '"', bool removeSafemodeChar = true, 118 char openparenthesis_char = '{', char closeparenthesis_char = '}', bool removeParenthesisChars = true, char comment_char = '\0'); 146 unsigned int split(const std::string& line, 147 const std::string& delimiters = SubString::WhiteSpaces, 148 const std::string& delimiterNeighbours = "", 149 bool bAllowEmptyEntries = false, 150 char escapeChar ='\\', 151 bool bRemoveEscapeChar = true, 152 char safemodeChar = '"', 153 bool bRemoveSafemodeChar = true, 154 char openparenthesisChar = '{', 155 char closeparenthesisChar = '}', 156 bool bRemoveParenthesisChars = true, 157 char commentChar = '\0'); 158 119 159 std::string join(const std::string& delimiter = " ") const; 120 160 //////////////////////////////////////// 121 161 122 162 // retrieve a SubSet from the String 123 SubString subSet(unsigned int subSetBegin) const;124 SubString subSet(unsigned int subSetBegin, unsigned int subSetEnd) const;163 SubString subSet(unsigned int begin) const; 164 SubString subSet(unsigned int begin, unsigned int end) const; 125 165 126 166 // retrieve Information from within 127 /** @brief Returns true if the SubString is empty */ 128 inline bool empty() const { return this->strings.empty(); }; 129 /** @brief Returns the count of Strings stored in this substring */ 130 inline unsigned int size() const { return this->strings.size(); }; 131 /** @brief Returns the i'th string from the subset of Strings @param i the i'th String */ 132 inline const std::string& operator[](unsigned int i) const { return this->strings[i]; }; 133 /** @brief Returns the i'th string from the subset of Strings @param i the i'th String */ 134 inline const std::string& getString(unsigned int i) const { return (*this)[i]; }; 135 /** @brief Returns all Strings as std::vector */ 136 inline const std::vector<std::string>& getAllStrings() const { return this->strings; } 137 /** @brief Returns true if the token is in safemode. @param i the i'th token */ 138 inline bool isInSafemode(unsigned int i) const { return this->bInSafemode[i]; } 139 /** @brief Returns the front of the StringList. */ 140 inline const std::string& front() const { return this->strings.front(); }; 141 /** @brief Returns the back of the StringList. */ 142 inline const std::string& back() const { return this->strings.back(); }; 143 /** @brief removes the back of the strings list. */ 144 inline void pop_back() { this->strings.pop_back(); this->bInSafemode.pop_back(); }; 145 167 /// Returns true if the SubString is empty 168 inline bool empty() const { return this->tokens_.empty(); } 169 /// Returns the number of tokens stored in this SubString 170 inline unsigned int size() const { return this->tokens_.size(); } 171 /// Returns the i'th token from the subset of strings @param index The index of the requested doken 172 inline const std::string& operator[](unsigned int index) const { return this->tokens_[index]; } 173 /// Returns the i'th token from the subset of strings @param index The index of the requested token 174 inline const std::string& getString(unsigned int index) const { return (*this)[index]; } 175 /// Returns all tokens as std::vector 176 inline const std::vector<std::string>& getAllStrings() const { return this->tokens_; } 177 /// Returns true if the token is in safemode. @param index The index of the token 178 inline bool isInSafemode(unsigned int index) const { return this->bTokenInSafemode_[index]; } 179 /// Returns the front of the list of tokens. 180 inline const std::string& front() const { return this->tokens_.front(); } 181 /// Returns the back of the list of tokens. 182 inline const std::string& back() const { return this->tokens_.back(); } 183 /// Removes the back of the list of tokens. 184 inline void pop_back() { this->tokens_.pop_back(); this->bTokenInSafemode_.pop_back(); } 185 186 void debug() const; 187 188 public: 189 static const std::string WhiteSpaces; ///< All whitespaces (usually used as delimiters or delimiterNeighbours 190 static const std::string WhiteSpacesWithComma; ///< All whitespaces and the comma (usually used as delimiters) 191 static const SubString NullSubString; ///< An empty SubString 192 193 private: 146 194 // the almighty algorithm. 147 static SPLIT_LINE_STATE splitLine(std::vector<std::string>& ret,148 std::vector<bool>& b InSafemode,195 static SPLIT_LINE_STATE splitLine(std::vector<std::string>& tokens, 196 std::vector<bool>& bTokenInSafemode, 149 197 const std::string& line, 150 198 const std::string& delimiters = SubString::WhiteSpaces, 151 199 const std::string& delimiterNeighbours = "", 152 bool emptyEntries = false,153 char escape _char = '\\',154 bool removeExcapeChar = true,155 char safemode _char = '"',156 bool removeSafemodeChar = true,157 char openparenthesis _char = '{',158 char closeparenthesis _char = '}',159 bool removeParenthesisChars = true,160 char comment _char = '\0',200 bool bAllowEmptyEntries = false, 201 char escapeChar = '\\', 202 bool bRemoveEscapeChar = true, 203 char safemodeChar = '"', 204 bool bRemoveSafemodeChar = true, 205 char openparenthesisChar = '{', 206 char closeparenthesisChar = '}', 207 bool bRemoveParenthesisChars = true, 208 char commentChar = '\0', 161 209 SPLIT_LINE_STATE start_state = SL_NORMAL); 162 // debugging. 163 void debug() const; 164 165 public: 166 static const std::string WhiteSpaces; 167 static const std::string WhiteSpacesWithComma; 168 static const SubString NullSubString; 169 170 private: 171 std::vector<std::string> strings; //!< strings produced from a single string splitted in multiple strings 172 std::vector<bool> bInSafemode; 210 211 std::vector<std::string> tokens_; ///< The tokens after spliting the input line 212 std::vector<bool> bTokenInSafemode_; ///< Saves for each token if it was in safe mode (between quotation marks or parenthesis) 173 213 }; 174 214 } -
code/trunk/src/libraries/util/TriBool.h
r6746 r7401 27 27 */ 28 28 29 /** 30 @file 31 @ingroup Util 32 */ 33 29 34 #ifndef _TriBool_H__ 30 35 #define _TriBool_H__ … … 35 40 namespace orxonox 36 41 { 42 /** Sort of a boolean value that also has state \c Dontcare 43 @remarks 44 Even though \c False has the value 0, both \c True and \c Dontcare have 45 a value other than 0. Keep that in mind when using TriBools in if statements. 46 */ 37 47 namespace TriBool 38 48 { -
code/trunk/src/libraries/util/VA_NARGS.h
r7284 r7401 29 29 /** 30 30 @file 31 @ingroup Util 31 32 @brief Declaration of the ORXONOX_VA_NARGS macro which returns the number of arguments passed to a variadic macro. 33 34 With this utility you can overload a macro for different numbers of arguments 35 (of course overloading is not possible for different types, as macros are not 36 type aware, but for different numbers of arguments is still very powerful). 37 38 Example: A macro to call functions 39 @code 40 myfunction(); // A static function 41 MyClass::myStaticFunction(); // A static class function 42 MyClass::myFunction(); // A member function 43 44 #define CallFunction(...) \ // Define a variadic macro that passes the arguments to the overloaded implementations 45 BOOST_PP_EXPAND(BOOST_PP_CAT(CallFunction, ORXONOX_VA_NARGS(__VA_ARGS__))(__VA_ARGS__)) 46 47 #define CallFunction1(function) \ // Overloaded macro for 1 argument 48 function() // Calls the static function 49 50 #define CallFunction2(class, function) \ // Overloaded macro for 2 arguments 51 class::function() // Calls the static class function 52 53 #define CallFunction3(class, function, object) \ // Overloaded macro for 3 arguments 54 object->class::function() // Calls the function on the object 55 56 57 CallFunction(myFunction); // Call the macro with 1 argument 58 CallFunction(MyClass, myStaticFunction); // Call the macro with 2 arguments 59 CallFunction(MyClass, myFunction, new MyClass()); // Call the macro with 3 arguments 60 @endcode 61 62 Note that the first (variadic) macro concatenates the name "CallFunction" with 63 the number of arguments ("1" - "N"). Then all arguments are passed to the right macro. 32 64 */ 33 65 -
code/trunk/src/libraries/util/mbool.h
r7268 r7401 27 27 */ 28 28 29 /** 30 @file 31 @ingroup Util 32 @brief Declaration and implementation of the @ref orxonox::mbool class. 33 */ 34 29 35 #ifndef _mbool_H__ 30 36 #define _mbool_H__ … … 34 40 namespace orxonox 35 41 { 42 /** 43 @brief mbool is a small helper class that acts like a bool, but keeps track of the number of its state changes. 44 45 The mbool class acts like a bool, but it has an internal counter that counts 46 the number state changes (i.e. when the bool changes from true to false or 47 back). This is used in the network if a boolean value is synchronized, because 48 if a value changes quickly from false to true and back in the same tick, the 49 clients will never be notified of this action. By using mbool however this 50 behaviour is fixed, which is important for triggers and other objects. 51 52 @note This is efficiently solved by using a union that combines a counter and a 53 boolean bitfield of size 1. The boolean value corresponds always to the first 54 bit of the counter - this means, if the counter is incremented, the boolean state 55 changes. On the other hand, if you want to change the state, you can simply increase 56 the counter. 57 */ 36 58 struct _UtilExport mbool 37 59 { 38 60 public: 61 /// Constructor: Creates the mbool and initializes the boolean value (default to false). 39 62 inline mbool(bool value = false) 40 63 { this->value_.memory_ = 0; this->value_.bool_ = value; } 64 /// Copy-constructor, copies state and memory. 41 65 inline mbool(const mbool& value) 42 66 { this->value_.memory_ = value.value_.memory_; } 43 67 68 /// Assigns a boolean value (and increases the memory value if the value is different to the old value). 44 69 inline mbool& operator=(bool value) 45 70 { if (value != this->value_.bool_) { ++this->value_.memory_; } return (*this); } 71 /// Assigns another mbool, copies state and memory. 46 72 inline mbool& operator=(const mbool& value) 47 73 { this->value_.memory_ = value.value_.memory_; return (*this); } 48 74 75 /// Increases the memory which also inverts it's state (++mbool). 49 76 inline mbool& operator++() 50 77 { ++this->value_.memory_; return (*this); } 51 inline mbool operator++(int i) 78 /// Increases the memory which also inverts it's state (mbool++). 79 inline mbool operator++(int) 52 80 { mbool temp = (*this); ++this->value_.memory_; return temp; } 53 81 82 /// Implicitly converts the mbool to a bool. 54 83 inline operator bool() const 55 84 { return this->value_.bool_; } 56 85 86 /// Compares the mbool to a bool, returns true if the bool has the same value as the state of the mbool. 57 87 inline bool operator==(bool other) const 58 88 { return this->value_.bool_ == other; } 89 /// Compares the mbool to a bool, returns true if the bool has a different value than the state of the mbool. 59 90 inline bool operator!=(bool other) const 60 91 { return this->value_.bool_ != other; } 61 92 93 /// Compares two mbools, returns true if their memory matches. 62 94 inline bool operator==(const mbool& other) const 63 95 { return this->value_.memory_ == other.value_.memory_; } 96 /// Compares two mbools, returns true if they have a different memory value. 64 97 inline bool operator!=(const mbool& other) const 65 98 { return this->value_.memory_ != other.value_.memory_; } 66 99 100 /// Returns the inverted state of the bool (doesn't change the internal state). 67 101 inline bool operator!() const 68 102 { return (!this->value_.bool_); } 69 103 104 /// Returns the memory value. 70 105 inline unsigned char& getMemory(){ return value_.memory_; } 71 106 … … 73 108 union 74 109 { 75 bool bool_ : 1; 76 unsigned char memory_; 77 } value_; 110 bool bool_ : 1; ///< The boolean state of the mbool, is located on the first bit of the memory variable 111 unsigned char memory_; ///< The memory of the mbool, counts the state-changes (and the first bit represents also the boolean value) 112 } value_; ///< A union containing the state and the memory of the mbool 78 113 }; 79 114 } -
code/trunk/src/modules/CMakeLists.txt
r7164 r7401 19 19 20 20 INCLUDE_DIRECTORIES( 21 ${CMAKE_SOURCE_DIR}/src/external22 21 ${CMAKE_SOURCE_DIR}/src/libraries 23 22 ${CMAKE_SOURCE_DIR}/src/orxonox -
code/trunk/src/modules/notifications/Notification.cc
r7193 r7401 55 55 @brief 56 56 Constructor. Creates a Notification with the input message. 57 @param creator 58 The object that created this Notification 57 59 @param message 58 60 The message of the Notification. -
code/trunk/src/modules/notifications/NotificationQueue.cc
r7163 r7401 109 109 Method for creating a NotificationQueue object through XML. 110 110 */ 111 void NotificationQueue::XMLPort(Element& xml Element, XMLPort::Mode mode)112 { 113 SUPER(NotificationQueue, XMLPort, xml Element, mode);111 void NotificationQueue::XMLPort(Element& xmlelement, XMLPort::Mode mode) 112 { 113 SUPER(NotificationQueue, XMLPort, xmlelement, mode); 114 114 115 115 this->setDefaults(); 116 116 117 XMLPortParam(NotificationQueue, "maxSize", setMaxSize, getMaxSize, xml Element, mode);118 XMLPortParam(NotificationQueue, "notificationLength", setNotificationLength, getNotificationLength, xml Element, mode);119 XMLPortParam(NotificationQueue, "displayTime", setDisplayTime, getDisplayTime, xml Element, mode);120 XMLPortParam(NotificationQueue, "targets", setTargets, getTargets, xml Element, mode);121 XMLPortParam(NotificationQueue, "font", setFont, getFont, xml Element, mode);122 XMLPortParam(NotificationQueue, "fontSize", setFontSize, getFontSize, xml Element, mode);123 XMLPortParam(NotificationQueue, "position", setPosition, getPosition, xml Element, mode);117 XMLPortParam(NotificationQueue, "maxSize", setMaxSize, getMaxSize, xmlelement, mode); 118 XMLPortParam(NotificationQueue, "notificationLength", setNotificationLength, getNotificationLength, xmlelement, mode); 119 XMLPortParam(NotificationQueue, "displayTime", setDisplayTime, getDisplayTime, xmlelement, mode); 120 XMLPortParam(NotificationQueue, "targets", setTargets, getTargets, xmlelement, mode); 121 XMLPortParam(NotificationQueue, "font", setFont, getFont, xmlelement, mode); 122 XMLPortParam(NotificationQueue, "fontSize", setFontSize, getFontSize, xmlelement, mode); 123 XMLPortParam(NotificationQueue, "position", setPosition, getPosition, xmlelement, mode); 124 124 125 125 COUT(3) << "NotificationQueue '" << this->getName() << "' created." << std::endl; -
code/trunk/src/modules/notifications/NotificationQueue.h
r7164 r7401 71 71 72 72 Creating a NotificationQueue through XML goes as follows: 73 Be aware that the NotificationQueue must be inside the <Level></Level> tags or bad things will happen. 73 Be aware that the NotificationQueue must be inside the @code <Level></Level> @endcode tags or bad things will happen. 74 75 @code 74 76 <NotificationQueue 75 77 name = "SuperQueue" //Name of your OverlayQueue. … … 82 84 position = "0.0, 0.0" //The position of the NotificationQueue. (Default is 0.0,0.0) 83 85 /> 86 @endcode 84 87 @author 85 88 Damian 'Mozork' Frick … … 93 96 virtual ~NotificationQueue(); 94 97 95 virtual void XMLPort(Element& xml Element, XMLPort::Mode mode); //!< Method for creating a NotificationQueue object through XML.98 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a NotificationQueue object through XML. 96 99 97 100 virtual void tick(float dt); //!< To update from time to time. -
code/trunk/src/modules/objects/Planet.cc
r7163 r7401 144 144 } 145 145 146 /**147 @brief XML loading and saving.148 @param xmlelement The XML-element149 @param loading Loading (true) or saving (false)150 @return The XML-element151 */152 146 void Planet::XMLPort(Element& xmlelement, XMLPort::Mode mode) 153 147 { -
code/trunk/src/modules/overlays/FadeoutText.h
r5929 r7401 44 44 virtual ~FadeoutText() {} 45 45 46 virtual void XMLPort(Element& xml Element, XMLPort::Mode mode);46 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 47 47 virtual void tick(float dt); 48 48 -
code/trunk/src/modules/overlays/GUIOverlay.cc
r7163 r7401 52 52 } 53 53 54 void GUIOverlay::XMLPort(Element& xml Element, XMLPort::Mode mode)54 void GUIOverlay::XMLPort(Element& xmlelement, XMLPort::Mode mode) 55 55 { 56 SUPER(GUIOverlay, XMLPort, xml Element, mode);56 SUPER(GUIOverlay, XMLPort, xmlelement, mode); 57 57 58 XMLPortParam(GUIOverlay, "guiname", setGUIName, getGUIName, xml Element, mode);58 XMLPortParam(GUIOverlay, "guiname", setGUIName, getGUIName, xmlelement, mode); 59 59 } 60 60 -
code/trunk/src/modules/overlays/GUIOverlay.h
r6753 r7401 44 44 virtual ~GUIOverlay(); 45 45 46 virtual void XMLPort(Element& xml Element, XMLPort::Mode mode);46 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 47 47 48 48 void setGUIName(const std::string& name); -
code/trunk/src/modules/overlays/OverlayText.cc
r6417 r7401 71 71 } 72 72 73 void OverlayText::XMLPort(Element& xml Element, XMLPort::Mode mode)73 void OverlayText::XMLPort(Element& xmlelement, XMLPort::Mode mode) 74 74 { 75 SUPER(OverlayText, XMLPort, xml Element, mode);75 SUPER(OverlayText, XMLPort, xmlelement, mode); 76 76 77 XMLPortParam(OverlayText, "font", setFont, getFont, xml Element, mode);78 XMLPortParam(OverlayText, "colour", setColour, getColour, xml Element, mode);79 XMLPortParam(OverlayText, "caption", setCaption, getCaption, xml Element, mode);80 XMLPortParam(OverlayText, "textsize", setTextSize, getTextSize, xml Element, mode);81 XMLPortParam(OverlayText, "align", setAlignmentString, getAlignmentString, xml Element, mode);82 XMLPortParam(OverlayText, "spacewidth", setSpaceWidth, getSpaceWidth, xml Element, mode);77 XMLPortParam(OverlayText, "font", setFont, getFont, xmlelement, mode); 78 XMLPortParam(OverlayText, "colour", setColour, getColour, xmlelement, mode); 79 XMLPortParam(OverlayText, "caption", setCaption, getCaption, xmlelement, mode); 80 XMLPortParam(OverlayText, "textsize", setTextSize, getTextSize, xmlelement, mode); 81 XMLPortParam(OverlayText, "align", setAlignmentString, getAlignmentString, xmlelement, mode); 82 XMLPortParam(OverlayText, "spacewidth", setSpaceWidth, getSpaceWidth, xmlelement, mode); 83 83 } 84 84 -
code/trunk/src/modules/overlays/OverlayText.h
r5781 r7401 52 52 virtual ~OverlayText(); 53 53 54 virtual void XMLPort(Element& xml Element, XMLPort::Mode mode);54 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 55 55 56 56 void setCaption(const std::string& caption); -
code/trunk/src/modules/overlays/hud/HUDBar.cc
r7368 r7401 55 55 } 56 56 57 void BarColour::XMLPort(Element& xml Element, XMLPort::Mode mode)58 { 59 SUPER(BarColour, XMLPort, xml Element, mode);60 61 XMLPortParam(BarColour, "colour", setColour, getColour, xml Element, mode);62 XMLPortParam(BarColour, "position", setPosition, getPosition, xml Element, mode);57 void BarColour::XMLPort(Element& xmlelement, XMLPort::Mode mode) 58 { 59 SUPER(BarColour, XMLPort, xmlelement, mode); 60 61 XMLPortParam(BarColour, "colour", setColour, getColour, xmlelement, mode); 62 XMLPortParam(BarColour, "position", setPosition, getPosition, xmlelement, mode); 63 63 } 64 64 … … 104 104 } 105 105 106 void HUDBar::XMLPort(Element& xml Element, XMLPort::Mode mode)107 { 108 SUPER(HUDBar, XMLPort, xml Element, mode);109 110 XMLPortParam(HUDBar, "initialvalue", setValue, getValue, xml Element, mode);111 XMLPortParam(HUDBar, "righttoleft", setRightToLeft, getRightToLeft, xml Element, mode);112 XMLPortParam(HUDBar, "autocolour", setAutoColour, getAutoColour, xml Element, mode);113 XMLPortParam(HUDBar, "bartexture", setBarTexture, getBarTexture, xml Element, mode);114 XMLPortObject(HUDBar, BarColour, "", addColour, getColour, xml Element, mode);106 void HUDBar::XMLPort(Element& xmlelement, XMLPort::Mode mode) 107 { 108 SUPER(HUDBar, XMLPort, xmlelement, mode); 109 110 XMLPortParam(HUDBar, "initialvalue", setValue, getValue, xmlelement, mode); 111 XMLPortParam(HUDBar, "righttoleft", setRightToLeft, getRightToLeft, xmlelement, mode); 112 XMLPortParam(HUDBar, "autocolour", setAutoColour, getAutoColour, xmlelement, mode); 113 XMLPortParam(HUDBar, "bartexture", setBarTexture, getBarTexture, xmlelement, mode); 114 XMLPortObject(HUDBar, BarColour, "", addColour, getColour, xmlelement, mode); 115 115 } 116 116 -
code/trunk/src/modules/overlays/hud/HUDBar.h
r5781 r7401 50 50 virtual ~BarColour() { } 51 51 52 virtual void XMLPort(Element& xml Element, XMLPort::Mode mode);52 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 53 53 54 54 void setColour(const ColourValue& colour) { this->colour_ = colour; } … … 70 70 virtual ~HUDBar(); 71 71 72 virtual void XMLPort(Element& xml Element, XMLPort::Mode mode);72 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 73 73 74 74 void clearColours(); -
code/trunk/src/modules/overlays/hud/HUDHealthBar.h
r6417 r7401 45 45 virtual ~HUDHealthBar(); 46 46 47 virtual void XMLPort(Element& xml Element, XMLPort::Mode mode);47 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 48 48 virtual void tick(float dt); 49 49 virtual void changedOwner(); -
code/trunk/src/modules/overlays/hud/HUDNavigation.cc
r7368 r7401 90 90 } 91 91 92 void HUDNavigation::XMLPort ( Element& xml Element, XMLPort::Mode mode )93 { 94 SUPER ( HUDNavigation, XMLPort, xml Element, mode );95 96 XMLPortParam ( HUDNavigation, "font", setFont, getFont, xml Element, mode );97 XMLPortParam ( HUDNavigation, "textSize", setTextSize, getTextSize, xml Element, mode );98 XMLPortParam ( HUDNavigation, "navMarkerSize", setNavMarkerSize, getNavMarkerSize, xml Element, mode );92 void HUDNavigation::XMLPort ( Element& xmlelement, XMLPort::Mode mode ) 93 { 94 SUPER ( HUDNavigation, XMLPort, xmlelement, mode ); 95 96 XMLPortParam ( HUDNavigation, "font", setFont, getFont, xmlelement, mode ); 97 XMLPortParam ( HUDNavigation, "textSize", setTextSize, getTextSize, xmlelement, mode ); 98 XMLPortParam ( HUDNavigation, "navMarkerSize", setNavMarkerSize, getNavMarkerSize, xmlelement, mode ); 99 99 } 100 100 -
code/trunk/src/modules/overlays/hud/HUDNavigation.h
r7163 r7401 51 51 void setConfigValues(); 52 52 53 virtual void XMLPort ( Element& xml Element, XMLPort::Mode mode );53 virtual void XMLPort ( Element& xmlelement, XMLPort::Mode mode ); 54 54 virtual void tick ( float dt ); 55 55 -
code/trunk/src/modules/overlays/hud/HUDRadar.cc
r7368 r7401 82 82 } 83 83 84 void HUDRadar::XMLPort(Element& xml Element, XMLPort::Mode mode)84 void HUDRadar::XMLPort(Element& xmlelement, XMLPort::Mode mode) 85 85 { 86 SUPER(HUDRadar, XMLPort, xml Element, mode);86 SUPER(HUDRadar, XMLPort, xmlelement, mode); 87 87 88 XMLPortParam(HUDRadar, "sensitivity", setRadarSensitivity, getRadarSensitivity, xml Element, mode);89 XMLPortParam(HUDRadar, "halfDotSizeDistance", setHalfDotSizeDistance, getHalfDotSizeDistance, xml Element, mode);90 XMLPortParam(HUDRadar, "maximumDotSize", setMaximumDotSize, getMaximumDotSize, xml Element, mode);88 XMLPortParam(HUDRadar, "sensitivity", setRadarSensitivity, getRadarSensitivity, xmlelement, mode); 89 XMLPortParam(HUDRadar, "halfDotSizeDistance", setHalfDotSizeDistance, getHalfDotSizeDistance, xmlelement, mode); 90 XMLPortParam(HUDRadar, "maximumDotSize", setMaximumDotSize, getMaximumDotSize, xmlelement, mode); 91 91 } 92 92 -
code/trunk/src/modules/overlays/hud/HUDRadar.h
r7163 r7401 49 49 virtual ~HUDRadar(); 50 50 51 virtual void XMLPort(Element& xml Element, XMLPort::Mode mode);51 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 52 52 virtual void changedOwner(); 53 53 -
code/trunk/src/modules/overlays/stats/Scoreboard.cc
r6502 r7401 54 54 this->lines_.pop_back(); 55 55 } 56 }57 58 /**59 @brief Initializes the lines.60 */61 void Scoreboard::XMLPort(Element& xmlElement, XMLPort::Mode mode)62 {63 SUPER(Scoreboard, XMLPort, xmlElement, mode);64 56 } 65 57 -
code/trunk/src/modules/overlays/stats/Scoreboard.h
r5929 r7401 44 44 virtual ~Scoreboard(); 45 45 46 virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);47 46 virtual void tick(float dt); 48 47 -
code/trunk/src/modules/overlays/stats/Stats.cc
r6502 r7401 98 98 } 99 99 100 /**101 @brief Initializes the Stats panel.102 */103 void Stats::XMLPort(Element& xmlElement, XMLPort::Mode mode)104 {105 OrxonoxOverlay::XMLPort(xmlElement, mode);106 }107 108 100 void Stats::tick(float dt) 109 101 { -
code/trunk/src/modules/overlays/stats/Stats.h
r5781 r7401 46 46 void setConfigValues(); 47 47 48 virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);49 50 48 virtual void tick(float dt); 51 49 -
code/trunk/src/modules/pickup/DroppedPickup.cc
r7163 r7401 61 61 @param pickup 62 62 The Pickupable that was dropped. 63 @param position64 The position at which the DroppedPickup should be created.63 @param carrier 64 The PickupCarrier that carried the input pickup before it was dropped. 65 65 @param triggerDistance 66 66 The distance at which the PickupSpawner triggers. Default is 10. -
code/trunk/src/modules/pickup/Pickup.cc
r7208 r7401 225 225 This method must be implemented by any class directly inheriting from Pickupable. It is most easily done by just creating a new DroppedPickup, e.g.: 226 226 DroppedPickup(BaseObject* creator, Pickupable* pickup, const Vector3& position); 227 @param position228 The position at which the PickupSpawner should be placed.229 227 @return 230 228 Returns true if a spawner was created, false if not. -
code/trunk/src/modules/pickup/PickupCollection.cc
r7163 r7401 228 228 @brief 229 229 Get whether a given class, represented by the input Identifier, is a target of this PickupCollection. 230 @param identifier231 A pointer to the Pickup Identifier of the PickupCarrier we want to know of, whether it is a target of this PickupCollection.230 @param carrier 231 A pointer to the PickupCarrier we want to know of, whether it is a target of this PickupCollection. 232 232 @return 233 233 Returns true if the PickupCarrier identified by the input PickupIdentififer it is a target of this PickupCollection, false if not. … … 336 336 This method must be implemented by any class directly inheriting from Pickupable. It is most easily done by just creating a new DroppedPickup, e.g.: 337 337 DroppedPickup(BaseObject* creator, Pickupable* pickup, const Vector3& position); 338 @param position339 The position at which the PickupSpawner should be placed.340 338 @return 341 339 Returns true if a spawner was created, false if not. -
code/trunk/src/modules/pickup/PickupCollectionIdentifier.cc
r7163 r7401 99 99 @brief 100 100 Add a Pickupable to the PickupCollectionIdentifier. 101 @param 101 @param identifier 102 102 A pointer to the PickupIdentifier of the Pickupable to be added. 103 103 */ -
code/trunk/src/modules/pickup/PickupSpawner.cc
r7163 r7401 70 70 @param respawnTime 71 71 The minimum time between two spawns. 72 @param ma ySpawnedItems72 @param maxSpawnedItems 73 73 The maximum number of items spawned by this PickupSpawner. 74 74 */ -
code/trunk/src/modules/pickup/items/SpeedPickup.cc
r7208 r7401 252 252 @brief 253 253 Sets the SpeedMultiply 254 @param speed Add254 @param speedMultiply 255 255 The multiplied Speed 256 256 */ -
code/trunk/src/modules/questsystem/CMakeLists.txt
r7164 r7401 1 1 SET_SOURCE_FILES(QUESTSYSTEM_SRC_FILES 2 AddQuest.cc3 AddQuestHint.cc4 AddReward.cc5 ChangeQuestStatus.cc6 CompleteQuest.cc7 FailQuest.cc8 2 GlobalQuest.cc 9 3 LocalQuest.cc … … 18 12 QuestNotification.cc 19 13 ) 14 15 ADD_SUBDIRECTORY(effects) 20 16 21 17 ORXONOX_ADD_LIBRARY(questsystem -
code/trunk/src/modules/questsystem/GlobalQuest.h
r5781 r7401 50 50 Creating a GlobalQuest through XML goes as follows: 51 51 52 <GlobalQuest id="questId"> //Where questId is a GUID, see http://en.wikipedia.org/wiki/Globally_Unique_Identifier#Basic_structure for more information 52 @code 53 <GlobalQuest id="questId"> 53 54 <QuestDescription title="Title" description="Description." /> //The description of the quest. 54 55 <subquests> … … 78 79 </reward-effects> 79 80 </GlobalQuest> 81 @endcode 80 82 @author 81 83 Damian 'Mozork' Frick -
code/trunk/src/modules/questsystem/LocalQuest.h
r5781 r7401 49 49 Creating a LocalQuest through XML goes as follows: 50 50 51 <LocalQuest id="questId"> //Where questId is a GUID, see http://en.wikipedia.org/wiki/Globally_Unique_Identifier#Basic_structure for more information 51 @code 52 <LocalQuest id="questId"> 52 53 <QuestDescription title="Title" description="Description." /> //The description of the quest. 53 54 <subquests> … … 72 73 </complete-effects> 73 74 </LocalQuest> 75 @endcode 74 76 @author 75 77 Damian 'Mozork' Frick -
code/trunk/src/modules/questsystem/Quest.cc
r7163 r7401 197 197 @brief 198 198 Returns the subquest at the given index. 199 @param 199 @param index 200 200 The index. 201 201 @return … … 222 222 @brief 223 223 Returns the QuestHint at the given index. 224 @param 224 @param index 225 225 The index. 226 226 @return … … 246 246 @brief 247 247 Returns the fail QuestEffect at the given index. 248 @param 248 @param index 249 249 The index. 250 250 @return … … 270 270 @brief 271 271 Returns the complete QuestEffect at the given index. 272 @param 272 @param index 273 273 The index. 274 274 @return -
code/trunk/src/modules/questsystem/QuestDescription.h
r7163 r7401 50 50 Creating a QuestDescription through XML goes as follows: 51 51 52 @code 52 53 <QuestDescription title="Title" description="Description Text" failMessage="You fail." completeMessage="You win!" /> 54 @endcode 53 55 @author 54 56 Damian 'Mozork' Frick -
code/trunk/src/modules/questsystem/QuestEffectBeacon.cc
r7163 r7401 92 92 Executes the QuestEffectBeacon. 93 93 This means extracting the Pawn from the PlayerTrigger, provided by the Event causing the execution, and the extracting the PlayerInfo from the received Pawn and invoking the QuestEffectbeacon's QuestEffects on the received PlayerInfo. 94 @param bTriggered 95 true means the trigger was activated while false means it was deactivated 94 96 @param trigger 95 97 A pointer to the PlayerTrigger that threw the Event. … … 97 99 Returns true if successfully executed, false if not. 98 100 */ 99 bool QuestEffectBeacon::execute(bool b , BaseObject* trigger)100 { 101 if(!b )101 bool QuestEffectBeacon::execute(bool bTriggered, BaseObject* trigger) 102 { 103 if(!bTriggered) 102 104 { 103 105 return false; -
code/trunk/src/modules/questsystem/QuestEffectBeacon.h
r6800 r7401 61 61 Creating a QuestEffectBeacon through XML goes as follows: 62 62 63 @code 63 64 <QuestEffectBeacon times=n> //Where 'n' is eighter a number >= 0, which means the QuestEffectBeacon can be executed n times. Or n = -1, which means the QuestEffectBeacon can be executed an infinite number of times. 64 65 <effects> … … 76 77 </attached> 77 78 </QuestEffectBeacon> 79 @endcode 78 80 @author 79 81 Damian 'Mozork' Frick … … 88 90 virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode); 89 91 90 bool execute(bool b , BaseObject* trigger); //!< Executes the QuestEffects of the QuestEffectBeacon.92 bool execute(bool bTriggered, BaseObject* trigger); //!< Executes the QuestEffects of the QuestEffectBeacon. 91 93 92 94 /** -
code/trunk/src/modules/questsystem/QuestHint.h
r7163 r7401 60 60 Creating a QuestHint through XML goes as follows: 61 61 62 <QuestHint id="hintId"> //Where hintId is a GUID, see http://en.wikipedia.org/wiki/Globally_Unique_Identifier#Basic_structure for more information 62 @code 63 <QuestHint id="hintId"> 63 64 <QuestDesctription title="" description="" /> 64 65 </QuestHint> 66 @endcode 65 67 @author 66 68 Damian 'Mozork' Frick -
code/trunk/src/modules/questsystem/QuestItem.cc
r7163 r7401 78 78 @brief 79 79 Sets the id of the QuestItem. 80 The id must be of GUID form. See 'http://en.wikipedia.org/wiki/Globally_Unique_Identifier#Basic_structure' for more information. 80 The id can be any string and must be unique in the context it is used (commonly a level file). To ensure uniqueness one could use GUIDs, however they are in general less readable, so make your own choice. 81 @see 82 http://en.wikipedia.org/wiki/Globally_Unique_Identifier#Basic_structure 81 83 @param id 82 84 The id to be set. -
code/trunk/src/modules/questsystem/QuestItem.h
r7163 r7401 98 98 99 99 private: 100 std::string id_; //!< Identifier. Should be of GUID form: http://en.wikipedia.org/wiki/Globally_Unique_Identifier#Basic_structure100 std::string id_; //!< Identifier. Must be unique. 101 101 QuestDescription* description_; //!< The QuestDescription of the QuestItem. 102 102 -
code/trunk/src/modules/questsystem/QuestListener.h
r5781 r7401 62 62 You can use the QuestListener as if it were a Trigger or EventListener, that fires an Event when the status (depending on the set mode) of the given Quest changes. 63 63 64 @code 64 65 <BaseObject> // The object that should react to the status change of a Quest. 65 66 <events> … … 69 70 </events> 70 71 </BaseObject> 72 @endcode 71 73 @author 72 74 Damian 'Mozork' Frick -
code/trunk/src/modules/questsystem/QuestNotification.cc
r7163 r7401 48 48 @brief 49 49 Creates a QuestNotification with the input message. 50 @param creator 51 The creator of this object 50 52 @param message 51 53 The message to be sent. -
code/trunk/src/orxonox/CMakeLists.txt
r7163 r7401 19 19 20 20 INCLUDE_DIRECTORIES( 21 ${CMAKE_SOURCE_DIR}/src/external22 21 ${CMAKE_SOURCE_DIR}/src/libraries 23 22 ${CMAKE_CURRENT_SOURCE_DIR} -
code/trunk/src/orxonox/Main.cc
r7163 r7401 43 43 #include "Main.h" 44 44 45 SetCommandLineSwitch(console).information("Start in console mode (text IO only)");46 // Shortcuts for easy direct loading47 SetCommandLineSwitch(server).information("Start in server mode");48 SetCommandLineSwitch(client).information("Start in client mode");49 SetCommandLineSwitch(dedicated).information("Start in dedicated server mode");50 SetCommandLineSwitch(standalone).information("Start in standalone mode");51 SetCommandLineSwitch(dedicatedClient).information("Start in dedicated client mode");52 53 45 DeclareToluaInterface(Orxonox); 54 46 DeclareToluaInterface(Network); … … 56 48 namespace orxonox 57 49 { 50 SetCommandLineSwitch(console).information("Start in console mode (text IO only)"); 51 SetCommandLineSwitch(server).information("Start in server mode"); 52 SetCommandLineSwitch(client).information("Start in client mode"); 53 SetCommandLineSwitch(dedicated).information("Start in dedicated server mode"); 54 SetCommandLineSwitch(standalone).information("Start in standalone mode"); 55 SetCommandLineSwitch(dedicatedClient).information("Start in dedicated client mode"); 56 57 SetCommandLineArgument(generateDoc, "") 58 .information("Generates a Doxygen file from things like SetConsoleCommand"); 59 58 60 /** 59 61 @brief … … 64 66 Game* game = new Game(strCmdLine); 65 67 66 game->setStateHierarchy( 67 "root" 68 " graphics" 69 " mainMenu" 70 " standalone,server,client" 71 " level" 72 " server,client" 73 " level" 74 ); 68 if (CommandLineParser::getValue("generateDoc").getString().empty()) 69 { 70 game->setStateHierarchy( 71 "root" 72 " graphics" 73 " mainMenu" 74 " standalone,server,client" 75 " level" 76 " server,client" 77 " level" 78 ); 75 79 76 game->requestState("root");80 game->requestState("root"); 77 81 78 // Some development hacks (not really, but in the future, this calls won't make sense anymore) 79 if (CommandLineParser::getValue("standalone").getBool()) 80 Game::getInstance().requestStates("graphics, standalone, level"); 81 else if (CommandLineParser::getValue("server").getBool()) 82 Game::getInstance().requestStates("graphics, server, level"); 83 else if (CommandLineParser::getValue("client").getBool()) 84 Game::getInstance().requestStates("graphics, client, level"); 85 else if (CommandLineParser::getValue("dedicated").getBool()) 86 Game::getInstance().requestStates("server, level"); 87 else if (CommandLineParser::getValue("dedicatedClient").getBool()) 88 Game::getInstance().requestStates("client, level"); 89 else 90 { 91 if (!CommandLineParser::getValue("console").getBool()) 92 Game::getInstance().requestStates("graphics, mainMenu"); 82 // Some development hacks (not really, but in the future, these calls won't make sense anymore) 83 if (CommandLineParser::getValue("standalone").getBool()) 84 Game::getInstance().requestStates("graphics, standalone, level"); 85 else if (CommandLineParser::getValue("server").getBool()) 86 Game::getInstance().requestStates("graphics, server, level"); 87 else if (CommandLineParser::getValue("client").getBool()) 88 Game::getInstance().requestStates("graphics, client, level"); 89 else if (CommandLineParser::getValue("dedicated").getBool()) 90 Game::getInstance().requestStates("server, level"); 91 else if (CommandLineParser::getValue("dedicatedClient").getBool()) 92 Game::getInstance().requestStates("client, level"); 93 else 94 { 95 if (!CommandLineParser::getValue("console").getBool()) 96 Game::getInstance().requestStates("graphics, mainMenu"); 97 } 98 99 game->run(); 93 100 } 94 101 95 game->run();96 102 delete game; 97 103 -
code/trunk/src/orxonox/collisionshapes/CollisionShape.cc
r5781 r7401 150 150 } 151 151 152 void CollisionShape::calculateLocalInertia( btScalarmass, btVector3& inertia) const152 void CollisionShape::calculateLocalInertia(float mass, btVector3& inertia) const 153 153 { 154 154 if (this->collisionShape_) -
code/trunk/src/orxonox/controllers/ArtificialController.cc
r7284 r7401 558 558 559 559 /** 560 @brief Master sets its slaves free for @ varFREEDOM_COUNT seconds.560 @brief Master sets its slaves free for @ref FREEDOM_COUNT seconds. 561 561 */ 562 562 void ArtificialController::forceFreeSlaves() … … 665 665 @brief Master begins to follow a pawn. Is a "specific master action". 666 666 @param pawn pawn to follow. 667 @param al aways follows pawn forever if true (false if omitted).667 @param always follows pawn forever if true (false if omitted). 668 668 @param secondsToFollow seconds to follow the pawn if always is false. Will follow pawn 100 seconds if omitted (set in header). 669 669 */ -
code/trunk/src/orxonox/gamestates/GSServer.cc
r6105 r7401 53 53 void GSServer::activate() 54 54 { 55 GameMode::set HasServer(true);55 GameMode::setIsServer(true); 56 56 57 57 this->server_ = new Server(CommandLineParser::getValue("port")); … … 66 66 delete this->server_; 67 67 68 GameMode::set HasServer(false);68 GameMode::setIsServer(false); 69 69 } 70 70 -
code/trunk/src/orxonox/graphics/Light.h
r7163 r7401 83 83 /** 84 84 @brief Sets the attenuation parameters of the light source i.e. how it diminishes with distance. 85 @param attenuation The parameters of the attenuation (see description) 85 86 86 @paramattenuation.x range (The absolute upper range of the light in world units)87 @paramattenuation.y constant (The constant factor in the attenuation formula: 1.0 means never attenuate, 0.0 is complete attenuation)88 @paramattenuation.z linear (The linear factor in the attenuation formula: 1 means attenuate evenly over the distance)89 @paramattenuation.w quadratic (The quadratic factor in the attenuation formula: adds a curvature to the attenuation formula)87 - @a attenuation.x range (The absolute upper range of the light in world units) 88 - @a attenuation.y constant (The constant factor in the attenuation formula: 1.0 means never attenuate, 0.0 is complete attenuation) 89 - @a attenuation.z linear (The linear factor in the attenuation formula: 1 means attenuate evenly over the distance) 90 - @a attenuation.w quadratic (The quadratic factor in the attenuation formula: adds a curvature to the attenuation formula) 90 91 91 92 Quote from the Ogre API: … … 120 121 /** 121 122 @brief Sets the range of a spotlight, i.e. the angle of the inner and outer cones and the rate of falloff between them. 122 123 @param spotlightRange.x innerAngle (The angle covered by the bright inner cone) 124 @param spotlightRange.x outerAngle (The angle covered by the outer cone) 125 @param spotlightRange.x falloff (The rate of falloff between the inner and outer cones. 1.0 means a linear falloff, less means slower falloff, higher means faster falloff.) 123 @param spotlightRange The parameters of the spotlight (see description) 124 125 - @a spotlightRange.x innerAngle (The angle covered by the bright inner cone) 126 - @a spotlightRange.x outerAngle (The angle covered by the outer cone) 127 - @a spotlightRange.x falloff (The rate of falloff between the inner and outer cones. 1.0 means a linear falloff, less means slower falloff, higher means faster falloff.) 126 128 */ 127 129 inline void setSpotlightRange(const Vector3& spotlightRange) -
code/trunk/src/orxonox/interfaces/Pickupable.h
r7163 r7401 161 161 @brief Facilitates the creation of a PickupSpawner upon dropping of the Pickupable. 162 162 This method must be implemented by any class directly inheriting from Pickupable. It is most easily done by just creating a new DroppedPickup, e.g.: 163 DroppedPickup(BaseObject* creator, Pickupable* pickup, const Vector3& position, float triggerDistance); 164 @param position The position at which the PickupSpawner should be placed. 163 DroppedPickup(BaseObject* creator, Pickupable* pickup, PickupCarrier* carrier, float triggerDistance); 165 164 @return Returns true if a spawner was created, false if not. 166 165 */ -
code/trunk/src/orxonox/overlays/GUISheet.cc
r7163 r7401 54 54 } 55 55 56 void GUISheet::XMLPort(Element& xml Element, XMLPort::Mode mode)56 void GUISheet::XMLPort(Element& xmlelement, XMLPort::Mode mode) 57 57 { 58 SUPER(GUISheet, XMLPort, xml Element, mode);58 SUPER(GUISheet, XMLPort, xmlelement, mode); 59 59 60 XMLPortParam(GUISheet, "showOnLoad", setShowOnLoad, getShowOnLoad, xml Element, mode);61 XMLPortParam(GUISheet, "hidePrevious", setPreviousHiding, getPreviousHiding, xml Element, mode);62 XMLPortParam(GUISheet, "sheetName", setSheetName, getSheetName, xml Element, mode);63 XMLPortParam(GUISheet, "backgroundImage", setBackgroundImage, getBackgroundImage, xml Element, mode);60 XMLPortParam(GUISheet, "showOnLoad", setShowOnLoad, getShowOnLoad, xmlelement, mode); 61 XMLPortParam(GUISheet, "hidePrevious", setPreviousHiding, getPreviousHiding, xmlelement, mode); 62 XMLPortParam(GUISheet, "sheetName", setSheetName, getSheetName, xmlelement, mode); 63 XMLPortParam(GUISheet, "backgroundImage", setBackgroundImage, getBackgroundImage, xmlelement, mode); 64 64 65 65 if (this->bShowOnLoad_) -
code/trunk/src/orxonox/overlays/GUISheet.h
r6746 r7401 44 44 ~GUISheet(); 45 45 46 void XMLPort(Element& xml Element, XMLPort::Mode mode);46 void XMLPort(Element& xmlelement, XMLPort::Mode mode); 47 47 48 48 void show(); -
code/trunk/src/orxonox/overlays/InGameConsole.cc
r7284 r7401 454 454 /** 455 455 @brief Prints string to bottom line. 456 @param s String to be printed 456 @param text The string to be printed 457 @param type The type of the text, defines the color 458 @param index The index of the text overlay in which the string will be displayed 459 @param alwaysShift If true the ohter lines in the console are always shifted by one line 457 460 */ 458 461 void InGameConsole::print(const std::string& text, Shell::LineType type, int index, bool alwaysShift) -
code/trunk/src/orxonox/overlays/OrxonoxOverlay.cc
r7284 r7401 126 126 BaseObject::XMLPort() 127 127 */ 128 void OrxonoxOverlay::XMLPort(Element& xml Element, XMLPort::Mode mode)129 { 130 SUPER(OrxonoxOverlay, XMLPort, xml Element, mode);131 132 XMLPortParam(OrxonoxOverlay, "size", setSize, getSize, xml Element, mode);133 XMLPortParam(OrxonoxOverlay, "pickpoint", setPickPoint, getPickPoint, xml Element, mode);134 XMLPortParam(OrxonoxOverlay, "position", setPosition, getPosition, xml Element, mode);135 XMLPortParam(OrxonoxOverlay, "rotation", setRotation, getRotation, xml Element, mode);136 XMLPortParam(OrxonoxOverlay, "correctaspect", setAspectCorrection, getAspectCorrection, xml Element, mode);137 XMLPortParam(OrxonoxOverlay, "background", setBackgroundMaterial, getBackgroundMaterial, xml Element, mode);128 void OrxonoxOverlay::XMLPort(Element& xmlelement, XMLPort::Mode mode) 129 { 130 SUPER(OrxonoxOverlay, XMLPort, xmlelement, mode); 131 132 XMLPortParam(OrxonoxOverlay, "size", setSize, getSize, xmlelement, mode); 133 XMLPortParam(OrxonoxOverlay, "pickpoint", setPickPoint, getPickPoint, xmlelement, mode); 134 XMLPortParam(OrxonoxOverlay, "position", setPosition, getPosition, xmlelement, mode); 135 XMLPortParam(OrxonoxOverlay, "rotation", setRotation, getRotation, xmlelement, mode); 136 XMLPortParam(OrxonoxOverlay, "correctaspect", setAspectCorrection, getAspectCorrection, xmlelement, mode); 137 XMLPortParam(OrxonoxOverlay, "background", setBackgroundMaterial, getBackgroundMaterial, xmlelement, mode); 138 138 } 139 139 … … 306 306 The name of the overlay defined BaseObject::setName() (usually done with the "name" 307 307 attribute in the xml file). 308 @param scale 309 The scaling factor 308 310 */ 309 311 /*static*/ void OrxonoxOverlay::scaleOverlay(const std::string& name, float scale) … … 346 348 The name of the overlay defined BaseObject::setName() (usually done with the "name" 347 349 attribute in the xml file). 350 @param scroll 351 The relative translation of the overlay 348 352 */ 349 353 /*static*/ void OrxonoxOverlay::scrollOverlay(const std::string& name, const Vector2& scroll) … … 360 364 The name of the overlay defined BaseObject::setName() (usually done with the "name" 361 365 attribute in the xml file). 366 @param angle 367 The rotation angle in degree 362 368 */ 363 369 /*static*/ void OrxonoxOverlay::rotateOverlay(const std::string& name, const Degree& angle) -
code/trunk/src/orxonox/overlays/OrxonoxOverlay.h
r6753 r7401 90 90 virtual ~OrxonoxOverlay(); 91 91 92 virtual void XMLPort(Element& xml Element, XMLPort::Mode mode);92 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 93 93 94 94 virtual void changedName(); -
code/trunk/src/orxonox/overlays/OverlayGroup.cc
r7284 r7401 71 71 BaseObject::XMLPort() 72 72 */ 73 void OverlayGroup::XMLPort(Element& xml Element, XMLPort::Mode mode)74 { 75 SUPER(OverlayGroup, XMLPort, xml Element, mode);76 77 XMLPortParam(OverlayGroup, "scale", setScale, getScale, xml Element, mode);78 XMLPortParam(OverlayGroup, "scroll", setScroll, getScroll, xml Element, mode);73 void OverlayGroup::XMLPort(Element& xmlelement, XMLPort::Mode mode) 74 { 75 SUPER(OverlayGroup, XMLPort, xmlelement, mode); 76 77 XMLPortParam(OverlayGroup, "scale", setScale, getScale, xmlelement, mode); 78 XMLPortParam(OverlayGroup, "scroll", setScroll, getScroll, xmlelement, mode); 79 79 // loads all the child elements 80 XMLPortObject(OverlayGroup, OrxonoxOverlay, "", addElement, getElement, xml Element, mode);80 XMLPortObject(OverlayGroup, OrxonoxOverlay, "", addElement, getElement, xmlelement, mode); 81 81 } 82 82 … … 114 114 @brief 115 115 Removes an element from the map. 116 @param name117 The name ofthe element that is removed.116 @param element 117 A pointer to the element that is removed. 118 118 @return 119 119 Returns true if there was such an element to remove, false if not. … … 181 181 The name of the group defined BaseObject::setName() (usually done with the "name" 182 182 attribute in the xml file). 183 @param scale 184 The scaling factor 183 185 */ 184 186 /*static*/ void OverlayGroup::scaleGroup(const std::string& name, float scale) … … 197 199 The name of the group defined BaseObject::setName() (usually done with the "name" 198 200 attribute in the xml file). 201 @param scroll 202 The relative translation of the overlay group 199 203 */ 200 204 /*static*/ void OverlayGroup::scrollGroup(const std::string& name, const Vector2& scroll) -
code/trunk/src/orxonox/overlays/OverlayGroup.h
r6054 r7401 58 58 ~OverlayGroup(); 59 59 60 virtual void XMLPort(Element& xml Element, XMLPort::Mode mode);60 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 61 61 62 62 static void toggleVisibility(const std::string& name); -
code/trunk/src/orxonox/worldentities/WorldEntity.cc
r7163 r7401 267 267 @brief 268 268 Attaches this object to a parent SceneNode. 269 @ Remarks269 @remarks 270 270 Only use this method if you know exactly what you're doing! 271 271 Normally, attaching works internally by attaching WE's. … … 282 282 @brief 283 283 Detaches this object from a parent SceneNode. 284 @ Remarks284 @remarks 285 285 Only use this method if you know exactly what you're doing! 286 286 Normally, attaching works internally by attaching WE's. … … 355 355 Attaches a child WorldEntity to this object. This calls notifyBeingAttached() 356 356 of the child WE. 357 @ Note357 @note 358 358 The collision shape of the child object gets attached nevertheless. That also means 359 359 that you can change the collision shape of the child and it correctly cascadeds the changes to this instance. … … 628 628 @brief 629 629 Sets the three dimensional scaling of this object. 630 @ Note630 @note 631 631 Scaling physical objects has not yet been implemented and is therefore forbidden. 632 632 */ … … 650 650 @brief 651 651 Translates this WorldEntity by a vector. 652 @param distance 653 The relative distance of the translation 652 654 @param relativeTo 653 @see WorldEntity::TransformSpace655 The TransformSpace of this translation 654 656 */ 655 657 void WorldEntity::translate(const Vector3& distance, TransformSpace relativeTo) … … 678 680 @brief 679 681 Rotates this WorldEntity by a quaternion. 682 @param rotation 683 The desired relative rotation 680 684 @param relativeTo 681 @see WorldEntity::TransformSpace685 The TransformSpace of this translation 682 686 */ 683 687 void WorldEntity::rotate(const Quaternion& rotation, TransformSpace relativeTo) … … 703 707 @brief 704 708 Makes this WorldEntity look at a specific target location. 709 @param target 710 An absolute point in the space which defines the direction of the entity 705 711 @param relativeTo 706 @see WorldEntity::TransformSpace712 The TransformSpace of this translation 707 713 @param localDirectionVector 708 714 The vector which normally describes the natural direction of the object, usually -Z. … … 729 735 @brief 730 736 Makes this WorldEntity look in specific direction. 737 @param direction 738 A point relative to the position of the WorldEntity which defines its orientation 731 739 @param relativeTo 732 @see WorldEntity::TransformSpace740 The TransformSpace of this translation 733 741 @param localDirectionVector 734 742 The vector which normally describes the natural direction of the object, usually -Z. … … 773 781 /** 774 782 @brief 775 Sets the CollisionType. This alters the object significantly! @see CollisionType.776 @ Note783 Sets the CollisionType. This alters the object significantly! 784 @note 777 785 Operation does not work on attached WorldEntities. 778 786 */ … … 900 908 Recalculates the accumulated child mass and calls recalculateMassProps() 901 909 and notifies the parent of the change. 902 @ Note910 @note 903 911 Called by a child WE 904 912 */ … … 919 927 @brief 920 928 Undertakes the necessary steps to change the collision shape in Bullet, even at runtime. 921 @ Note929 @note 922 930 - called by this->collisionShape_ 923 931 - May have a REALLY big overhead when called continuously at runtime, because then we need -
code/trunk/src/orxonox/worldentities/WorldEntity.h
r7163 r7401 299 299 @brief 300 300 Returns the diagonal elements of the inertia tensor when calculated in local coordinates. 301 @ Note301 @note 302 302 The local inertia tensor cannot be set, but is calculated by Bullet according to the collisionShape. 303 303 With compound collision shapes, an approximation is used. … … 367 367 @param otherObject 368 368 The object this one has collided into. 369 @p ram contactPoint369 @param contactPoint 370 370 Contact point provided by Bullet. Holds more information and can me modified. See return value. 371 @ Return371 @return 372 372 Returning false means that no modification to the contactPoint has been made. Return true otherwise! 373 @ Note373 @note 374 374 Condition is that enableCollisionCallback() was called. 375 375 */
Note: See TracChangeset
for help on using the changeset viewer.