├── .gitignore ├── LICENSE.md ├── Makefile ├── README.md ├── doc ├── doxyconfig └── img │ ├── logo.png │ └── stateMachine.svg ├── examples └── stateMachineExample.c ├── src ├── stateMachine.c └── stateMachine.h └── tests └── nestedTest.c /.gitignore: -------------------------------------------------------------------------------- 1 | .*.sw* 2 | *.o 3 | tags 4 | cscope.out 5 | doc/output 6 | bin 7 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT license 2 | =========== 3 | 4 | Copyright (c) 2013 Andreas Misje 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | default: clean dist run 2 | 3 | dist: 4 | mkdir bin/ 5 | gcc -std=c99 -I src src/stateMachine.c examples/stateMachineExample.c -o bin/example 6 | 7 | run: 8 | ./bin/example 9 | 10 | clean: 11 | rm -rf bin -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | stateMachine 2 | ============ 3 | 4 | A feature-rich, yet simple finite state machine (FSM) implementation in C. 5 | 6 | For when a simple switch statement just isn't enough. [Documentation](http://misje.github.io/stateMachine). 7 | -------------------------------------------------------------------------------- /doc/doxyconfig: -------------------------------------------------------------------------------- 1 | # Doxyfile 1.8.1.2 2 | 3 | # This file describes the settings to be used by the documentation system 4 | # doxygen (www.doxygen.org) for a project. 5 | # 6 | # All text after a hash (#) is considered a comment and will be ignored. 7 | # The format is: 8 | # TAG = value [value, ...] 9 | # For lists items can also be appended using: 10 | # TAG += value [value, ...] 11 | # Values that contain spaces should be placed between quotes (" "). 12 | 13 | #--------------------------------------------------------------------------- 14 | # Project related configuration options 15 | #--------------------------------------------------------------------------- 16 | 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 sequence of words) that should 26 | # identify the project. Note that if you do not use Doxywizard you need 27 | # to put quotes around the project name if it contains spaces. 28 | 29 | PROJECT_NAME = "State machine" 30 | 31 | # The PROJECT_NUMBER tag can be used to enter a project or revision number. 32 | # This could be handy for archiving the generated documentation or 33 | # if some version control system is used. 34 | 35 | PROJECT_NUMBER = 36 | 37 | # Using the PROJECT_BRIEF tag one can provide an optional one line description 38 | # for a project that appears at the top of each page and should give viewer 39 | # a quick idea about the purpose of the project. Keep the description short. 40 | 41 | PROJECT_BRIEF = 42 | 43 | # With the PROJECT_LOGO tag one can specify an logo or icon that is 44 | # included in the documentation. The maximum height of the logo should not 45 | # exceed 55 pixels and the maximum width should not exceed 200 pixels. 46 | # Doxygen will copy the logo to the output directory. 47 | 48 | PROJECT_LOGO = img/logo.png 49 | 50 | # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) 51 | # base path where the generated documentation will be put. 52 | # If a relative path is entered, it will be relative to the location 53 | # where doxygen was started. If left blank the current directory will be used. 54 | 55 | OUTPUT_DIRECTORY = output 56 | 57 | # If the CREATE_SUBDIRS tag is set to YES, then doxygen will create 58 | # 4096 sub-directories (in 2 levels) under the output directory of each output 59 | # format and will distribute the generated files over these directories. 60 | # Enabling this option can be useful when feeding doxygen a huge amount of 61 | # source files, where putting all generated files in the same directory would 62 | # otherwise cause performance problems for the file system. 63 | 64 | CREATE_SUBDIRS = NO 65 | 66 | # The OUTPUT_LANGUAGE tag is used to specify the language in which all 67 | # documentation generated by doxygen is written. Doxygen will use this 68 | # information to generate all constant output in the proper language. 69 | # The default language is English, other supported languages are: 70 | # Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, 71 | # Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, 72 | # Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English 73 | # messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, 74 | # Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak, 75 | # Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. 76 | 77 | OUTPUT_LANGUAGE = English 78 | 79 | # If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will 80 | # include brief member descriptions after the members that are listed in 81 | # the file and class documentation (similar to JavaDoc). 82 | # Set to NO to disable this. 83 | 84 | BRIEF_MEMBER_DESC = YES 85 | 86 | # If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend 87 | # the brief description of a member or function before the detailed description. 88 | # Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the 89 | # brief descriptions will be completely suppressed. 90 | 91 | REPEAT_BRIEF = YES 92 | 93 | # This tag implements a quasi-intelligent brief description abbreviator 94 | # that is used to form the text in various listings. Each string 95 | # in this list, if found as the leading text of the brief description, will be 96 | # stripped from the text and the result after processing the whole list, is 97 | # used as the annotated text. Otherwise, the brief description is used as-is. 98 | # If left blank, the following values are used ("$name" is automatically 99 | # replaced with the name of the entity): "The $name class" "The $name widget" 100 | # "The $name file" "is" "provides" "specifies" "contains" 101 | # "represents" "a" "an" "the" 102 | 103 | ABBREVIATE_BRIEF = 104 | 105 | # If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then 106 | # Doxygen will generate a detailed section even if there is only a brief 107 | # description. 108 | 109 | ALWAYS_DETAILED_SEC = NO 110 | 111 | # If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all 112 | # inherited members of a class in the documentation of that class as if those 113 | # members were ordinary class members. Constructors, destructors and assignment 114 | # operators of the base classes will not be shown. 115 | 116 | INLINE_INHERITED_MEMB = NO 117 | 118 | # If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full 119 | # path before files name in the file list and in the header files. If set 120 | # to NO the shortest path that makes the file name unique will be used. 121 | 122 | FULL_PATH_NAMES = NO 123 | 124 | # If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag 125 | # can be used to strip a user-defined part of the path. Stripping is 126 | # only done if one of the specified strings matches the left-hand part of 127 | # the path. The tag can be used to show relative paths in the file list. 128 | # If left blank the directory from which doxygen is run is used as the 129 | # path to strip. 130 | 131 | STRIP_FROM_PATH = 132 | 133 | # The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of 134 | # the path mentioned in the documentation of a class, which tells 135 | # the reader which header file to include in order to use a class. 136 | # If left blank only the name of the header file containing the class 137 | # definition is used. Otherwise one should specify the include paths that 138 | # are normally passed to the compiler using the -I flag. 139 | 140 | STRIP_FROM_INC_PATH = 141 | 142 | # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter 143 | # (but less readable) file names. This can be useful if your file system 144 | # doesn't support long names like on DOS, Mac, or CD-ROM. 145 | 146 | SHORT_NAMES = NO 147 | 148 | # If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen 149 | # will interpret the first line (until the first dot) of a JavaDoc-style 150 | # comment as the brief description. If set to NO, the JavaDoc 151 | # comments will behave just like regular Qt-style comments 152 | # (thus requiring an explicit @brief command for a brief description.) 153 | 154 | JAVADOC_AUTOBRIEF = NO 155 | 156 | # If the QT_AUTOBRIEF tag is set to YES then Doxygen will 157 | # interpret the first line (until the first dot) of a Qt-style 158 | # comment as the brief description. If set to NO, the comments 159 | # will behave just like regular Qt-style comments (thus requiring 160 | # an explicit \brief command for a brief description.) 161 | 162 | QT_AUTOBRIEF = NO 163 | 164 | # The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen 165 | # treat a multi-line C++ special comment block (i.e. a block of //! or /// 166 | # comments) as a brief description. This used to be the default behaviour. 167 | # The new default is to treat a multi-line C++ comment block as a detailed 168 | # description. Set this tag to YES if you prefer the old behaviour instead. 169 | 170 | MULTILINE_CPP_IS_BRIEF = NO 171 | 172 | # If the INHERIT_DOCS tag is set to YES (the default) then an undocumented 173 | # member inherits the documentation from any documented member that it 174 | # re-implements. 175 | 176 | INHERIT_DOCS = YES 177 | 178 | # If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce 179 | # a new page for each member. If set to NO, the documentation of a member will 180 | # be part of the file/class/namespace that contains it. 181 | 182 | SEPARATE_MEMBER_PAGES = NO 183 | 184 | # The TAB_SIZE tag can be used to set the number of spaces in a tab. 185 | # Doxygen uses this value to replace tabs by spaces in code fragments. 186 | 187 | TAB_SIZE = 3 188 | 189 | # This tag can be used to specify a number of aliases that acts 190 | # as commands in the documentation. An alias has the form "name=value". 191 | # For example adding "sideeffect=\par Side Effects:\n" will allow you to 192 | # put the command \sideeffect (or @sideeffect) in the documentation, which 193 | # will result in a user-defined paragraph with heading "Side Effects:". 194 | # You can put \n's in the value part of an alias to insert newlines. 195 | 196 | ALIASES += pn{1}="\1" 197 | 198 | # This tag can be used to specify a number of word-keyword mappings (TCL only). 199 | # A mapping has the form "name=value". For example adding 200 | # "class=itcl::class" will allow you to use the command class in the 201 | # itcl::class meaning. 202 | 203 | TCL_SUBST = 204 | 205 | # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C 206 | # sources only. Doxygen will then generate output that is more tailored for C. 207 | # For instance, some of the names that are used will be different. The list 208 | # of all members will be omitted, etc. 209 | 210 | OPTIMIZE_OUTPUT_FOR_C = NO 211 | 212 | # Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java 213 | # sources only. Doxygen will then generate output that is more tailored for 214 | # Java. For instance, namespaces will be presented as packages, qualified 215 | # scopes will look different, etc. 216 | 217 | OPTIMIZE_OUTPUT_JAVA = NO 218 | 219 | # Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran 220 | # sources only. Doxygen will then generate output that is more tailored for 221 | # Fortran. 222 | 223 | OPTIMIZE_FOR_FORTRAN = NO 224 | 225 | # Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL 226 | # sources. Doxygen will then generate output that is tailored for 227 | # VHDL. 228 | 229 | OPTIMIZE_OUTPUT_VHDL = NO 230 | 231 | # Doxygen selects the parser to use depending on the extension of the files it 232 | # parses. With this tag you can assign which parser to use for a given extension. 233 | # Doxygen has a built-in mapping, but you can override or extend it using this 234 | # tag. The format is ext=language, where ext is a file extension, and language 235 | # is one of the parsers supported by doxygen: IDL, Java, Javascript, CSharp, C, 236 | # C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, C++. For instance to make 237 | # doxygen treat .inc files as Fortran files (default is PHP), and .f files as C 238 | # (default is Fortran), use: inc=Fortran f=C. Note that for custom extensions 239 | # you also need to set FILE_PATTERNS otherwise the files are not read by doxygen. 240 | 241 | EXTENSION_MAPPING = 242 | 243 | # If MARKDOWN_SUPPORT is enabled (the default) then doxygen pre-processes all 244 | # comments according to the Markdown format, which allows for more readable 245 | # documentation. See http://daringfireball.net/projects/markdown/ for details. 246 | # The output of markdown processing is further processed by doxygen, so you 247 | # can mix doxygen, HTML, and XML commands with Markdown formatting. 248 | # Disable only in case of backward compatibilities issues. 249 | 250 | MARKDOWN_SUPPORT = YES 251 | 252 | # If you use STL classes (i.e. std::string, std::vector, etc.) but do not want 253 | # to include (a tag file for) the STL sources as input, then you should 254 | # set this tag to YES in order to let doxygen match functions declarations and 255 | # definitions whose arguments contain STL classes (e.g. func(std::string); v.s. 256 | # func(std::string) {}). This also makes the inheritance and collaboration 257 | # diagrams that involve STL classes more complete and accurate. 258 | 259 | BUILTIN_STL_SUPPORT = NO 260 | 261 | # If you use Microsoft's C++/CLI language, you should set this option to YES to 262 | # enable parsing support. 263 | 264 | CPP_CLI_SUPPORT = NO 265 | 266 | # Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. 267 | # Doxygen will parse them like normal C++ but will assume all classes use public 268 | # instead of private inheritance when no explicit protection keyword is present. 269 | 270 | SIP_SUPPORT = NO 271 | 272 | # For Microsoft's IDL there are propget and propput attributes to indicate getter 273 | # and setter methods for a property. Setting this option to YES (the default) 274 | # will make doxygen replace the get and set methods by a property in the 275 | # documentation. This will only work if the methods are indeed getting or 276 | # setting a simple type. If this is not the case, or you want to show the 277 | # methods anyway, you should set this option to NO. 278 | 279 | IDL_PROPERTY_SUPPORT = YES 280 | 281 | # If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC 282 | # tag is set to YES, then doxygen will reuse the documentation of the first 283 | # member in the group (if any) for the other members of the group. By default 284 | # all members of a group must be documented explicitly. 285 | 286 | DISTRIBUTE_GROUP_DOC = NO 287 | 288 | # Set the SUBGROUPING tag to YES (the default) to allow class member groups of 289 | # the same type (for instance a group of public functions) to be put as a 290 | # subgroup of that type (e.g. under the Public Functions section). Set it to 291 | # NO to prevent subgrouping. Alternatively, this can be done per class using 292 | # the \nosubgrouping command. 293 | 294 | SUBGROUPING = YES 295 | 296 | # When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and 297 | # unions are shown inside the group in which they are included (e.g. using 298 | # @ingroup) instead of on a separate page (for HTML and Man pages) or 299 | # section (for LaTeX and RTF). 300 | 301 | INLINE_GROUPED_CLASSES = NO 302 | 303 | # When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and 304 | # unions with only public data fields will be shown inline in the documentation 305 | # of the scope in which they are defined (i.e. file, namespace, or group 306 | # documentation), provided this scope is documented. If set to NO (the default), 307 | # structs, classes, and unions are shown on a separate page (for HTML and Man 308 | # pages) or section (for LaTeX and RTF). 309 | 310 | INLINE_SIMPLE_STRUCTS = YES 311 | 312 | # When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum 313 | # is documented as struct, union, or enum with the name of the typedef. So 314 | # typedef struct TypeS {} TypeT, will appear in the documentation as a struct 315 | # with name TypeT. When disabled the typedef will appear as a member of a file, 316 | # namespace, or class. And the struct will be named TypeS. This can typically 317 | # be useful for C code in case the coding convention dictates that all compound 318 | # types are typedef'ed and only the typedef is referenced, never the tag name. 319 | 320 | TYPEDEF_HIDES_STRUCT = NO 321 | 322 | # The SYMBOL_CACHE_SIZE determines the size of the internal cache use to 323 | # determine which symbols to keep in memory and which to flush to disk. 324 | # When the cache is full, less often used symbols will be written to disk. 325 | # For small to medium size projects (<1000 input files) the default value is 326 | # probably good enough. For larger projects a too small cache size can cause 327 | # doxygen to be busy swapping symbols to and from disk most of the time 328 | # causing a significant performance penalty. 329 | # If the system has enough physical memory increasing the cache will improve the 330 | # performance by keeping more symbols in memory. Note that the value works on 331 | # a logarithmic scale so increasing the size by one will roughly double the 332 | # memory usage. The cache size is given by this formula: 333 | # 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, 334 | # corresponding to a cache size of 2^16 = 65536 symbols. 335 | 336 | SYMBOL_CACHE_SIZE = 0 337 | 338 | # Similar to the SYMBOL_CACHE_SIZE the size of the symbol lookup cache can be 339 | # set using LOOKUP_CACHE_SIZE. This cache is used to resolve symbols given 340 | # their name and scope. Since this can be an expensive process and often the 341 | # same symbol appear multiple times in the code, doxygen keeps a cache of 342 | # pre-resolved symbols. If the cache is too small doxygen will become slower. 343 | # If the cache is too large, memory is wasted. The cache size is given by this 344 | # formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range is 0..9, the default is 0, 345 | # corresponding to a cache size of 2^16 = 65536 symbols. 346 | 347 | LOOKUP_CACHE_SIZE = 0 348 | 349 | #--------------------------------------------------------------------------- 350 | # Build related configuration options 351 | #--------------------------------------------------------------------------- 352 | 353 | # If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in 354 | # documentation are documented, even if no documentation was available. 355 | # Private class members and static file members will be hidden unless 356 | # the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES 357 | 358 | EXTRACT_ALL = NO 359 | 360 | # If the EXTRACT_PRIVATE tag is set to YES all private members of a class 361 | # will be included in the documentation. 362 | 363 | EXTRACT_PRIVATE = NO 364 | 365 | # If the EXTRACT_PACKAGE tag is set to YES all members with package or internal scope will be included in the documentation. 366 | 367 | EXTRACT_PACKAGE = NO 368 | 369 | # If the EXTRACT_STATIC tag is set to YES all static members of a file 370 | # will be included in the documentation. 371 | 372 | EXTRACT_STATIC = NO 373 | 374 | # If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) 375 | # defined locally in source files will be included in the documentation. 376 | # If set to NO only classes defined in header files are included. 377 | 378 | EXTRACT_LOCAL_CLASSES = YES 379 | 380 | # This flag is only useful for Objective-C code. When set to YES local 381 | # methods, which are defined in the implementation section but not in 382 | # the interface are included in the documentation. 383 | # If set to NO (the default) only methods in the interface are included. 384 | 385 | EXTRACT_LOCAL_METHODS = NO 386 | 387 | # If this flag is set to YES, the members of anonymous namespaces will be 388 | # extracted and appear in the documentation as a namespace called 389 | # 'anonymous_namespace{file}', where file will be replaced with the base 390 | # name of the file that contains the anonymous namespace. By default 391 | # anonymous namespaces are hidden. 392 | 393 | EXTRACT_ANON_NSPACES = NO 394 | 395 | # If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all 396 | # undocumented members of documented classes, files or namespaces. 397 | # If set to NO (the default) these members will be included in the 398 | # various overviews, but no documentation section is generated. 399 | # This option has no effect if EXTRACT_ALL is enabled. 400 | 401 | HIDE_UNDOC_MEMBERS = NO 402 | 403 | # If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all 404 | # undocumented classes that are normally visible in the class hierarchy. 405 | # If set to NO (the default) these classes will be included in the various 406 | # overviews. This option has no effect if EXTRACT_ALL is enabled. 407 | 408 | HIDE_UNDOC_CLASSES = NO 409 | 410 | # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all 411 | # friend (class|struct|union) declarations. 412 | # If set to NO (the default) these declarations will be included in the 413 | # documentation. 414 | 415 | HIDE_FRIEND_COMPOUNDS = NO 416 | 417 | # If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any 418 | # documentation blocks found inside the body of a function. 419 | # If set to NO (the default) these blocks will be appended to the 420 | # function's detailed documentation block. 421 | 422 | HIDE_IN_BODY_DOCS = NO 423 | 424 | # The INTERNAL_DOCS tag determines if documentation 425 | # that is typed after a \internal command is included. If the tag is set 426 | # to NO (the default) then the documentation will be excluded. 427 | # Set it to YES to include the internal documentation. 428 | 429 | INTERNAL_DOCS = NO 430 | 431 | # If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate 432 | # file names in lower-case letters. If set to YES upper-case letters are also 433 | # allowed. This is useful if you have classes or files whose names only differ 434 | # in case and if your file system supports case sensitive file names. Windows 435 | # and Mac users are advised to set this option to NO. 436 | 437 | CASE_SENSE_NAMES = YES 438 | 439 | # If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen 440 | # will show members with their full class and namespace scopes in the 441 | # documentation. If set to YES the scope will be hidden. 442 | 443 | HIDE_SCOPE_NAMES = NO 444 | 445 | # If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen 446 | # will put a list of the files that are included by a file in the documentation 447 | # of that file. 448 | 449 | SHOW_INCLUDE_FILES = YES 450 | 451 | # If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen 452 | # will list include files with double quotes in the documentation 453 | # rather than with sharp brackets. 454 | 455 | FORCE_LOCAL_INCLUDES = NO 456 | 457 | # If the INLINE_INFO tag is set to YES (the default) then a tag [inline] 458 | # is inserted in the documentation for inline members. 459 | 460 | INLINE_INFO = YES 461 | 462 | # If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen 463 | # will sort the (detailed) documentation of file and class members 464 | # alphabetically by member name. If set to NO the members will appear in 465 | # declaration order. 466 | 467 | SORT_MEMBER_DOCS = YES 468 | 469 | # If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the 470 | # brief documentation of file, namespace and class members alphabetically 471 | # by member name. If set to NO (the default) the members will appear in 472 | # declaration order. 473 | 474 | SORT_BRIEF_DOCS = NO 475 | 476 | # If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen 477 | # will sort the (brief and detailed) documentation of class members so that 478 | # constructors and destructors are listed first. If set to NO (the default) 479 | # the constructors will appear in the respective orders defined by 480 | # SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. 481 | # This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO 482 | # and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. 483 | 484 | SORT_MEMBERS_CTORS_1ST = NO 485 | 486 | # If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the 487 | # hierarchy of group names into alphabetical order. If set to NO (the default) 488 | # the group names will appear in their defined order. 489 | 490 | SORT_GROUP_NAMES = NO 491 | 492 | # If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be 493 | # sorted by fully-qualified names, including namespaces. If set to 494 | # NO (the default), the class list will be sorted only by class name, 495 | # not including the namespace part. 496 | # Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. 497 | # Note: This option applies only to the class list, not to the 498 | # alphabetical list. 499 | 500 | SORT_BY_SCOPE_NAME = NO 501 | 502 | # If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to 503 | # do proper type resolution of all parameters of a function it will reject a 504 | # match between the prototype and the implementation of a member function even 505 | # if there is only one candidate or it is obvious which candidate to choose 506 | # by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen 507 | # will still accept a match between prototype and implementation in such cases. 508 | 509 | STRICT_PROTO_MATCHING = NO 510 | 511 | # The GENERATE_TODOLIST tag can be used to enable (YES) or 512 | # disable (NO) the todo list. This list is created by putting \todo 513 | # commands in the documentation. 514 | 515 | GENERATE_TODOLIST = YES 516 | 517 | # The GENERATE_TESTLIST tag can be used to enable (YES) or 518 | # disable (NO) the test list. This list is created by putting \test 519 | # commands in the documentation. 520 | 521 | GENERATE_TESTLIST = YES 522 | 523 | # The GENERATE_BUGLIST tag can be used to enable (YES) or 524 | # disable (NO) the bug list. This list is created by putting \bug 525 | # commands in the documentation. 526 | 527 | GENERATE_BUGLIST = YES 528 | 529 | # The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or 530 | # disable (NO) the deprecated list. This list is created by putting 531 | # \deprecated commands in the documentation. 532 | 533 | GENERATE_DEPRECATEDLIST= YES 534 | 535 | # The ENABLED_SECTIONS tag can be used to enable conditional 536 | # documentation sections, marked by \if sectionname ... \endif. 537 | 538 | ENABLED_SECTIONS = 539 | 540 | # The MAX_INITIALIZER_LINES tag determines the maximum number of lines 541 | # the initial value of a variable or macro consists of for it to appear in 542 | # the documentation. If the initializer consists of more lines than specified 543 | # here it will be hidden. Use a value of 0 to hide initializers completely. 544 | # The appearance of the initializer of individual variables and macros in the 545 | # documentation can be controlled using \showinitializer or \hideinitializer 546 | # command in the documentation regardless of this setting. 547 | 548 | MAX_INITIALIZER_LINES = 30 549 | 550 | # Set the SHOW_USED_FILES tag to NO to disable the list of files generated 551 | # at the bottom of the documentation of classes and structs. If set to YES the 552 | # list will mention the files that were used to generate the documentation. 553 | 554 | SHOW_USED_FILES = YES 555 | 556 | # Set the SHOW_FILES tag to NO to disable the generation of the Files page. 557 | # This will remove the Files entry from the Quick Index and from the 558 | # Folder Tree View (if specified). The default is YES. 559 | 560 | SHOW_FILES = YES 561 | 562 | # Set the SHOW_NAMESPACES tag to NO to disable the generation of the 563 | # Namespaces page. 564 | # This will remove the Namespaces entry from the Quick Index 565 | # and from the Folder Tree View (if specified). The default is YES. 566 | 567 | SHOW_NAMESPACES = YES 568 | 569 | # The FILE_VERSION_FILTER tag can be used to specify a program or script that 570 | # doxygen should invoke to get the current version for each file (typically from 571 | # the version control system). Doxygen will invoke the program by executing (via 572 | # popen()) the command , where is the value of 573 | # the FILE_VERSION_FILTER tag, and is the name of an input file 574 | # provided by doxygen. Whatever the program writes to standard output 575 | # is used as the file version. See the manual for examples. 576 | 577 | FILE_VERSION_FILTER = 578 | 579 | # The LAYOUT_FILE tag can be used to specify a layout file which will be parsed 580 | # by doxygen. The layout file controls the global structure of the generated 581 | # output files in an output format independent way. To create the layout file 582 | # that represents doxygen's defaults, run doxygen with the -l option. 583 | # You can optionally specify a file name after the option, if omitted 584 | # DoxygenLayout.xml will be used as the name of the layout file. 585 | 586 | LAYOUT_FILE = 587 | 588 | # The CITE_BIB_FILES tag can be used to specify one or more bib files 589 | # containing the references data. This must be a list of .bib files. The 590 | # .bib extension is automatically appended if omitted. Using this command 591 | # requires the bibtex tool to be installed. See also 592 | # http://en.wikipedia.org/wiki/BibTeX for more info. For LaTeX the style 593 | # of the bibliography can be controlled using LATEX_BIB_STYLE. To use this 594 | # feature you need bibtex and perl available in the search path. 595 | 596 | CITE_BIB_FILES = 597 | 598 | #--------------------------------------------------------------------------- 599 | # configuration options related to warning and progress messages 600 | #--------------------------------------------------------------------------- 601 | 602 | # The QUIET tag can be used to turn on/off the messages that are generated 603 | # by doxygen. Possible values are YES and NO. If left blank NO is used. 604 | 605 | QUIET = NO 606 | 607 | # The WARNINGS tag can be used to turn on/off the warning messages that are 608 | # generated by doxygen. Possible values are YES and NO. If left blank 609 | # NO is used. 610 | 611 | WARNINGS = YES 612 | 613 | # If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings 614 | # for undocumented members. If EXTRACT_ALL is set to YES then this flag will 615 | # automatically be disabled. 616 | 617 | WARN_IF_UNDOCUMENTED = YES 618 | 619 | # If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for 620 | # potential errors in the documentation, such as not documenting some 621 | # parameters in a documented function, or documenting parameters that 622 | # don't exist or using markup commands wrongly. 623 | 624 | WARN_IF_DOC_ERROR = YES 625 | 626 | # The WARN_NO_PARAMDOC option can be enabled to get warnings for 627 | # functions that are documented, but have no documentation for their parameters 628 | # or return value. If set to NO (the default) doxygen will only warn about 629 | # wrong or incomplete parameter documentation, but not about the absence of 630 | # documentation. 631 | 632 | WARN_NO_PARAMDOC = NO 633 | 634 | # The WARN_FORMAT tag determines the format of the warning messages that 635 | # doxygen can produce. The string should contain the $file, $line, and $text 636 | # tags, which will be replaced by the file and line number from which the 637 | # warning originated and the warning text. Optionally the format may contain 638 | # $version, which will be replaced by the version of the file (if it could 639 | # be obtained via FILE_VERSION_FILTER) 640 | 641 | WARN_FORMAT = "$file:$line: $text" 642 | 643 | # The WARN_LOGFILE tag can be used to specify a file to which warning 644 | # and error messages should be written. If left blank the output is written 645 | # to stderr. 646 | 647 | WARN_LOGFILE = 648 | 649 | #--------------------------------------------------------------------------- 650 | # configuration options related to the input files 651 | #--------------------------------------------------------------------------- 652 | 653 | # The INPUT tag can be used to specify the files and/or directories that contain 654 | # documented source files. You may enter file names like "myfile.cpp" or 655 | # directories like "/usr/src/myproject". Separate the files or directories 656 | # with spaces. 657 | 658 | INPUT = . ../src/ 659 | 660 | # This tag can be used to specify the character encoding of the source files 661 | # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is 662 | # also the default input encoding. Doxygen uses libiconv (or the iconv built 663 | # into libc) for the transcoding. See http://www.gnu.org/software/libiconv for 664 | # the list of possible encodings. 665 | 666 | INPUT_ENCODING = UTF-8 667 | 668 | # If the value of the INPUT tag contains directories, you can use the 669 | # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp 670 | # and *.h) to filter out the source-files in the directories. If left 671 | # blank the following patterns are tested: 672 | # *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh 673 | # *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py 674 | # *.f90 *.f *.for *.vhd *.vhdl 675 | 676 | FILE_PATTERNS = *.h 677 | 678 | # The RECURSIVE tag can be used to turn specify whether or not subdirectories 679 | # should be searched for input files as well. Possible values are YES and NO. 680 | # If left blank NO is used. 681 | 682 | RECURSIVE = NO 683 | 684 | # The EXCLUDE tag can be used to specify files and/or directories that should be 685 | # excluded from the INPUT source files. This way you can easily exclude a 686 | # subdirectory from a directory tree whose root is specified with the INPUT tag. 687 | # Note that relative paths are relative to the directory from which doxygen is 688 | # run. 689 | 690 | EXCLUDE = 691 | 692 | # The EXCLUDE_SYMLINKS tag can be used to select whether or not files or 693 | # directories that are symbolic links (a Unix file system feature) are excluded 694 | # from the input. 695 | 696 | EXCLUDE_SYMLINKS = NO 697 | 698 | # If the value of the INPUT tag contains directories, you can use the 699 | # EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude 700 | # certain files from those directories. Note that the wildcards are matched 701 | # against the file with absolute path, so to exclude all test directories 702 | # for example use the pattern */test/* 703 | 704 | EXCLUDE_PATTERNS = 705 | 706 | # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names 707 | # (namespaces, classes, functions, etc.) that should be excluded from the 708 | # output. The symbol name can be a fully qualified name, a word, or if the 709 | # wildcard * is used, a substring. Examples: ANamespace, AClass, 710 | # AClass::ANamespace, ANamespace::*Test 711 | 712 | EXCLUDE_SYMBOLS = 713 | 714 | # The EXAMPLE_PATH tag can be used to specify one or more files or 715 | # directories that contain example code fragments that are included (see 716 | # the \include command). 717 | 718 | EXAMPLE_PATH = ../examples/ ../tests/ 719 | 720 | # If the value of the EXAMPLE_PATH tag contains directories, you can use the 721 | # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp 722 | # and *.h) to filter out the source-files in the directories. If left 723 | # blank all files are included. 724 | 725 | EXAMPLE_PATTERNS = 726 | 727 | # If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be 728 | # searched for input files to be used with the \include or \dontinclude 729 | # commands irrespective of the value of the RECURSIVE tag. 730 | # Possible values are YES and NO. If left blank NO is used. 731 | 732 | EXAMPLE_RECURSIVE = NO 733 | 734 | # The IMAGE_PATH tag can be used to specify one or more files or 735 | # directories that contain image that are included in the documentation (see 736 | # the \image command). 737 | 738 | IMAGE_PATH = img/ 739 | 740 | # The INPUT_FILTER tag can be used to specify a program that doxygen should 741 | # invoke to filter for each input file. Doxygen will invoke the filter program 742 | # by executing (via popen()) the command , where 743 | # is the value of the INPUT_FILTER tag, and is the name of an 744 | # input file. Doxygen will then use the output that the filter program writes 745 | # to standard output. 746 | # If FILTER_PATTERNS is specified, this tag will be 747 | # ignored. 748 | 749 | INPUT_FILTER = 750 | 751 | # The FILTER_PATTERNS tag can be used to specify filters on a per file pattern 752 | # basis. 753 | # Doxygen will compare the file name with each pattern and apply the 754 | # filter if there is a match. 755 | # The filters are a list of the form: 756 | # pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further 757 | # info on how filters are used. If FILTER_PATTERNS is empty or if 758 | # non of the patterns match the file name, INPUT_FILTER is applied. 759 | 760 | FILTER_PATTERNS = 761 | 762 | # If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using 763 | # INPUT_FILTER) will be used to filter the input files when producing source 764 | # files to browse (i.e. when SOURCE_BROWSER is set to YES). 765 | 766 | FILTER_SOURCE_FILES = NO 767 | 768 | # The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file 769 | # pattern. A pattern will override the setting for FILTER_PATTERN (if any) 770 | # and it is also possible to disable source filtering for a specific pattern 771 | # using *.ext= (so without naming a filter). This option only has effect when 772 | # FILTER_SOURCE_FILES is enabled. 773 | 774 | FILTER_SOURCE_PATTERNS = 775 | 776 | #--------------------------------------------------------------------------- 777 | # configuration options related to source browsing 778 | #--------------------------------------------------------------------------- 779 | 780 | # If the SOURCE_BROWSER tag is set to YES then a list of source files will 781 | # be generated. Documented entities will be cross-referenced with these sources. 782 | # Note: To get rid of all source code in the generated output, make sure also 783 | # VERBATIM_HEADERS is set to NO. 784 | 785 | SOURCE_BROWSER = NO 786 | 787 | # Setting the INLINE_SOURCES tag to YES will include the body 788 | # of functions and classes directly in the documentation. 789 | 790 | INLINE_SOURCES = NO 791 | 792 | # Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct 793 | # doxygen to hide any special comment blocks from generated source code 794 | # fragments. Normal C, C++ and Fortran comments will always remain visible. 795 | 796 | STRIP_CODE_COMMENTS = YES 797 | 798 | # If the REFERENCED_BY_RELATION tag is set to YES 799 | # then for each documented function all documented 800 | # functions referencing it will be listed. 801 | 802 | REFERENCED_BY_RELATION = NO 803 | 804 | # If the REFERENCES_RELATION tag is set to YES 805 | # then for each documented function all documented entities 806 | # called/used by that function will be listed. 807 | 808 | REFERENCES_RELATION = NO 809 | 810 | # If the REFERENCES_LINK_SOURCE tag is set to YES (the default) 811 | # and SOURCE_BROWSER tag is set to YES, then the hyperlinks from 812 | # functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will 813 | # link to the source code. 814 | # Otherwise they will link to the documentation. 815 | 816 | REFERENCES_LINK_SOURCE = YES 817 | 818 | # If the USE_HTAGS tag is set to YES then the references to source code 819 | # will point to the HTML generated by the htags(1) tool instead of doxygen 820 | # built-in source browser. The htags tool is part of GNU's global source 821 | # tagging system (see http://www.gnu.org/software/global/global.html). You 822 | # will need version 4.8.6 or higher. 823 | 824 | USE_HTAGS = NO 825 | 826 | # If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen 827 | # will generate a verbatim copy of the header file for each class for 828 | # which an include is specified. Set to NO to disable this. 829 | 830 | VERBATIM_HEADERS = YES 831 | 832 | #--------------------------------------------------------------------------- 833 | # configuration options related to the alphabetical class index 834 | #--------------------------------------------------------------------------- 835 | 836 | # If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index 837 | # of all compounds will be generated. Enable this if the project 838 | # contains a lot of classes, structs, unions or interfaces. 839 | 840 | ALPHABETICAL_INDEX = YES 841 | 842 | # If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then 843 | # the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns 844 | # in which this list will be split (can be a number in the range [1..20]) 845 | 846 | COLS_IN_ALPHA_INDEX = 5 847 | 848 | # In case all classes in a project start with a common prefix, all 849 | # classes will be put under the same header in the alphabetical index. 850 | # The IGNORE_PREFIX tag can be used to specify one or more prefixes that 851 | # should be ignored while generating the index headers. 852 | 853 | IGNORE_PREFIX = 854 | 855 | #--------------------------------------------------------------------------- 856 | # configuration options related to the HTML output 857 | #--------------------------------------------------------------------------- 858 | 859 | # If the GENERATE_HTML tag is set to YES (the default) Doxygen will 860 | # generate HTML output. 861 | 862 | GENERATE_HTML = YES 863 | 864 | # The HTML_OUTPUT tag is used to specify where the HTML docs will be put. 865 | # If a relative path is entered the value of OUTPUT_DIRECTORY will be 866 | # put in front of it. If left blank `html' will be used as the default path. 867 | 868 | HTML_OUTPUT = html 869 | 870 | # The HTML_FILE_EXTENSION tag can be used to specify the file extension for 871 | # each generated HTML page (for example: .htm,.php,.asp). If it is left blank 872 | # doxygen will generate files with .html extension. 873 | 874 | HTML_FILE_EXTENSION = .html 875 | 876 | # The HTML_HEADER tag can be used to specify a personal HTML header for 877 | # each generated HTML page. If it is left blank doxygen will generate a 878 | # standard header. Note that when using a custom header you are responsible 879 | # for the proper inclusion of any scripts and style sheets that doxygen 880 | # needs, which is dependent on the configuration options used. 881 | # It is advised to generate a default header using "doxygen -w html 882 | # header.html footer.html stylesheet.css YourConfigFile" and then modify 883 | # that header. Note that the header is subject to change so you typically 884 | # have to redo this when upgrading to a newer version of doxygen or when 885 | # changing the value of configuration settings such as GENERATE_TREEVIEW! 886 | 887 | HTML_HEADER = 888 | 889 | # The HTML_FOOTER tag can be used to specify a personal HTML footer for 890 | # each generated HTML page. If it is left blank doxygen will generate a 891 | # standard footer. 892 | 893 | HTML_FOOTER = 894 | 895 | # The HTML_STYLESHEET tag can be used to specify a user-defined cascading 896 | # style sheet that is used by each HTML page. It can be used to 897 | # fine-tune the look of the HTML output. If the tag is left blank doxygen 898 | # will generate a default style sheet. Note that doxygen will try to copy 899 | # the style sheet file to the HTML output directory, so don't put your own 900 | # style sheet in the HTML output directory as well, or it will be erased! 901 | 902 | HTML_STYLESHEET = 903 | 904 | # The HTML_EXTRA_FILES tag can be used to specify one or more extra images or 905 | # other source files which should be copied to the HTML output directory. Note 906 | # that these files will be copied to the base HTML output directory. Use the 907 | # $relpath$ marker in the HTML_HEADER and/or HTML_FOOTER files to load these 908 | # files. In the HTML_STYLESHEET file, use the file name only. Also note that 909 | # the files will be copied as-is; there are no commands or markers available. 910 | 911 | HTML_EXTRA_FILES = 912 | 913 | # The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. 914 | # Doxygen will adjust the colors in the style sheet and background images 915 | # according to this color. Hue is specified as an angle on a colorwheel, 916 | # see http://en.wikipedia.org/wiki/Hue for more information. 917 | # For instance the value 0 represents red, 60 is yellow, 120 is green, 918 | # 180 is cyan, 240 is blue, 300 purple, and 360 is red again. 919 | # The allowed range is 0 to 359. 920 | 921 | HTML_COLORSTYLE_HUE = 220 922 | 923 | # The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of 924 | # the colors in the HTML output. For a value of 0 the output will use 925 | # grayscales only. A value of 255 will produce the most vivid colors. 926 | 927 | HTML_COLORSTYLE_SAT = 100 928 | 929 | # The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to 930 | # the luminance component of the colors in the HTML output. Values below 931 | # 100 gradually make the output lighter, whereas values above 100 make 932 | # the output darker. The value divided by 100 is the actual gamma applied, 933 | # so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, 934 | # and 100 does not change the gamma. 935 | 936 | HTML_COLORSTYLE_GAMMA = 80 937 | 938 | # If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML 939 | # page will contain the date and time when the page was generated. Setting 940 | # this to NO can help when comparing the output of multiple runs. 941 | 942 | HTML_TIMESTAMP = YES 943 | 944 | # If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML 945 | # documentation will contain sections that can be hidden and shown after the 946 | # page has loaded. 947 | 948 | HTML_DYNAMIC_SECTIONS = NO 949 | 950 | # With HTML_INDEX_NUM_ENTRIES one can control the preferred number of 951 | # entries shown in the various tree structured indices initially; the user 952 | # can expand and collapse entries dynamically later on. Doxygen will expand 953 | # the tree to such a level that at most the specified number of entries are 954 | # visible (unless a fully collapsed tree already exceeds this amount). 955 | # So setting the number of entries 1 will produce a full collapsed tree by 956 | # default. 0 is a special value representing an infinite number of entries 957 | # and will result in a full expanded tree by default. 958 | 959 | HTML_INDEX_NUM_ENTRIES = 100 960 | 961 | # If the GENERATE_DOCSET tag is set to YES, additional index files 962 | # will be generated that can be used as input for Apple's Xcode 3 963 | # integrated development environment, introduced with OSX 10.5 (Leopard). 964 | # To create a documentation set, doxygen will generate a Makefile in the 965 | # HTML output directory. Running make will produce the docset in that 966 | # directory and running "make install" will install the docset in 967 | # ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find 968 | # it at startup. 969 | # See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html 970 | # for more information. 971 | 972 | GENERATE_DOCSET = NO 973 | 974 | # When GENERATE_DOCSET tag is set to YES, this tag determines the name of the 975 | # feed. A documentation feed provides an umbrella under which multiple 976 | # documentation sets from a single provider (such as a company or product suite) 977 | # can be grouped. 978 | 979 | DOCSET_FEEDNAME = "Doxygen generated docs" 980 | 981 | # When GENERATE_DOCSET tag is set to YES, this tag specifies a string that 982 | # should uniquely identify the documentation set bundle. This should be a 983 | # reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen 984 | # will append .docset to the name. 985 | 986 | DOCSET_BUNDLE_ID = org.doxygen.Project 987 | 988 | # When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely identify 989 | # the documentation publisher. This should be a reverse domain-name style 990 | # string, e.g. com.mycompany.MyDocSet.documentation. 991 | 992 | DOCSET_PUBLISHER_ID = org.doxygen.Publisher 993 | 994 | # The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher. 995 | 996 | DOCSET_PUBLISHER_NAME = Publisher 997 | 998 | # If the GENERATE_HTMLHELP tag is set to YES, additional index files 999 | # will be generated that can be used as input for tools like the 1000 | # Microsoft HTML help workshop to generate a compiled HTML help file (.chm) 1001 | # of the generated HTML documentation. 1002 | 1003 | GENERATE_HTMLHELP = NO 1004 | 1005 | # If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can 1006 | # be used to specify the file name of the resulting .chm file. You 1007 | # can add a path in front of the file if the result should not be 1008 | # written to the html output directory. 1009 | 1010 | CHM_FILE = 1011 | 1012 | # If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can 1013 | # be used to specify the location (absolute path including file name) of 1014 | # the HTML help compiler (hhc.exe). If non-empty doxygen will try to run 1015 | # the HTML help compiler on the generated index.hhp. 1016 | 1017 | HHC_LOCATION = 1018 | 1019 | # If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag 1020 | # controls if a separate .chi index file is generated (YES) or that 1021 | # it should be included in the master .chm file (NO). 1022 | 1023 | GENERATE_CHI = NO 1024 | 1025 | # If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING 1026 | # is used to encode HtmlHelp index (hhk), content (hhc) and project file 1027 | # content. 1028 | 1029 | CHM_INDEX_ENCODING = 1030 | 1031 | # If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag 1032 | # controls whether a binary table of contents is generated (YES) or a 1033 | # normal table of contents (NO) in the .chm file. 1034 | 1035 | BINARY_TOC = NO 1036 | 1037 | # The TOC_EXPAND flag can be set to YES to add extra items for group members 1038 | # to the contents of the HTML help documentation and to the tree view. 1039 | 1040 | TOC_EXPAND = NO 1041 | 1042 | # If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and 1043 | # QHP_VIRTUAL_FOLDER are set, an additional index file will be generated 1044 | # that can be used as input for Qt's qhelpgenerator to generate a 1045 | # Qt Compressed Help (.qch) of the generated HTML documentation. 1046 | 1047 | GENERATE_QHP = NO 1048 | 1049 | # If the QHG_LOCATION tag is specified, the QCH_FILE tag can 1050 | # be used to specify the file name of the resulting .qch file. 1051 | # The path specified is relative to the HTML output folder. 1052 | 1053 | QCH_FILE = 1054 | 1055 | # The QHP_NAMESPACE tag specifies the namespace to use when generating 1056 | # Qt Help Project output. For more information please see 1057 | # http://doc.trolltech.com/qthelpproject.html#namespace 1058 | 1059 | QHP_NAMESPACE = org.doxygen.Project 1060 | 1061 | # The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating 1062 | # Qt Help Project output. For more information please see 1063 | # http://doc.trolltech.com/qthelpproject.html#virtual-folders 1064 | 1065 | QHP_VIRTUAL_FOLDER = doc 1066 | 1067 | # If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to 1068 | # add. For more information please see 1069 | # http://doc.trolltech.com/qthelpproject.html#custom-filters 1070 | 1071 | QHP_CUST_FILTER_NAME = 1072 | 1073 | # The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the 1074 | # custom filter to add. For more information please see 1075 | # 1076 | # Qt Help Project / Custom Filters. 1077 | 1078 | QHP_CUST_FILTER_ATTRS = 1079 | 1080 | # The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this 1081 | # project's 1082 | # filter section matches. 1083 | # 1084 | # Qt Help Project / Filter Attributes. 1085 | 1086 | QHP_SECT_FILTER_ATTRS = 1087 | 1088 | # If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can 1089 | # be used to specify the location of Qt's qhelpgenerator. 1090 | # If non-empty doxygen will try to run qhelpgenerator on the generated 1091 | # .qhp file. 1092 | 1093 | QHG_LOCATION = 1094 | 1095 | # If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files 1096 | # will be generated, which together with the HTML files, form an Eclipse help 1097 | # plugin. To install this plugin and make it available under the help contents 1098 | # menu in Eclipse, the contents of the directory containing the HTML and XML 1099 | # files needs to be copied into the plugins directory of eclipse. The name of 1100 | # the directory within the plugins directory should be the same as 1101 | # the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before 1102 | # the help appears. 1103 | 1104 | GENERATE_ECLIPSEHELP = NO 1105 | 1106 | # A unique identifier for the eclipse help plugin. When installing the plugin 1107 | # the directory name containing the HTML and XML files should also have 1108 | # this name. 1109 | 1110 | ECLIPSE_DOC_ID = org.doxygen.Project 1111 | 1112 | # The DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) 1113 | # at top of each HTML page. The value NO (the default) enables the index and 1114 | # the value YES disables it. Since the tabs have the same information as the 1115 | # navigation tree you can set this option to NO if you already set 1116 | # GENERATE_TREEVIEW to YES. 1117 | 1118 | DISABLE_INDEX = NO 1119 | 1120 | # The GENERATE_TREEVIEW tag is used to specify whether a tree-like index 1121 | # structure should be generated to display hierarchical information. 1122 | # If the tag value is set to YES, a side panel will be generated 1123 | # containing a tree-like index structure (just like the one that 1124 | # is generated for HTML Help). For this to work a browser that supports 1125 | # JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). 1126 | # Windows users are probably better off using the HTML help feature. 1127 | # Since the tree basically has the same information as the tab index you 1128 | # could consider to set DISABLE_INDEX to NO when enabling this option. 1129 | 1130 | GENERATE_TREEVIEW = NO 1131 | 1132 | # The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values 1133 | # (range [0,1..20]) that doxygen will group on one line in the generated HTML 1134 | # documentation. Note that a value of 0 will completely suppress the enum 1135 | # values from appearing in the overview section. 1136 | 1137 | ENUM_VALUES_PER_LINE = 4 1138 | 1139 | # If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be 1140 | # used to set the initial width (in pixels) of the frame in which the tree 1141 | # is shown. 1142 | 1143 | TREEVIEW_WIDTH = 250 1144 | 1145 | # When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open 1146 | # links to external symbols imported via tag files in a separate window. 1147 | 1148 | EXT_LINKS_IN_WINDOW = NO 1149 | 1150 | # Use this tag to change the font size of Latex formulas included 1151 | # as images in the HTML documentation. The default is 10. Note that 1152 | # when you change the font size after a successful doxygen run you need 1153 | # to manually remove any form_*.png images from the HTML output directory 1154 | # to force them to be regenerated. 1155 | 1156 | FORMULA_FONTSIZE = 10 1157 | 1158 | # Use the FORMULA_TRANPARENT tag to determine whether or not the images 1159 | # generated for formulas are transparent PNGs. Transparent PNGs are 1160 | # not supported properly for IE 6.0, but are supported on all modern browsers. 1161 | # Note that when changing this option you need to delete any form_*.png files 1162 | # in the HTML output before the changes have effect. 1163 | 1164 | FORMULA_TRANSPARENT = YES 1165 | 1166 | # Enable the USE_MATHJAX option to render LaTeX formulas using MathJax 1167 | # (see http://www.mathjax.org) which uses client side Javascript for the 1168 | # rendering instead of using prerendered bitmaps. Use this if you do not 1169 | # have LaTeX installed or if you want to formulas look prettier in the HTML 1170 | # output. When enabled you may also need to install MathJax separately and 1171 | # configure the path to it using the MATHJAX_RELPATH option. 1172 | 1173 | USE_MATHJAX = NO 1174 | 1175 | # When MathJax is enabled you need to specify the location relative to the 1176 | # HTML output directory using the MATHJAX_RELPATH option. The destination 1177 | # directory should contain the MathJax.js script. For instance, if the mathjax 1178 | # directory is located at the same level as the HTML output directory, then 1179 | # MATHJAX_RELPATH should be ../mathjax. The default value points to 1180 | # the MathJax Content Delivery Network so you can quickly see the result without 1181 | # installing MathJax. 1182 | # However, it is strongly recommended to install a local 1183 | # copy of MathJax from http://www.mathjax.org before deployment. 1184 | 1185 | MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest 1186 | 1187 | # The MATHJAX_EXTENSIONS tag can be used to specify one or MathJax extension 1188 | # names that should be enabled during MathJax rendering. 1189 | 1190 | MATHJAX_EXTENSIONS = 1191 | 1192 | # When the SEARCHENGINE tag is enabled doxygen will generate a search box 1193 | # for the HTML output. The underlying search engine uses javascript 1194 | # and DHTML and should work on any modern browser. Note that when using 1195 | # HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets 1196 | # (GENERATE_DOCSET) there is already a search function so this one should 1197 | # typically be disabled. For large projects the javascript based search engine 1198 | # can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. 1199 | 1200 | SEARCHENGINE = YES 1201 | 1202 | # When the SERVER_BASED_SEARCH tag is enabled the search engine will be 1203 | # implemented using a PHP enabled web server instead of at the web client 1204 | # using Javascript. Doxygen will generate the search PHP script and index 1205 | # file to put on the web server. The advantage of the server 1206 | # based approach is that it scales better to large projects and allows 1207 | # full text search. The disadvantages are that it is more difficult to setup 1208 | # and does not have live searching capabilities. 1209 | 1210 | SERVER_BASED_SEARCH = NO 1211 | 1212 | #--------------------------------------------------------------------------- 1213 | # configuration options related to the LaTeX output 1214 | #--------------------------------------------------------------------------- 1215 | 1216 | # If the GENERATE_LATEX tag is set to YES (the default) Doxygen will 1217 | # generate Latex output. 1218 | 1219 | GENERATE_LATEX = NO 1220 | 1221 | # The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. 1222 | # If a relative path is entered the value of OUTPUT_DIRECTORY will be 1223 | # put in front of it. If left blank `latex' will be used as the default path. 1224 | 1225 | LATEX_OUTPUT = latex 1226 | 1227 | # The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be 1228 | # invoked. If left blank `latex' will be used as the default command name. 1229 | # Note that when enabling USE_PDFLATEX this option is only used for 1230 | # generating bitmaps for formulas in the HTML output, but not in the 1231 | # Makefile that is written to the output directory. 1232 | 1233 | LATEX_CMD_NAME = latex 1234 | 1235 | # The MAKEINDEX_CMD_NAME tag can be used to specify the command name to 1236 | # generate index for LaTeX. If left blank `makeindex' will be used as the 1237 | # default command name. 1238 | 1239 | MAKEINDEX_CMD_NAME = makeindex 1240 | 1241 | # If the COMPACT_LATEX tag is set to YES Doxygen generates more compact 1242 | # LaTeX documents. This may be useful for small projects and may help to 1243 | # save some trees in general. 1244 | 1245 | COMPACT_LATEX = NO 1246 | 1247 | # The PAPER_TYPE tag can be used to set the paper type that is used 1248 | # by the printer. Possible values are: a4, letter, legal and 1249 | # executive. If left blank a4wide will be used. 1250 | 1251 | PAPER_TYPE = a4 1252 | 1253 | # The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX 1254 | # packages that should be included in the LaTeX output. 1255 | 1256 | EXTRA_PACKAGES = 1257 | 1258 | # The LATEX_HEADER tag can be used to specify a personal LaTeX header for 1259 | # the generated latex document. The header should contain everything until 1260 | # the first chapter. If it is left blank doxygen will generate a 1261 | # standard header. Notice: only use this tag if you know what you are doing! 1262 | 1263 | LATEX_HEADER = 1264 | 1265 | # The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for 1266 | # the generated latex document. The footer should contain everything after 1267 | # the last chapter. If it is left blank doxygen will generate a 1268 | # standard footer. Notice: only use this tag if you know what you are doing! 1269 | 1270 | LATEX_FOOTER = 1271 | 1272 | # If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated 1273 | # is prepared for conversion to pdf (using ps2pdf). The pdf file will 1274 | # contain links (just like the HTML output) instead of page references 1275 | # This makes the output suitable for online browsing using a pdf viewer. 1276 | 1277 | PDF_HYPERLINKS = YES 1278 | 1279 | # If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of 1280 | # plain latex in the generated Makefile. Set this option to YES to get a 1281 | # higher quality PDF documentation. 1282 | 1283 | USE_PDFLATEX = YES 1284 | 1285 | # If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. 1286 | # command to the generated LaTeX files. This will instruct LaTeX to keep 1287 | # running if errors occur, instead of asking the user for help. 1288 | # This option is also used when generating formulas in HTML. 1289 | 1290 | LATEX_BATCHMODE = NO 1291 | 1292 | # If LATEX_HIDE_INDICES is set to YES then doxygen will not 1293 | # include the index chapters (such as File Index, Compound Index, etc.) 1294 | # in the output. 1295 | 1296 | LATEX_HIDE_INDICES = NO 1297 | 1298 | # If LATEX_SOURCE_CODE is set to YES then doxygen will include 1299 | # source code with syntax highlighting in the LaTeX output. 1300 | # Note that which sources are shown also depends on other settings 1301 | # such as SOURCE_BROWSER. 1302 | 1303 | LATEX_SOURCE_CODE = NO 1304 | 1305 | # The LATEX_BIB_STYLE tag can be used to specify the style to use for the 1306 | # bibliography, e.g. plainnat, or ieeetr. The default style is "plain". See 1307 | # http://en.wikipedia.org/wiki/BibTeX for more info. 1308 | 1309 | LATEX_BIB_STYLE = plain 1310 | 1311 | #--------------------------------------------------------------------------- 1312 | # configuration options related to the RTF output 1313 | #--------------------------------------------------------------------------- 1314 | 1315 | # If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output 1316 | # The RTF output is optimized for Word 97 and may not look very pretty with 1317 | # other RTF readers or editors. 1318 | 1319 | GENERATE_RTF = NO 1320 | 1321 | # The RTF_OUTPUT tag is used to specify where the RTF docs will be put. 1322 | # If a relative path is entered the value of OUTPUT_DIRECTORY will be 1323 | # put in front of it. If left blank `rtf' will be used as the default path. 1324 | 1325 | RTF_OUTPUT = rtf 1326 | 1327 | # If the COMPACT_RTF tag is set to YES Doxygen generates more compact 1328 | # RTF documents. This may be useful for small projects and may help to 1329 | # save some trees in general. 1330 | 1331 | COMPACT_RTF = NO 1332 | 1333 | # If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated 1334 | # will contain hyperlink fields. The RTF file will 1335 | # contain links (just like the HTML output) instead of page references. 1336 | # This makes the output suitable for online browsing using WORD or other 1337 | # programs which support those fields. 1338 | # Note: wordpad (write) and others do not support links. 1339 | 1340 | RTF_HYPERLINKS = NO 1341 | 1342 | # Load style sheet definitions from file. Syntax is similar to doxygen's 1343 | # config file, i.e. a series of assignments. You only have to provide 1344 | # replacements, missing definitions are set to their default value. 1345 | 1346 | RTF_STYLESHEET_FILE = 1347 | 1348 | # Set optional variables used in the generation of an rtf document. 1349 | # Syntax is similar to doxygen's config file. 1350 | 1351 | RTF_EXTENSIONS_FILE = 1352 | 1353 | #--------------------------------------------------------------------------- 1354 | # configuration options related to the man page output 1355 | #--------------------------------------------------------------------------- 1356 | 1357 | # If the GENERATE_MAN tag is set to YES (the default) Doxygen will 1358 | # generate man pages 1359 | 1360 | GENERATE_MAN = NO 1361 | 1362 | # The MAN_OUTPUT tag is used to specify where the man pages will be put. 1363 | # If a relative path is entered the value of OUTPUT_DIRECTORY will be 1364 | # put in front of it. If left blank `man' will be used as the default path. 1365 | 1366 | MAN_OUTPUT = man 1367 | 1368 | # The MAN_EXTENSION tag determines the extension that is added to 1369 | # the generated man pages (default is the subroutine's section .3) 1370 | 1371 | MAN_EXTENSION = .3 1372 | 1373 | # If the MAN_LINKS tag is set to YES and Doxygen generates man output, 1374 | # then it will generate one additional man file for each entity 1375 | # documented in the real man page(s). These additional files 1376 | # only source the real man page, but without them the man command 1377 | # would be unable to find the correct page. The default is NO. 1378 | 1379 | MAN_LINKS = NO 1380 | 1381 | #--------------------------------------------------------------------------- 1382 | # configuration options related to the XML output 1383 | #--------------------------------------------------------------------------- 1384 | 1385 | # If the GENERATE_XML tag is set to YES Doxygen will 1386 | # generate an XML file that captures the structure of 1387 | # the code including all documentation. 1388 | 1389 | GENERATE_XML = NO 1390 | 1391 | # The XML_OUTPUT tag is used to specify where the XML pages will be put. 1392 | # If a relative path is entered the value of OUTPUT_DIRECTORY will be 1393 | # put in front of it. If left blank `xml' will be used as the default path. 1394 | 1395 | XML_OUTPUT = xml 1396 | 1397 | # The XML_SCHEMA tag can be used to specify an XML schema, 1398 | # which can be used by a validating XML parser to check the 1399 | # syntax of the XML files. 1400 | 1401 | XML_SCHEMA = 1402 | 1403 | # The XML_DTD tag can be used to specify an XML DTD, 1404 | # which can be used by a validating XML parser to check the 1405 | # syntax of the XML files. 1406 | 1407 | XML_DTD = 1408 | 1409 | # If the XML_PROGRAMLISTING tag is set to YES Doxygen will 1410 | # dump the program listings (including syntax highlighting 1411 | # and cross-referencing information) to the XML output. Note that 1412 | # enabling this will significantly increase the size of the XML output. 1413 | 1414 | XML_PROGRAMLISTING = YES 1415 | 1416 | #--------------------------------------------------------------------------- 1417 | # configuration options for the AutoGen Definitions output 1418 | #--------------------------------------------------------------------------- 1419 | 1420 | # If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will 1421 | # generate an AutoGen Definitions (see autogen.sf.net) file 1422 | # that captures the structure of the code including all 1423 | # documentation. Note that this feature is still experimental 1424 | # and incomplete at the moment. 1425 | 1426 | GENERATE_AUTOGEN_DEF = NO 1427 | 1428 | #--------------------------------------------------------------------------- 1429 | # configuration options related to the Perl module output 1430 | #--------------------------------------------------------------------------- 1431 | 1432 | # If the GENERATE_PERLMOD tag is set to YES Doxygen will 1433 | # generate a Perl module file that captures the structure of 1434 | # the code including all documentation. Note that this 1435 | # feature is still experimental and incomplete at the 1436 | # moment. 1437 | 1438 | GENERATE_PERLMOD = NO 1439 | 1440 | # If the PERLMOD_LATEX tag is set to YES Doxygen will generate 1441 | # the necessary Makefile rules, Perl scripts and LaTeX code to be able 1442 | # to generate PDF and DVI output from the Perl module output. 1443 | 1444 | PERLMOD_LATEX = NO 1445 | 1446 | # If the PERLMOD_PRETTY tag is set to YES the Perl module output will be 1447 | # nicely formatted so it can be parsed by a human reader. 1448 | # This is useful 1449 | # if you want to understand what is going on. 1450 | # On the other hand, if this 1451 | # tag is set to NO the size of the Perl module output will be much smaller 1452 | # and Perl will parse it just the same. 1453 | 1454 | PERLMOD_PRETTY = YES 1455 | 1456 | # The names of the make variables in the generated doxyrules.make file 1457 | # are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. 1458 | # This is useful so different doxyrules.make files included by the same 1459 | # Makefile don't overwrite each other's variables. 1460 | 1461 | PERLMOD_MAKEVAR_PREFIX = 1462 | 1463 | #--------------------------------------------------------------------------- 1464 | # Configuration options related to the preprocessor 1465 | #--------------------------------------------------------------------------- 1466 | 1467 | # If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will 1468 | # evaluate all C-preprocessor directives found in the sources and include 1469 | # files. 1470 | 1471 | ENABLE_PREPROCESSING = YES 1472 | 1473 | # If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro 1474 | # names in the source code. If set to NO (the default) only conditional 1475 | # compilation will be performed. Macro expansion can be done in a controlled 1476 | # way by setting EXPAND_ONLY_PREDEF to YES. 1477 | 1478 | MACRO_EXPANSION = YES 1479 | 1480 | # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES 1481 | # then the macro expansion is limited to the macros specified with the 1482 | # PREDEFINED and EXPAND_AS_DEFINED tags. 1483 | 1484 | EXPAND_ONLY_PREDEF = YES 1485 | 1486 | # If the SEARCH_INCLUDES tag is set to YES (the default) the includes files 1487 | # pointed to by INCLUDE_PATH will be searched when a #include is found. 1488 | 1489 | SEARCH_INCLUDES = YES 1490 | 1491 | # The INCLUDE_PATH tag can be used to specify one or more directories that 1492 | # contain include files that are not input files but should be processed by 1493 | # the preprocessor. 1494 | 1495 | INCLUDE_PATH = 1496 | 1497 | # You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard 1498 | # patterns (like *.h and *.hpp) to filter out the header-files in the 1499 | # directories. If left blank, the patterns specified with FILE_PATTERNS will 1500 | # be used. 1501 | 1502 | INCLUDE_FILE_PATTERNS = 1503 | 1504 | # The PREDEFINED tag can be used to specify one or more macro names that 1505 | # are defined before the preprocessor is started (similar to the -D option of 1506 | # gcc). The argument of the tag is a list of macros of the form: name 1507 | # or name=definition (no spaces). If the definition and the = are 1508 | # omitted =1 is assumed. To prevent a macro definition from being 1509 | # undefined via #undef or recursively expanded use the := operator 1510 | # instead of the = operator. 1511 | 1512 | PREDEFINED = __attribute__(x) = 1513 | 1514 | # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then 1515 | # this tag can be used to specify a list of macro names that should be expanded. 1516 | # The macro definition that is found in the sources will be used. 1517 | # Use the PREDEFINED tag if you want to use a different macro definition that 1518 | # overrules the definition found in the source code. 1519 | 1520 | EXPAND_AS_DEFINED = 1521 | 1522 | # If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then 1523 | # doxygen's preprocessor will remove all references to function-like macros 1524 | # that are alone on a line, have an all uppercase name, and do not end with a 1525 | # semicolon, because these will confuse the parser if not removed. 1526 | 1527 | SKIP_FUNCTION_MACROS = YES 1528 | 1529 | #--------------------------------------------------------------------------- 1530 | # Configuration::additions related to external references 1531 | #--------------------------------------------------------------------------- 1532 | 1533 | # The TAGFILES option can be used to specify one or more tagfiles. For each 1534 | # tag file the location of the external documentation should be added. The 1535 | # format of a tag file without this location is as follows: 1536 | # 1537 | # TAGFILES = file1 file2 ... 1538 | # Adding location for the tag files is done as follows: 1539 | # 1540 | # TAGFILES = file1=loc1 "file2 = loc2" ... 1541 | # where "loc1" and "loc2" can be relative or absolute paths 1542 | # or URLs. Note that each tag file must have a unique name (where the name does 1543 | # NOT include the path). If a tag file is not located in the directory in which 1544 | # doxygen is run, you must also specify the path to the tagfile here. 1545 | 1546 | TAGFILES = 1547 | 1548 | # When a file name is specified after GENERATE_TAGFILE, doxygen will create 1549 | # a tag file that is based on the input files it reads. 1550 | 1551 | GENERATE_TAGFILE = 1552 | 1553 | # If the ALLEXTERNALS tag is set to YES all external classes will be listed 1554 | # in the class index. If set to NO only the inherited external classes 1555 | # will be listed. 1556 | 1557 | ALLEXTERNALS = NO 1558 | 1559 | # If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed 1560 | # in the modules index. If set to NO, only the current project's groups will 1561 | # be listed. 1562 | 1563 | EXTERNAL_GROUPS = YES 1564 | 1565 | # The PERL_PATH should be the absolute path and name of the perl script 1566 | # interpreter (i.e. the result of `which perl'). 1567 | 1568 | PERL_PATH = /usr/bin/perl 1569 | 1570 | #--------------------------------------------------------------------------- 1571 | # Configuration options related to the dot tool 1572 | #--------------------------------------------------------------------------- 1573 | 1574 | # If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will 1575 | # generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base 1576 | # or super classes. Setting the tag to NO turns the diagrams off. Note that 1577 | # this option also works with HAVE_DOT disabled, but it is recommended to 1578 | # install and use dot, since it yields more powerful graphs. 1579 | 1580 | CLASS_DIAGRAMS = YES 1581 | 1582 | # You can define message sequence charts within doxygen comments using the \msc 1583 | # command. Doxygen will then run the mscgen tool (see 1584 | # http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the 1585 | # documentation. The MSCGEN_PATH tag allows you to specify the directory where 1586 | # the mscgen tool resides. If left empty the tool is assumed to be found in the 1587 | # default search path. 1588 | 1589 | MSCGEN_PATH = 1590 | 1591 | # If set to YES, the inheritance and collaboration graphs will hide 1592 | # inheritance and usage relations if the target is undocumented 1593 | # or is not a class. 1594 | 1595 | HIDE_UNDOC_RELATIONS = YES 1596 | 1597 | # If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is 1598 | # available from the path. This tool is part of Graphviz, a graph visualization 1599 | # toolkit from AT&T and Lucent Bell Labs. The other options in this section 1600 | # have no effect if this option is set to NO (the default) 1601 | 1602 | HAVE_DOT = NO 1603 | 1604 | # The DOT_NUM_THREADS specifies the number of dot invocations doxygen is 1605 | # allowed to run in parallel. When set to 0 (the default) doxygen will 1606 | # base this on the number of processors available in the system. You can set it 1607 | # explicitly to a value larger than 0 to get control over the balance 1608 | # between CPU load and processing speed. 1609 | 1610 | DOT_NUM_THREADS = 0 1611 | 1612 | # By default doxygen will use the Helvetica font for all dot files that 1613 | # doxygen generates. When you want a differently looking font you can specify 1614 | # the font name using DOT_FONTNAME. You need to make sure dot is able to find 1615 | # the font, which can be done by putting it in a standard location or by setting 1616 | # the DOTFONTPATH environment variable or by setting DOT_FONTPATH to the 1617 | # directory containing the font. 1618 | 1619 | DOT_FONTNAME = Helvetica 1620 | 1621 | # The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. 1622 | # The default size is 10pt. 1623 | 1624 | DOT_FONTSIZE = 10 1625 | 1626 | # By default doxygen will tell dot to use the Helvetica font. 1627 | # If you specify a different font using DOT_FONTNAME you can use DOT_FONTPATH to 1628 | # set the path where dot can find it. 1629 | 1630 | DOT_FONTPATH = 1631 | 1632 | # If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen 1633 | # will generate a graph for each documented class showing the direct and 1634 | # indirect inheritance relations. Setting this tag to YES will force the 1635 | # CLASS_DIAGRAMS tag to NO. 1636 | 1637 | CLASS_GRAPH = YES 1638 | 1639 | # If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen 1640 | # will generate a graph for each documented class showing the direct and 1641 | # indirect implementation dependencies (inheritance, containment, and 1642 | # class references variables) of the class with other documented classes. 1643 | 1644 | COLLABORATION_GRAPH = YES 1645 | 1646 | # If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen 1647 | # will generate a graph for groups, showing the direct groups dependencies 1648 | 1649 | GROUP_GRAPHS = YES 1650 | 1651 | # If the UML_LOOK tag is set to YES doxygen will generate inheritance and 1652 | # collaboration diagrams in a style similar to the OMG's Unified Modeling 1653 | # Language. 1654 | 1655 | UML_LOOK = NO 1656 | 1657 | # If the UML_LOOK tag is enabled, the fields and methods are shown inside 1658 | # the class node. If there are many fields or methods and many nodes the 1659 | # graph may become too big to be useful. The UML_LIMIT_NUM_FIELDS 1660 | # threshold limits the number of items for each type to make the size more 1661 | # managable. Set this to 0 for no limit. Note that the threshold may be 1662 | # exceeded by 50% before the limit is enforced. 1663 | 1664 | UML_LIMIT_NUM_FIELDS = 10 1665 | 1666 | # If set to YES, the inheritance and collaboration graphs will show the 1667 | # relations between templates and their instances. 1668 | 1669 | TEMPLATE_RELATIONS = NO 1670 | 1671 | # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT 1672 | # tags are set to YES then doxygen will generate a graph for each documented 1673 | # file showing the direct and indirect include dependencies of the file with 1674 | # other documented files. 1675 | 1676 | INCLUDE_GRAPH = YES 1677 | 1678 | # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and 1679 | # HAVE_DOT tags are set to YES then doxygen will generate a graph for each 1680 | # documented header file showing the documented files that directly or 1681 | # indirectly include this file. 1682 | 1683 | INCLUDED_BY_GRAPH = YES 1684 | 1685 | # If the CALL_GRAPH and HAVE_DOT options are set to YES then 1686 | # doxygen will generate a call dependency graph for every global function 1687 | # or class method. Note that enabling this option will significantly increase 1688 | # the time of a run. So in most cases it will be better to enable call graphs 1689 | # for selected functions only using the \callgraph command. 1690 | 1691 | CALL_GRAPH = NO 1692 | 1693 | # If the CALLER_GRAPH and HAVE_DOT tags are set to YES then 1694 | # doxygen will generate a caller dependency graph for every global function 1695 | # or class method. Note that enabling this option will significantly increase 1696 | # the time of a run. So in most cases it will be better to enable caller 1697 | # graphs for selected functions only using the \callergraph command. 1698 | 1699 | CALLER_GRAPH = NO 1700 | 1701 | # If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen 1702 | # will generate a graphical hierarchy of all classes instead of a textual one. 1703 | 1704 | GRAPHICAL_HIERARCHY = YES 1705 | 1706 | # If the DIRECTORY_GRAPH and HAVE_DOT tags are set to YES 1707 | # then doxygen will show the dependencies a directory has on other directories 1708 | # in a graphical way. The dependency relations are determined by the #include 1709 | # relations between the files in the directories. 1710 | 1711 | DIRECTORY_GRAPH = YES 1712 | 1713 | # The DOT_IMAGE_FORMAT tag can be used to set the image format of the images 1714 | # generated by dot. Possible values are svg, png, jpg, or gif. 1715 | # If left blank png will be used. If you choose svg you need to set 1716 | # HTML_FILE_EXTENSION to xhtml in order to make the SVG files 1717 | # visible in IE 9+ (other browsers do not have this requirement). 1718 | 1719 | DOT_IMAGE_FORMAT = png 1720 | 1721 | # If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to 1722 | # enable generation of interactive SVG images that allow zooming and panning. 1723 | # Note that this requires a modern browser other than Internet Explorer. 1724 | # Tested and working are Firefox, Chrome, Safari, and Opera. For IE 9+ you 1725 | # need to set HTML_FILE_EXTENSION to xhtml in order to make the SVG files 1726 | # visible. Older versions of IE do not have SVG support. 1727 | 1728 | INTERACTIVE_SVG = NO 1729 | 1730 | # The tag DOT_PATH can be used to specify the path where the dot tool can be 1731 | # found. If left blank, it is assumed the dot tool can be found in the path. 1732 | 1733 | DOT_PATH = 1734 | 1735 | # The DOTFILE_DIRS tag can be used to specify one or more directories that 1736 | # contain dot files that are included in the documentation (see the 1737 | # \dotfile command). 1738 | 1739 | DOTFILE_DIRS = 1740 | 1741 | # The MSCFILE_DIRS tag can be used to specify one or more directories that 1742 | # contain msc files that are included in the documentation (see the 1743 | # \mscfile command). 1744 | 1745 | MSCFILE_DIRS = 1746 | 1747 | # The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of 1748 | # nodes that will be shown in the graph. If the number of nodes in a graph 1749 | # becomes larger than this value, doxygen will truncate the graph, which is 1750 | # visualized by representing a node as a red box. Note that doxygen if the 1751 | # number of direct children of the root node in a graph is already larger than 1752 | # DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note 1753 | # that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. 1754 | 1755 | DOT_GRAPH_MAX_NODES = 50 1756 | 1757 | # The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the 1758 | # graphs generated by dot. A depth value of 3 means that only nodes reachable 1759 | # from the root by following a path via at most 3 edges will be shown. Nodes 1760 | # that lay further from the root node will be omitted. Note that setting this 1761 | # option to 1 or 2 may greatly reduce the computation time needed for large 1762 | # code bases. Also note that the size of a graph can be further restricted by 1763 | # DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. 1764 | 1765 | MAX_DOT_GRAPH_DEPTH = 0 1766 | 1767 | # Set the DOT_TRANSPARENT tag to YES to generate images with a transparent 1768 | # background. This is disabled by default, because dot on Windows does not 1769 | # seem to support this out of the box. Warning: Depending on the platform used, 1770 | # enabling this option may lead to badly anti-aliased labels on the edges of 1771 | # a graph (i.e. they become hard to read). 1772 | 1773 | DOT_TRANSPARENT = NO 1774 | 1775 | # Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output 1776 | # files in one run (i.e. multiple -o and -T options on the command line). This 1777 | # makes dot run faster, but since only newer versions of dot (>1.8.10) 1778 | # support this, this feature is disabled by default. 1779 | 1780 | DOT_MULTI_TARGETS = YES 1781 | 1782 | # If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will 1783 | # generate a legend page explaining the meaning of the various boxes and 1784 | # arrows in the dot generated graphs. 1785 | 1786 | GENERATE_LEGEND = YES 1787 | 1788 | # If the DOT_CLEANUP tag is set to YES (the default) Doxygen will 1789 | # remove the intermediate dot files that are used to generate 1790 | # the various graphs. 1791 | 1792 | DOT_CLEANUP = YES 1793 | -------------------------------------------------------------------------------- /doc/img/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/misje/stateMachine/e68077c54c312555d3a9dd0ff113088ae2320cbc/doc/img/logo.png -------------------------------------------------------------------------------- /doc/img/stateMachine.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 21 | 23 | 27 | 31 | 32 | 35 | 39 | 43 | 44 | 47 | 51 | 55 | 56 | 65 | 68 | 72 | 76 | 77 | 87 | 97 | 107 | 110 | 114 | 118 | 119 | 128 | 138 | 148 | 158 | 168 | 169 | 192 | 194 | 195 | 197 | image/svg+xml 198 | 200 | 201 | 202 | 203 | 204 | 209 | 212 | 221 | 230 | 233 | ERRORSTATE 250 | 253 | entryAction( event ) 264 | 269 | 270 | 271 | 274 | 283 | 286 | STATE 297 | 300 | exitAction( event ) 311 | 317 | 318 | 319 | 320 | 323 | 332 | 335 | STATE 346 | 349 | exitAction( event ) 360 | 366 | 367 | 370 | entryAction( event ) 381 | 386 | 387 | 388 | 389 | 392 | 401 | 404 | STATE 415 | 418 | exitAction( event ) 429 | 435 | 436 | 439 | entryAction( event ) 450 | 455 | 456 | 457 | 458 | 461 | 473 | 482 | 489 | 490 | 493 | 505 | 514 | 521 | 522 | parent/group state 533 | 537 | exitAction( event ) 548 | 554 | 555 | 558 | 561 | 570 | 577 | 578 | / action( event ) 589 | guard( condition, event ) 600 | 601 | 604 | 610 | 613 | 615 | 620 | 627 | 628 | / action( event ) 639 | guard( condition, event ) 650 | 651 | initial state 662 | entry state 673 | 675 | 681 | 689 | guard( condition, event ) 698 | 699 | final state 710 | (unconditional) 719 | (unconditional)/ action( event ) 736 | 742 | 750 | 751 | 752 | -------------------------------------------------------------------------------- /examples/stateMachineExample.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Andreas Misje 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a 5 | * copy of this software and associated documentation files (the "Software"), 6 | * to deal in the Software without restriction, including without limitation 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | * and/or sell copies of the Software, and to permit persons to whom the 9 | * Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | * DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #include 24 | #include 25 | #include "stateMachine.h" 26 | 27 | /* This simple example checks keyboad input against the two allowed strings 28 | * "ha\n" and "hi\n". If an unrecognised character is read, a group state will 29 | * handle this by printing a message and returning to the idle state. If the 30 | * character '!' is encountered, a "reset" message is printed, and the group 31 | * state's entry state will be entered (the idle state). 32 | * 33 | * print 'reset' 34 | * o +---------------------+ 35 | * | | | '!' 36 | * | v group state | 37 | * +-----v-----------------------------------+----+ 38 | * | +------+ 'h' +---+ 'a' +---+ '\n' | 39 | * +->| idle | ----> | h | ----> | a | ---------+ | 40 | * | +------+ +---+\ +---+ | | 41 | * | ^ ^ ^ \'i' +---+ '\n' | | 42 | * | | | | \--> | i | ------+ | | 43 | * | | | | +---+ | | | 44 | * +---|-|-|----------------+----------------|--|-+ 45 | * | | | | | | 46 | * | | | | '[^hai!\n]' | | 47 | * | | | print unrecog. | | | 48 | * | | +----------------+ print 'hi' | | 49 | * | +-----------------------------------+ | 50 | * | print 'ha' | 51 | * +----------------------------------------+ 52 | */ 53 | 54 | /* Types of events */ 55 | enum eventType { 56 | Event_keyboard, 57 | }; 58 | 59 | /* Compare keyboard character from transition's condition variable against 60 | * data in event. */ 61 | static bool compareKeyboardChar( void *ch, struct event *event ); 62 | 63 | static void printRecognisedChar( void *stateData, struct event *event ); 64 | static void printUnrecognisedChar( void *oldStateData, struct event *event, 65 | void *newStateData ); 66 | static void printReset( void *oldStateData, struct event *event, 67 | void *newStateData ); 68 | static void printHiMsg( void *oldStateData, struct event *event, 69 | void *newStateData ); 70 | static void printHaMsg( void *oldStateData, struct event *event, 71 | void *newStateData ); 72 | static void printErrMsg( void *stateData, struct event *event ); 73 | static void printEnterMsg( void *stateData, struct event *event ); 74 | static void printExitMsg( void *stateData, struct event *event ); 75 | 76 | /* Forward declaration of states so that they can be defined in an logical 77 | * order: */ 78 | static struct state checkCharsGroupState, idleState, hState, iState, aState; 79 | 80 | /* All the following states (apart from the error state) are children of this 81 | * group state. This way, any unrecognised character will be handled by this 82 | * state's transition, eliminating the need for adding the same transition to 83 | * all the children states. */ 84 | static struct state checkCharsGroupState = { 85 | .parentState = NULL, 86 | /* The entry state is defined in order to demontrate that the 'reset' 87 | * transtition, going to this group state, will be 'redirected' to the 88 | * 'idle' state (the transition could of course go directly to the 'idle' 89 | * state): */ 90 | .entryState = &idleState, 91 | .transitions = (struct transition[]){ 92 | { Event_keyboard, (void *)(intptr_t)'!', &compareKeyboardChar, 93 | &printReset, &idleState, }, 94 | { Event_keyboard, NULL, NULL, &printUnrecognisedChar, &idleState, }, 95 | }, 96 | .numTransitions = 2, 97 | .data = "group", 98 | .entryAction = &printEnterMsg, 99 | .exitAction = &printExitMsg, 100 | }; 101 | 102 | static struct state idleState = { 103 | .parentState = &checkCharsGroupState, 104 | .entryState = NULL, 105 | .transitions = (struct transition[]){ 106 | { Event_keyboard, (void *)(intptr_t)'h', &compareKeyboardChar, NULL, 107 | &hState }, 108 | }, 109 | .numTransitions = 1, 110 | .data = "idle", 111 | .entryAction = &printEnterMsg, 112 | .exitAction = &printExitMsg, 113 | }; 114 | 115 | static struct state hState = { 116 | .parentState = &checkCharsGroupState, 117 | .entryState = NULL, 118 | .transitions = (struct transition[]){ 119 | { Event_keyboard, (void *)(intptr_t)'a', &compareKeyboardChar, NULL, 120 | &aState }, 121 | { Event_keyboard, (void *)(intptr_t)'i', &compareKeyboardChar, NULL, 122 | &iState }, 123 | }, 124 | .numTransitions = 2, 125 | .data = "H", 126 | .entryAction = &printRecognisedChar, 127 | .exitAction = &printExitMsg, 128 | }; 129 | 130 | static struct state iState = { 131 | .parentState = &checkCharsGroupState, 132 | .entryState = NULL, 133 | .transitions = (struct transition[]){ 134 | { Event_keyboard, (void *)(intptr_t)'\n', &compareKeyboardChar, 135 | &printHiMsg, &idleState } 136 | }, 137 | .numTransitions = 1, 138 | .data = "I", 139 | .entryAction = &printRecognisedChar, 140 | .exitAction = &printExitMsg, 141 | }; 142 | 143 | static struct state aState = { 144 | .parentState = &checkCharsGroupState, 145 | .entryState = NULL, 146 | .transitions = (struct transition[]){ 147 | { Event_keyboard, (void *)(intptr_t)'\n', &compareKeyboardChar, 148 | &printHaMsg, &idleState } 149 | }, 150 | .numTransitions = 1, 151 | .data = "A", 152 | .entryAction = &printRecognisedChar, 153 | .exitAction = &printExitMsg 154 | }; 155 | 156 | static struct state errorState = { 157 | .entryAction = &printErrMsg 158 | }; 159 | 160 | 161 | int main() 162 | { 163 | struct stateMachine m; 164 | stateM_init( &m, &idleState, &errorState ); 165 | 166 | int ch; 167 | while ( ( ch = getc( stdin ) ) != EOF ) 168 | stateM_handleEvent( &m, &(struct event){ Event_keyboard, 169 | (void *)(intptr_t)ch } ); 170 | 171 | return 0; 172 | } 173 | 174 | static bool compareKeyboardChar( void *ch, struct event *event ) 175 | { 176 | if ( event->type != Event_keyboard ) 177 | return false; 178 | 179 | return (intptr_t)ch == (intptr_t)event->data; 180 | } 181 | 182 | static void printRecognisedChar( void *stateData, struct event *event ) 183 | { 184 | printEnterMsg( stateData, event ); 185 | printf( "parsed: %c\n", (char)(intptr_t)event->data ); 186 | } 187 | 188 | static void printUnrecognisedChar( void *oldStateData, struct event *event, 189 | void *newStateData ) 190 | { 191 | printf( "unrecognised character: %c\n", 192 | (char)(intptr_t)event->data ); 193 | } 194 | 195 | static void printReset( void *oldStateData, struct event *event, 196 | void *newStateData ) 197 | { 198 | puts( "Resetting" ); 199 | } 200 | 201 | static void printHiMsg( void *oldStateData, struct event *event, 202 | void *newStateData ) 203 | { 204 | puts( "Hi!" ); 205 | } 206 | 207 | static void printHaMsg( void *oldStateData, struct event *event, 208 | void *newStateData ) 209 | { 210 | puts( "Ha-ha" ); 211 | } 212 | 213 | static void printErrMsg( void *stateData, struct event *event ) 214 | { 215 | puts( "ENTERED ERROR STATE!" ); 216 | } 217 | 218 | static void printEnterMsg( void *stateData, struct event *event ) 219 | { 220 | printf( "Entering %s state\n", (char *)stateData ); 221 | } 222 | 223 | static void printExitMsg( void *stateData, struct event *event ) 224 | { 225 | printf( "Exiting %s state\n", (char *)stateData ); 226 | } 227 | -------------------------------------------------------------------------------- /src/stateMachine.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Andreas Misje 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a 5 | * copy of this software and associated documentation files (the "Software"), 6 | * to deal in the Software without restriction, including without limitation 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | * and/or sell copies of the Software, and to permit persons to whom the 9 | * Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | * DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #include "stateMachine.h" 24 | 25 | static void goToErrorState( struct stateMachine *stateMachine, 26 | struct event *const event ); 27 | static struct transition *getTransition( struct stateMachine *stateMachine, 28 | struct state *state, struct event *const event ); 29 | 30 | void stateM_init( struct stateMachine *fsm, 31 | struct state *initialState, struct state *errorState ) 32 | { 33 | if ( !fsm ) 34 | return; 35 | 36 | fsm->currentState = initialState; 37 | fsm->previousState = NULL; 38 | fsm->errorState = errorState; 39 | } 40 | 41 | int stateM_handleEvent( struct stateMachine *fsm, 42 | struct event *event ) 43 | { 44 | if ( !fsm || !event ) 45 | return stateM_errArg; 46 | 47 | if ( !fsm->currentState ) 48 | { 49 | goToErrorState( fsm, event ); 50 | return stateM_errorStateReached; 51 | } 52 | 53 | if ( !fsm->currentState->numTransitions ) 54 | return stateM_noStateChange; 55 | 56 | struct state *nextState = fsm->currentState; 57 | do { 58 | struct transition *transition = getTransition( fsm, nextState, event ); 59 | 60 | /* If there were no transitions for the given event for the current 61 | * state, check if there are any transitions for any of the parent 62 | * states (if any): */ 63 | if ( !transition ) 64 | { 65 | nextState = nextState->parentState; 66 | continue; 67 | } 68 | 69 | /* A transition must have a next state defined. If the user has not 70 | * defined the next state, go to error state: */ 71 | if ( !transition->nextState ) 72 | { 73 | goToErrorState( fsm, event ); 74 | return stateM_errorStateReached; 75 | } 76 | 77 | nextState = transition->nextState; 78 | 79 | /* If the new state is a parent state, enter its entry state (if it has 80 | * one). Step down through the whole family tree until a state without 81 | * an entry state is found: */ 82 | while ( nextState->entryState ) 83 | nextState = nextState->entryState; 84 | 85 | /* Run exit action only if the current state is left (only if it does 86 | * not return to itself): */ 87 | if ( nextState != fsm->currentState && fsm->currentState->exitAction ) 88 | fsm->currentState->exitAction( fsm->currentState->data, event ); 89 | 90 | /* Run transition action (if any): */ 91 | if ( transition->action ) 92 | transition->action( fsm->currentState->data, event, nextState-> 93 | data ); 94 | 95 | /* Call the new state's entry action if it has any (only if state does 96 | * not return to itself): */ 97 | if ( nextState != fsm->currentState && nextState->entryAction ) 98 | nextState->entryAction( nextState->data, event ); 99 | 100 | fsm->previousState = fsm->currentState; 101 | fsm->currentState = nextState; 102 | 103 | /* If the state returned to itself: */ 104 | if ( fsm->currentState == fsm->previousState ) 105 | return stateM_stateLoopSelf; 106 | 107 | if ( fsm->currentState == fsm->errorState ) 108 | return stateM_errorStateReached; 109 | 110 | /* If the new state is a final state, notify user that the state 111 | * machine has stopped: */ 112 | if ( !fsm->currentState->numTransitions ) 113 | return stateM_finalStateReached; 114 | 115 | return stateM_stateChanged; 116 | } while ( nextState ); 117 | 118 | return stateM_noStateChange; 119 | } 120 | 121 | struct state *stateM_currentState( struct stateMachine *fsm ) 122 | { 123 | if ( !fsm ) 124 | return NULL; 125 | 126 | return fsm->currentState; 127 | } 128 | 129 | struct state *stateM_previousState( struct stateMachine *fsm ) 130 | { 131 | if ( !fsm ) 132 | return NULL; 133 | 134 | return fsm->previousState; 135 | } 136 | 137 | 138 | static void goToErrorState( struct stateMachine *fsm, 139 | struct event *const event ) 140 | { 141 | fsm->previousState = fsm->currentState; 142 | fsm->currentState = fsm->errorState; 143 | 144 | if ( fsm->currentState && fsm->currentState->entryAction ) 145 | fsm->currentState->entryAction( fsm->currentState->data, event ); 146 | } 147 | 148 | static struct transition *getTransition( struct stateMachine *fsm, 149 | struct state *state, struct event *const event ) 150 | { 151 | size_t i; 152 | 153 | for ( i = 0; i < state->numTransitions; ++i ) 154 | { 155 | struct transition *t = &state->transitions[ i ]; 156 | 157 | /* A transition for the given event has been found: */ 158 | if ( t->eventType == event->type ) 159 | { 160 | if ( !t->guard ) 161 | return t; 162 | /* If transition is guarded, ensure that the condition is held: */ 163 | else if ( t->guard( t->condition, event ) ) 164 | return t; 165 | } 166 | } 167 | 168 | /* No transitions found for given event for given state: */ 169 | return NULL; 170 | } 171 | 172 | bool stateM_stopped( struct stateMachine *stateMachine ) 173 | { 174 | if ( !stateMachine ) 175 | return true; 176 | 177 | return stateMachine->currentState->numTransitions == 0; 178 | } 179 | -------------------------------------------------------------------------------- /src/stateMachine.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Andreas Misje 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a 5 | * copy of this software and associated documentation files (the "Software"), 6 | * to deal in the Software without restriction, including without limitation 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | * and/or sell copies of the Software, and to permit persons to whom the 9 | * Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | * DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | /** 24 | * \mainpage %stateMachine 25 | * 26 | * %stateMachine is a feature-rich, yet simple finite state machine 27 | * implementation. It supports grouped states, guarded transitions, events 28 | * with payload, entry and exit actions, transition actions and access to 29 | * user-defined state data from all actions. 30 | * 31 | * The user must build the state machine by linking together states and 32 | * transitions arrays with pointers. A pointer to an initial state and an 33 | * error state is given to stateM_init() to initialise a state machine object. 34 | * The state machine is run by passing events to it with the function 35 | * stateM_handleEvent(). The return value of stateM_handleEvent() will 36 | * give an indication to what has happened. 37 | * 38 | * \image html stateMachine.svg "Illustrating a stateMachine" 39 | */ 40 | 41 | /** 42 | * \defgroup stateMachine State machine 43 | * 44 | * \author Andreas Misje 45 | * \date 27.03.13 46 | * 47 | * \brief Finite state machine 48 | * 49 | * A finite state machine implementation that supports nested states, guards 50 | * and entry/exit routines. All state machine data is stored in separate 51 | * objects, and the state machine must be built by the user. States are 52 | * connected using pointers, and all data can be stored on either the stack, 53 | * heap or both. 54 | */ 55 | 56 | /** 57 | * \addtogroup stateMachine 58 | * @{ 59 | * 60 | * \file 61 | * \example stateMachineExample.c Simple example of how to create a state 62 | * machine 63 | * \example nestedTest.c Simple example testing the behaviour of nested 64 | * parent states 65 | */ 66 | 67 | #ifndef STATEMACHINE_H 68 | #define STATEMACHINE_H 69 | 70 | #include 71 | #include 72 | 73 | /** 74 | * \brief Event 75 | * 76 | * Events trigger transitions from a state to another. Event types are defined 77 | * by the user. Any event may optionally contain a \ref #event::data 78 | * "payload". 79 | * 80 | * \sa state 81 | * \sa transition 82 | */ 83 | struct event 84 | { 85 | /** \brief Type of event. Defined by user. */ 86 | int type; 87 | /** 88 | * \brief Event payload. 89 | * 90 | * How this is used is entirely up to the user. This data 91 | * is always passed together with #type in order to make it possible to 92 | * always cast the data correctly. 93 | */ 94 | void *data; 95 | }; 96 | 97 | struct state; 98 | 99 | /** 100 | * \brief Transition between a state and another state 101 | * 102 | * All states that are not final must have at least one transition. The 103 | * transition may be guarded or not. Transitions are triggered by events. If 104 | * a state has more than one transition with the same type of event (and the 105 | * same condition), the first transition in the array will be run. An 106 | * unconditional transition placed last in the transition array of a state can 107 | * act as a "catch-all". A transition may optionally run an #action, which 108 | * will have the triggering event passed to it as an argument, along with the 109 | * current and new states' \ref state::data "data". 110 | * 111 | * It is perfectly valid for a transition to return to the state it belongs 112 | * to. Such a transition will not call the state's \ref state::entryAction 113 | * "entry action" or \ref state::exitAction "exit action". If there are no 114 | * transitions for the current event, the state's parent will be handed the 115 | * event. 116 | * 117 | * ### Examples ### 118 | * - An ungarded transition to a state with no action performed: 119 | * ~~~{.c} 120 | * { 121 | * .eventType = Event_timeout, 122 | * .condition = NULL, 123 | * .guard = NULL, 124 | * .action = NULL, 125 | * .nextState = &mainMenuState, 126 | * }, 127 | * ~~~ 128 | * - A guarded transition executing an action 129 | * ~~~{.c} 130 | * { 131 | * .eventType = Event_keyboard, 132 | * .condition = NULL, 133 | * .guard = &ensureNumericInput, 134 | * .action = &addToBuffer, 135 | * .nextState = &awaitingInputState, 136 | * }, 137 | * ~~~ 138 | * - A guarded transition using a condition 139 | * ~~~{.c} 140 | * { 141 | * .eventType = Event_mouse, 142 | * .condition = boxLimits, 143 | * .guard = &coordinatesWithinLimits, 144 | * }, 145 | * ~~~ 146 | * By using \ref #condition "conditions" a more general guard function can be 147 | * used, operating on the supplied argument #condition. In this example, 148 | * `coordinatesWithinLimits` checks whether the coordinates in the mouse event 149 | * are within the limits of the "box". 150 | * 151 | * \sa event 152 | * \sa state 153 | */ 154 | struct transition 155 | { 156 | /** \brief The event that will trigger this transition. */ 157 | int eventType; 158 | /** 159 | * \brief Condition that event must fulfil 160 | * 161 | * This variable will be passed to the #guard (if #guard is non-NULL) and 162 | * may be used as a condition that the incoming event's data must fulfil in 163 | * order for the transition to be performed. By using this variable, the 164 | * number of #guard functions can be minimised by making them more general. 165 | */ 166 | void *condition; 167 | /** 168 | * \brief Check if data passed with event fulfils a condition 169 | * 170 | * A transition may be conditional. If so, this function, if non-NULL, will 171 | * be called. Its first argument will be supplied with #condition, which 172 | * can be compared against the \ref event::data "payload" in the #event. 173 | * The user may choose to use this argument or not. Only if the result is 174 | * true, the transition will take place. 175 | * 176 | * \param condition event (data) to compare the incoming event against. 177 | * \param event the event passed to the state machine. 178 | * 179 | * \returns true if the event's data fulfils the condition, otherwise false. 180 | */ 181 | bool ( *guard )( void *condition, struct event *event ); 182 | /** 183 | * \brief Function containing tasks to be performed during the transition 184 | * 185 | * The transition may optionally do some work in this function before 186 | * entering the next state. May be NULL. 187 | * 188 | * \param currentStateData the leaving state's \ref state::data "data" 189 | * \param event the event passed to the state machine. 190 | * \param newStateData the new state's (the \ref state::entryState 191 | * "entryState" of any (chain of) parent states, not the parent state 192 | * itself) \ref state::data "data" 193 | */ 194 | void ( *action )( void *currentStateData, struct event *event, 195 | void *newStateData ); 196 | /** 197 | * \brief The next state 198 | * 199 | * This must point to the next state that will be entered. It cannot be 200 | * NULL. If it is, the state machine will detect it and enter the \ref 201 | * stateMachine::errorState "error state". 202 | */ 203 | struct state *nextState; 204 | }; 205 | 206 | /** 207 | * \brief State 208 | * 209 | * The current state in a state machine moves to a new state when one of the 210 | * #transitions in the current state triggers on an event. An optional \ref 211 | * #exitAction "exit action" is called when the state is left, and an \ref 212 | * #entryAction "entry action" is called when the state machine enters a new 213 | * state. If a state returns to itself, neither #exitAction nor #entryAction 214 | * will be called. An optional \ref transition::action "transition action" is 215 | * called in either case. 216 | * 217 | * States may be organised in a hierarchy by setting \ref #parentState 218 | * "parent states". When a group/parent state is entered, the state machine is 219 | * redirected to the group state's \ref #entryState "entry state" (if 220 | * non-NULL). If an event does not trigger a transition in a state and if the 221 | * state has a parent state, the event will be passed to the parent state. 222 | * This behaviour is repeated for all parents. Thus all children of a state 223 | * have a set of common #transitions. A parent state's #entryAction will not 224 | * be called if an event is passed on to a child state. 225 | * 226 | * The following lists the different types of states that may be created, and 227 | * how to create them: 228 | * 229 | * ### Normal state ### 230 | * ~~~{.c} 231 | * struct state normalState = { 232 | * .parentState = &groupState, 233 | * .entryState = NULL, 234 | * .transition = (struct transition[]){ 235 | * { Event_keyboard, (void *)(intptr_t)'\n', &compareKeyboardChar, 236 | * NULL, &msgReceivedState }, 237 | * }, 238 | * .numTransitions = 1, 239 | * .data = normalStateData, 240 | * .entryAction = &doSomething, 241 | * .exitAction = &cleanUp, 242 | * }; 243 | * ~~~ 244 | * In this example, `normalState` is a child of `groupState`, but the 245 | * #parentState value may also be NULL to indicate that it is not a child of 246 | * any group state. 247 | * 248 | * ### Group/parent state ### 249 | * A state becomes a group/parent state when it is linked to by child states 250 | * by using #parentState. No members in the group state need to be set in a 251 | * particular way. A parent state may also have a parent. 252 | * ~~~{.c} 253 | * struct state groupState = { 254 | * .entryState = &normalState, 255 | * .entryAction = NULL, 256 | * ~~~ 257 | * If there are any transitions in the state machine that lead to a group 258 | * state, it makes sense to define an entry state in the group. This can be 259 | * done by using #entryState, but it is not mandatory. If the #entryState 260 | * state has children, the chain of children will be traversed until a child 261 | * with its #entryState set to NULL is found. 262 | * 263 | * \note If #entryState is defined for a group state, the group state's 264 | * #entryAction will not be called (the state pointed to by #entryState (after 265 | * following the chain of children), however, will have its #entryAction 266 | * called). 267 | * 268 | * \warning The state machine cannot detect cycles in parent chains and 269 | * children chains. If such cycles are present, stateM_handleEvent() will 270 | * never finish due to never-ending loops. 271 | * 272 | * ### Final state ### 273 | * A final state is a state that terminates the state machine. A state is 274 | * considered as a final state if its #numTransitions is 0: 275 | * ~~~{.c} 276 | * struct state finalState = { 277 | * .transitions = NULL, 278 | * .numTransitions = 0, 279 | * ~~~ 280 | * The error state used by the state machine to indicate errors should be a 281 | * final state. Any calls to stateM_handleEvent() when the current state is a 282 | * final state will return #stateM_noStateChange. 283 | * 284 | * \sa event 285 | * \sa transition 286 | */ 287 | struct state 288 | { 289 | /** 290 | * \brief If the state has a parent state, this pointer must be non-NULL. 291 | */ 292 | struct state *parentState; 293 | /** 294 | * \brief If this state is a parent state, this pointer may point to a 295 | * child state that serves as an entry point. 296 | */ 297 | struct state *entryState; 298 | /** 299 | * \brief An array of transitions for the state. 300 | */ 301 | struct transition *transitions; 302 | /** 303 | * \brief Number of transitions in the #transitions array. 304 | */ 305 | size_t numTransitions; 306 | /** 307 | * \brief Data that will be available for the state in its #entryAction and 308 | * #exitAction, and in any \ref transition::action "transition action" 309 | */ 310 | void *data; 311 | /** 312 | * \brief This function is called whenever the state is being entered. May 313 | * be NULL. 314 | * 315 | * \note If a state returns to itself through a transition (either directly 316 | * or through a parent/group sate), its #entryAction will not be called. 317 | * 318 | * \note A group/parent state with its #entryState defined will not have 319 | * its #entryAction called. 320 | * 321 | * \param stateData the state's #data will be passed. 322 | * \param event the event that triggered the transition will be passed. 323 | */ 324 | void ( *entryAction )( void *stateData, struct event *event ); 325 | /** 326 | * \brief This function is called whenever the state is being left. May be 327 | * NULL. 328 | * 329 | * \note If a state returns to itself through a transition (either directly 330 | * or through a parent/group sate), its #exitAction will not be called. 331 | * 332 | * \param stateData the state's #data will be passed. 333 | * \param event the event that triggered a transition will be passed. 334 | */ 335 | void ( *exitAction )( void *stateData, struct event *event ); 336 | }; 337 | 338 | /** 339 | * \brief State machine 340 | * 341 | * There is no need to manipulate the members directly. 342 | */ 343 | struct stateMachine 344 | { 345 | /** \brief Pointer to the current state */ 346 | struct state *currentState; 347 | /** 348 | * \brief Pointer to previous state 349 | * 350 | * The previous state is stored for convenience in case the user needs to 351 | * keep track of previous states. 352 | */ 353 | struct state *previousState; 354 | /** 355 | * \brief Pointer to a state that will be entered whenever an error occurs 356 | * in the state machine. 357 | * 358 | * See #stateM_errorStateReached for when the state machine enters the 359 | * error state. 360 | */ 361 | struct state *errorState; 362 | }; 363 | 364 | /** 365 | * \brief Initialise the state machine 366 | * 367 | * This function initialises the supplied stateMachine and sets the current 368 | * state to \pn{initialState}. No actions are performed until 369 | * stateM_handleEvent() is called. It is safe to call this function numerous 370 | * times, for instance in order to reset/restart the state machine if a final 371 | * state has been reached. 372 | * 373 | * \note The \ref #state::entryAction "entry action" for \pn{initialState} 374 | * will not be called. 375 | * 376 | * \note If \pn{initialState} is a parent state with its \ref 377 | * state::entryState "entryState" defined, it will not be entered. The user 378 | * must explicitly set the initial state. 379 | * 380 | * \param stateMachine the state machine to initialise. 381 | * \param initialState the initial state of the state machine. 382 | * \param errorState pointer to a state that acts a final state and notifies 383 | * the system/user that an error has occurred. 384 | */ 385 | void stateM_init( struct stateMachine *stateMachine, 386 | struct state *initialState, struct state *errorState ); 387 | 388 | /** 389 | * \brief stateM_handleEvent() return values 390 | */ 391 | enum stateM_handleEventRetVals 392 | { 393 | /** \brief Erroneous arguments were passed */ 394 | stateM_errArg = -2, 395 | /** 396 | * \brief The error state was reached 397 | * 398 | * This value is returned either when the state machine enters the error 399 | * state itself as a result of an error, or when the error state is the 400 | * next state as a result of a successful transition. 401 | * 402 | * The state machine enters the state machine if any of the following 403 | * happens: 404 | * - The current state is NULL 405 | * - A transition for the current event did not define the next state 406 | */ 407 | stateM_errorStateReached, 408 | /** \brief The current state changed into a non-final state */ 409 | stateM_stateChanged, 410 | /** 411 | * \brief The state changed back to itself 412 | * 413 | * The state can return to itself either directly or indirectly. An 414 | * indirect path may inlude a transition from a parent state and the use of 415 | * \ref state::entryState "entryStates". 416 | */ 417 | stateM_stateLoopSelf, 418 | /** 419 | * \brief The current state did not change on the given event 420 | * 421 | * If any event passed to the state machine should result in a state 422 | * change, this return value should be considered as an error. 423 | */ 424 | stateM_noStateChange, 425 | /** \brief A final state (any but the error state) was reached */ 426 | stateM_finalStateReached, 427 | }; 428 | 429 | /** 430 | * \brief Pass an event to the state machine 431 | * 432 | * The event will be passed to the current state, and possibly to the current 433 | * state's parent states (if any). If the event triggers a transition, a new 434 | * state will be entered. If the transition has an \ref transition::action 435 | * "action" defined, it will be called. If the transition is to a state other 436 | * than the current state, the current state's \ref state::exitAction 437 | * "exit action" is called (if defined). Likewise, if the state is a new 438 | * state, the new state's \ref state::entryAction "entry action" is called (if 439 | * defined). 440 | * 441 | * The returned value is negative if an error occurs. 442 | * 443 | * \param stateMachine the state machine to pass an event to. 444 | * \param event the event to be handled. 445 | * 446 | * \return #stateM_handleEventRetVals 447 | */ 448 | int stateM_handleEvent( struct stateMachine *stateMachine, 449 | struct event *event ); 450 | 451 | /** 452 | * \brief Get the current state 453 | * 454 | * \param stateMachine the state machine to get the current state from. 455 | * 456 | * \retval a pointer to the current state. 457 | * \retval NULL if \pn{stateMachine} is NULL. 458 | */ 459 | struct state *stateM_currentState( struct stateMachine *stateMachine ); 460 | 461 | /** 462 | * \brief Get the previous state 463 | * 464 | * \param stateMachine the state machine to get the previous state from. 465 | * 466 | * \retval the previous state. 467 | * \retval NULL if \pn{stateMachine} is NULL. 468 | * \retval NULL if there has not yet been any transitions. 469 | */ 470 | struct state *stateM_previousState( struct stateMachine *stateMachine ); 471 | 472 | /** 473 | * \brief Check if the state machine has stopped 474 | * 475 | * \param stateMachine the state machine to test. 476 | * 477 | * \retval true if the state machine has reached a final state. 478 | * \retval false if \pn{stateMachine} is NULL or if the current state is not a 479 | * final state. 480 | */ 481 | bool stateM_stopped( struct stateMachine *stateMachine ); 482 | 483 | #endif // STATEMACHINE_H 484 | 485 | /** 486 | * @} 487 | */ 488 | -------------------------------------------------------------------------------- /tests/nestedTest.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Andreas Misje 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a 5 | * copy of this software and associated documentation files (the "Software"), 6 | * to deal in the Software without restriction, including without limitation 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | * and/or sell copies of the Software, and to permit persons to whom the 9 | * Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | * DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #include "stateMachine.h" 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | /* This simple test uses a multiple-nested state machine to test that 30 | * traversing parents anc children work correctly. 31 | * 32 | * +--+ o 33 | * | v | 34 | * +---|------[9]---|----------+ 35 | * | | v | 36 | * | | o +---+ (b) | +---+ 37 | * | | | | 1 |<----------| 2 |<---+ 38 | * | | | +---+ | +---+<-+ | 39 | * | | | |(d) | | | 40 | * | +-|---|--[10]--|--------+ | | | 41 | * | | | | v | | (f)| |(g) 42 | * | | o | +---+<----------+ | | 43 | * | | | | 3 |-+ | | |(a) | | 44 | * | | | +---+ |(e) | +--+ | | 45 | * | | | v | | | | 46 | * | | +---|----[11]-------+ +-----------+ | 47 | * | | | v o +---------------+ 48 | * | | | +---+ (h)+---+ | | | | 49 | * | | | | 4 |--->| 5 |<-+ | | | +---+ 50 | * | | | +---+ +---+ | | | | 6 | 51 | * | | | |(j) | | | | +---+ 52 | * | | | | | | | | ^ 53 | * | | +---|--------|------+ +------+(i) 54 | * | +-----|--------|--------+ | 55 | * +-------|-----^--|----------+ +---+ 56 | * ^ | | | | E | 57 | * +--+ +--+ +---+ 58 | */ 59 | 60 | enum eventTypes 61 | { 62 | Event_dummy, 63 | }; 64 | 65 | /* Use this struct as event payload, containing both the event data (a single 66 | * character) and the name of the expected new state (used to ensure correct 67 | * behaviour). */ 68 | struct eventPayload 69 | { 70 | char data; 71 | const char *expectedState; 72 | }; 73 | 74 | static void entryAction( void *stateData, struct event *event ); 75 | static void exitAction( void *stateData, struct event *event ); 76 | static void transAction( void *oldStateData, struct event *event, 77 | void *newStateData ); 78 | static bool guard( void *condition, struct event *event ); 79 | 80 | static struct state s1, s2, s3, s4, s5, s6, s9, s10, s11, sE; 81 | 82 | static struct state 83 | 84 | s1 = 85 | { 86 | .data = "1", 87 | .entryAction = &entryAction, 88 | .exitAction = &exitAction, 89 | .transitions = (struct transition[]) { 90 | { Event_dummy, (void *)(intptr_t)'d', &guard, &transAction, &s3 }, 91 | }, 92 | .numTransitions = 1, 93 | .parentState = &s9, 94 | }, 95 | 96 | s2 = 97 | { 98 | .data = "2", 99 | .entryAction = &entryAction, 100 | .exitAction = &exitAction, 101 | .transitions = (struct transition[]) { 102 | { Event_dummy, (void *)(intptr_t)'b', &guard, &transAction, &s1 }, 103 | }, 104 | .numTransitions = 1, 105 | }, 106 | 107 | s3 = 108 | { 109 | .data = "3", 110 | .entryAction = &entryAction, 111 | .exitAction = &exitAction, 112 | .transitions = (struct transition[]) { 113 | { Event_dummy, (void *)(intptr_t)'e', &guard, &transAction, &s11 }, 114 | }, 115 | .numTransitions = 1, 116 | .parentState = &s10, 117 | }, 118 | 119 | s4 = 120 | { 121 | .data = "4", 122 | .entryAction = &entryAction, 123 | .exitAction = &exitAction, 124 | .transitions = (struct transition[]) { 125 | { Event_dummy, (void *)(intptr_t)'h', &guard, &transAction, &s5 }, 126 | { Event_dummy, (void *)(intptr_t)'j', &guard, &transAction, &s9 }, 127 | }, 128 | .numTransitions = 2, 129 | .parentState = &s11, 130 | }, 131 | 132 | s5 = 133 | { 134 | .data = "5", 135 | .entryAction = &entryAction, 136 | .exitAction = &exitAction, 137 | .transitions = (struct transition[]) { 138 | /* Use an conditionless transition: */ 139 | { Event_dummy, NULL, NULL, &transAction, &s10 }, 140 | }, 141 | .numTransitions = 1, 142 | .parentState = &s11, 143 | }, 144 | 145 | s6 = 146 | { 147 | .data = "6", 148 | .entryAction = &entryAction, 149 | .exitAction = &exitAction, 150 | }, 151 | 152 | s9 = 153 | { 154 | .data = "9", 155 | .entryAction = &entryAction, 156 | .exitAction = &exitAction, 157 | .entryState = &s4, 158 | .transitions = (struct transition[]) { 159 | { Event_dummy, (void *)(intptr_t)'a', &guard, &transAction, &s3 }, 160 | }, 161 | .numTransitions = 1, 162 | }, 163 | 164 | s10 = 165 | { 166 | .data = "10", 167 | .entryAction = &entryAction, 168 | .exitAction = &exitAction, 169 | .entryState = &s9, 170 | .transitions = (struct transition[]) { 171 | { Event_dummy, (void *)(intptr_t)'f', &guard, &transAction, &s2 }, 172 | { Event_dummy, (void *)(intptr_t)'i', &guard, &transAction, &s6 }, 173 | }, 174 | .numTransitions = 2, 175 | .parentState = &s9, 176 | }, 177 | 178 | s11 = 179 | { 180 | .data = "11", 181 | .entryAction = &entryAction, 182 | .exitAction = &exitAction, 183 | .entryState = &s5, 184 | .transitions = (struct transition[]) { 185 | { Event_dummy, (void *)(intptr_t)'g', &guard, &transAction, &s2 }, 186 | }, 187 | .numTransitions = 1, 188 | .parentState = &s10, 189 | }, 190 | 191 | sE = 192 | { 193 | .data = "ERROR", 194 | .entryAction = &entryAction, 195 | }; 196 | 197 | int main() 198 | { 199 | struct stateMachine fsm; 200 | stateM_init( &fsm, &s1, &sE ); 201 | 202 | struct event events[] = { 203 | /* Create transitions, with the single character as triggering event 204 | * data, and the expected new state name as the following string. '*' is 205 | * used when the unconditional transition will be followed. */ 206 | { Event_dummy, &(struct eventPayload){ 'd', "3" } }, 207 | { Event_dummy, &(struct eventPayload){ 'e', "5" } }, 208 | { Event_dummy, &(struct eventPayload){ '*', "4" } }, 209 | { Event_dummy, &(struct eventPayload){ 'j', "4" } }, 210 | { Event_dummy, &(struct eventPayload){ 'g', "2" } }, 211 | { Event_dummy, &(struct eventPayload){ 'b', "1" } }, 212 | { Event_dummy, &(struct eventPayload){ 'd', "3" } }, 213 | { Event_dummy, &(struct eventPayload){ 'e', "5" } }, 214 | { Event_dummy, &(struct eventPayload){ 'k', "4" } }, 215 | { Event_dummy, &(struct eventPayload){ 'h', "5" } }, 216 | { Event_dummy, &(struct eventPayload){ '*', "4" } }, 217 | { Event_dummy, &(struct eventPayload){ 'f', "2" } }, 218 | { Event_dummy, &(struct eventPayload){ 'b', "1" } }, 219 | { Event_dummy, &(struct eventPayload){ 'a', "3" } }, 220 | { Event_dummy, &(struct eventPayload){ 'f', "2" } }, 221 | { Event_dummy, &(struct eventPayload){ 'b', "1" } }, 222 | { Event_dummy, &(struct eventPayload){ 'd', "3" } }, 223 | { Event_dummy, &(struct eventPayload){ 'i', "6" } }, 224 | }; 225 | 226 | int res; 227 | size_t i; 228 | 229 | /* Hand all but the last event to the state machine: */ 230 | for ( i = 0; i < sizeof( events ) / sizeof( events[ 0 ] ) - 1; ++i ) 231 | { 232 | res = stateM_handleEvent( &fsm, &events[ i ] ); 233 | if ( res == stateM_stateLoopSelf ) 234 | { 235 | /* Prevent segmentation faults (due to the following comparison) 236 | * (loops will not be tested in the first transition): */ 237 | if ( i == 0 ) 238 | { 239 | fputs( "Internal error. This should not happen.\n", stderr ); 240 | exit( 4 ); 241 | } 242 | 243 | /* Ensure that the reported state loop is indeed a state loop (check 244 | * that the expected state is the same as the previous expected 245 | * state): */ 246 | if ( !strcmp( ( (struct eventPayload *)events[ i ].data 247 | )->expectedState, ((struct eventPayload *)events[ i - 1 ] 248 | .data )->expectedState ) ) 249 | puts( "State changed back to itself" ); 250 | else 251 | { 252 | fputs( "State unexpectedly changed back to itself", stderr ); 253 | exit( 5 ); 254 | } 255 | } 256 | /* Apart from an occasional state loop, all other events handed to the 257 | * state machine should result in 'stateM_stateChanged': */ 258 | else if ( res != stateM_stateChanged ) 259 | { 260 | fprintf( stderr, "Unexpected return value from stateM_handleEvent:" 261 | " %d\n", res ); 262 | exit( 2 ); 263 | } 264 | } 265 | 266 | /* The last state change is expected to result in a transition to a final 267 | * state: */ 268 | res = stateM_handleEvent( &fsm, &events[ i ] ); 269 | if ( res != stateM_finalStateReached ) 270 | { 271 | fprintf( stderr, "Unexpected return value from stateM_handleEvent:" 272 | " %d\n", res ); 273 | exit( 3 ); 274 | } 275 | puts( "A final state was reached (as expected)" ); 276 | 277 | return 0; 278 | } 279 | 280 | static void entryAction( void *stateData, struct event *event ) 281 | { 282 | const char *stateName = (const char *)stateData; 283 | 284 | printf( "Entering %s\n", stateName ); 285 | } 286 | 287 | static void exitAction( void *stateData, struct event *event ) 288 | { 289 | const char *stateName = (const char *)stateData; 290 | 291 | printf( "Exiting %s\n", stateName ); 292 | } 293 | 294 | static void transAction( void *oldStateData, struct event *event, 295 | void *newStateData ) 296 | { 297 | struct eventPayload *eventData = (struct eventPayload *)event->data; 298 | 299 | printf( "Event '%c'\n", eventData->data ); 300 | 301 | if ( strcmp( ( (const char *)newStateData ), eventData->expectedState ) ) 302 | { 303 | fprintf( stderr, "Unexpected state transition (to %s)\n", 304 | (const char *)newStateData ); 305 | exit( 1 ); 306 | } 307 | } 308 | 309 | static bool guard( void *condition, struct event *event ) 310 | { 311 | struct eventPayload *eventData = (struct eventPayload *)event->data; 312 | 313 | return (intptr_t )condition == (intptr_t)eventData->data; 314 | } 315 | --------------------------------------------------------------------------------