cfl_definitions.h
Go to the documentation of this file.
1 /** @file cfl_definitions.h
2 
3 Compiletime options. This file configures the runtime bahaviour of
4 libFAUDES, in particular informative output on stderr and stdout; see
5 also the Makefile.
6 
7 */
8 
9 
10 /* FAU Discrete Event Systems Library (libfaudes)
11 
12  Copyright (C) 2006 Bernd Opitz
13  Copyright (C) 2008-2021 Thomas Moor
14  Exclusive copyright is granted to Klaus Schmidt
15 
16  This library is free software; you can redistribute it and/or
17  modify it under the terms of the GNU Lesser General Public
18  License as published by the Free Software Foundation; either
19  version 2.1 of the License, or (at your option) any later version.
20 
21  This library is distributed in the hope that it will be useful,
22  but WITHOUT ANY WARRANTY; without even the implied warranty of
23  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24  Lesser General Public License for more details.
25 
26  You should have received a copy of the GNU Lesser General Public
27  License along with this library; if not, write to the Free Software
28  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
29 
30 
31 
32 #ifndef FAUDES_DEFINITIONS_H
33 #define FAUDES_DEFINITIONS_H
34 
35 #include <iostream>
36 #include <sstream>
37 #include <inttypes.h>
38 #include "configuration.h"
39 
40 namespace faudes {
41 
42 /** Type definition for index type (allways 32bit) */
43 typedef uint32_t Idx;
44 #define FAUDES_IDX_MAX 0xFFFFFFFFU
45 
46 /** Type definition for integer type (let target system decide, minimum 32bit) */
47 typedef long int Int;
48 #define FAUDES_INT_MIN (std::numeric_limits<int>::min())
49 #define FAUDES_INT_MAX (std::numeric_limits<Type>::max())
50 
51 /** Type definition for real type */
52 typedef double Float;
53 
54 /** Length of strings for text fields in token output*/
55 #define FD_NAMELEN 13
56 
57 /** Max length of automatic container names (set to -1 for unlimited) */
58 #define FD_MAXCONTAINERNAME 70
59 
60 /** Max size of transrel for state name output */
61 #define FD_SMALLTRANSREL 100
62 
63 /** Min number of states to use consecutive section in file output */
64 #define FD_CONSECUTIVE 6
65 
66 /** Max number of automatic signatures */
67 #define FD_RTIMAXSIG 5
68 
69 #ifndef FAUDES_VERSION
70 /** Fallback version string (should define version in Makefile) */
71 #define FAUDES_VERSION "undefined version"
72 #endif
73 
74 /** Debug: console output, no redirection */
75 #define FAUDES_WRITE_DIRECT(message) \
76  { if(!faudes::ConsoleOut::G()->Mute()) { std::cout << message << std::endl;} }
77 
78 /** Debug: output macro for optional redirection of all console output */
79 #define FAUDES_WRITE_CONSOLE(message) \
80  { if(!faudes::ConsoleOut::G()->Mute()) { \
81  std::ostringstream cfl_line; cfl_line << message << std::endl; \
82  faudes::ConsoleOut::G()->Write(cfl_line.str()); } }
83 
84 /** Debug: always report warnings */
85 #define FD_WARN(message) FAUDES_WRITE_CONSOLE("FAUDES_WARNING: " << message)
86 
87 /** Debug: report more errors with file/line info */
88 #ifdef FAUDES_DEBUG_CODE
89 #define FD_ERR(message) \
90  FAUDES_WRITE_CONSOLE("FAUDES_CODE: " << message << " in " << __FILE__ << ":" << __LINE__ )
91 #else
92 #define FD_ERR(message)
93 #endif
94 
95 /** Application callback: optional write progress report to console or application */
96 #ifdef FAUDES_WRITE_PROGRESS
97 #define FD_WP(message) {FAUDES_WRITE_CONSOLE("FAUDES_PROGRESS: " << message); LoopCallback();}
98 #else
99 #define FD_WP(message)
100 #endif
101 
102 /** Application callback: optional write progress report to console or application, incl count */
103 #ifdef FAUDES_WRITE_PROGRESS
104 #define FD_WPC(cntnow, cntdone, message) \
105  { std::ostringstream cfl_line; cfl_line << "FAUDES_PROGRESS: " << message << std::endl; \
106  faudes::ConsoleOut::G()->Write(cfl_line.str(),(cntnow),(cntdone)); LoopCallback(); }
107 #else
108 #define FD_WPC(cntnow, contdone, message)
109 #endif
110 
111 /** Alternative progessreport for development */
112 #define FD_WPD(cntnow, cntdone, message) { \
113  static faudes_systime_t start; \
114  static faudes_systime_t now; \
115  static faudes_mstime_t lap; \
116  static Int prog; \
117  static bool init(false); \
118  if(!init) { faudes_gettimeofday(&start); prog=cntnow;} \
119  faudes_gettimeofday(&now); \
120  faudes_diffsystime(now,start,&lap); \
121  if(!init) lap=10000; \
122  if(lap>=10000) { \
123  Int cps = (cntnow-prog)/(lap/1000); \
124  std::ostringstream cfl_line; \
125  cfl_line << "FAUDES_PROGRESS: " << message; \
126  if(cntnow>0) cfl_line << " (#/sec: " << cps << ")";\
127  cfl_line << std::endl; \
128  faudes::ConsoleOut::G()->Write(cfl_line.str(),(cntnow),(cntdone)); LoopCallback(); \
129  faudes_gettimeofday(&start); \
130  prog=cntnow; \
131  } \
132  init=true; }
133 
134 
135 /** Debug: optional report on user functions */
136 #ifdef FAUDES_DEBUG_FUNCTION
137 #define FD_DF(message) FAUDES_WRITE_CONSOLE("FAUDES_FUNCTION: " << message)
138 #else
139 #define FD_DF(message)
140 #endif
141 
142 
143 /** Debug: optional report on generator operations */
144 #ifdef FAUDES_DEBUG_GENERATOR
145 #define FD_DG(message) FAUDES_WRITE_CONSOLE("FAUDES_GENERATOR: " << message)
146 #else
147 #define FD_DG(message)
148 #endif
149 
150 /** Debug: optional report on container operations */
151 #ifdef FAUDES_DEBUG_CONTAINER
152 #define FD_DC(message) FAUDES_WRITE_CONSOLE("FAUDES_CONTAINER: " << message)
153 #else
154 #define FD_DC(message)
155 #endif
156 
157 /** Debug: optional on function and type definition */
158 #ifdef FAUDES_DEBUG_RUNTIMEINTERFACE
159 #define FD_DRTI(message) FAUDES_WRITE_CONSOLE("FAUDES_RTI: " << message)
160 #else
161 #define FD_DRTI(message)
162 #endif
163 
164 /** Debug: optional report registry operations */
165 #ifdef FAUDES_DEBUG_REGISTRY
166 #define FD_DREG(message) FAUDES_WRITE_CONSOLE("FAUDES_REG: " << message)
167 #else
168 #define FD_DREG(message)
169 #endif
170 
171 /** Debug: optional low-level report on iterations and token IO */
172 #ifdef FAUDES_DEBUG_VERBOSE
173 #define FD_DV(message) FAUDES_WRITE_CONSOLE("FAUDES_VERBOSE: " << message)
174 #else
175 #define FD_DV(message)
176 #endif
177 
178 /** Debug: count objects, report on exit */
179 #ifdef FAUDES_DEBUG_CODE
180 #define FAUDES_OBJCOUNT_INC(type) ObjectCount::Inc(type)
181 #define FAUDES_OBJCOUNT_DEC(type) ObjectCount::Dec(type)
182 #else
183 #define FAUDES_OBJCOUNT_INC(type)
184 #define FAUDES_OBJCOUNT_DEC(type)
185 #endif
186 
187 /** Debug: timing */
188 #define FAUDES_TIMER_START(msg) { \
189  FD_WARN("timer start " << msg ); \
190  faudes_gettimeofday(& gPerfTimer1 ); }
191 #define FAUDES_TIMER_LAP(msg) { \
192  faudes_systime_t now; \
193  faudes_mstime_t lap; \
194  faudes_gettimeofday(&now); \
195  faudes_diffsystime(now,gPerfTimer1,&lap); \
196  FD_WARN("timer lap " << msg << " " << lap << "ms");}
197 
198 
199 /** Tutorial/debugging mark */
200 #define FD_DLINE(message) FD_WARN( \
201  std::endl << "################################################ " << \
202  std::endl << message << " at file " << __FILE__ << ", line " << __LINE__ << endl << \
203  std::endl << "################################################ " << std::endl );
204 
205 
206 /** Doxygen: exclude this from doxygen */
207 #ifndef FAUDES_DOXYGEN
208 #define FAUDES_NODOC(a) a
209 #else
210 #define FAUDES_NODOC(a)
211 #endif
212 
213 /* Doxygen: include group definitions */
214 #ifdef FAUDES_DOXYGEN
215 #include "doxygen_groups.h"
216 #endif
217 
218 } // namespace faudes
219 
220 #endif
221 
uint32_t Idx
double Float
long int Int

libFAUDES 2.33a --- 2025.05.02 --- c++ api documentaion by doxygen