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 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 "configuration.h"
36 #include "cfl_platform.h"
37 
38 #include <sstream>
39 #include <iostream>
40 #include <inttypes.h>
41 
42 namespace faudes {
43 
44 
45 /** Type definition for index type (allways 32bit) */
46 typedef uint32_t Idx;
47 #define FAUDES_IDX_MAX 0xFFFFFFFFU
48 
49 /** Type definition for integer type (let target system decide, minimum 32bit) */
50 typedef long int Int;
51 #define FAUDES_INT_MIN LONG_MIN
52 #define FAUDES_INT_MAX LONG_MAX
53 
54 /** Type definition for real type (use C std double, must at least represent Int) */
55 typedef double Float;
56 
57 /** Length of strings for text fields in token output*/
58 #define FD_NAMELEN 13
59 
60 /** Max length of automatic container names (set to -1 for unlimited) */
61 #define FD_MAXCONTAINERNAME 70
62 
63 /** Max size of transrel for state name output */
64 #define FD_SMALLTRANSREL 100
65 
66 /** Min number of states to use consecutive section in file output */
67 #define FD_CONSECUTIVE 6
68 
69 /** Max number of automatic signatures */
70 #define FD_RTIMAXSIG 5
71 
72 #ifndef FAUDES_VERSION
73 /** Fallback version string (should define version in Makefile) */
74 #define FAUDES_VERSION "undefined version"
75 #endif
76 
77 /** Debug: console output, no redirection */
78 #define FAUDES_WRITE_DIRECT(message) \
79  { if(!ConsoleOut::G()->Mute()) { std::cout << message << std::endl;} }
80 
81 /** Debug: output macro for optional redirection of all console output */
82 #define FAUDES_WRITE_CONSOLE(message) \
83  { if(!ConsoleOut::G()->Mute()) { \
84  std::ostringstream cfl_line; cfl_line << message << std::endl; ConsoleOut::G()->Write(cfl_line.str());} }
85 
86 /** Debug: always report warnings */
87 #define FD_WARN(message) FAUDES_WRITE_CONSOLE("FAUDES_WARNING: " << message)
88 
89 /** Debug: report more errors with file/line info */
90 #ifdef FAUDES_DEBUG_CODE
91 #define FD_ERR(message) \
92  FAUDES_WRITE_CONSOLE("FAUDES_CODE: " << message << " in " << __FILE__ << ":" << __LINE__ )
93 #else
94 #define FD_ERR(message)
95 #endif
96 
97 /** Application callback: optional write progress report to console or application */
98 #ifdef FAUDES_WRITE_PROGRESS
99 #define FD_WP(message) {FAUDES_WRITE_CONSOLE("FAUDES_PROGRESS: " << message); LoopCallback();}
100 #else
101 #define FD_WP(message)
102 #endif
103 
104 /** Application callback: optional write progress report to console or application, incl count */
105 #ifdef FAUDES_WRITE_PROGRESS
106 #define FD_WPC(cntnow, cntdone, message) \
107  { std::ostringstream cfl_line; cfl_line << "FAUDES_PROGRESS: " << message << std::endl; \
108  ConsoleOut::G()->Write(cfl_line.str(),(cntnow),(cntdone)); LoopCallback(); }
109 #else
110 #define FD_WPC(cntnow, contdone, message)
111 #endif
112 
113 /** Alternative progessreport for development */
114 #define FD_WPD(cntnow, cntdone, message) { \
115  static faudes_systime_t start; \
116  static faudes_systime_t now; \
117  static faudes_mstime_t lap; \
118  static Int prog; \
119  static bool init(false); \
120  if(!init) { faudes_gettimeofday(&start); prog=cntnow;} \
121  faudes_gettimeofday(&now); \
122  faudes_diffsystime(now,start,&lap); \
123  if(!init) lap=10000; \
124  if(lap>=10000) { \
125  Int cps = (cntnow-prog)/(lap/1000); \
126  std::ostringstream cfl_line; \
127  cfl_line << "FAUDES_PROGRESS: " << message; \
128  if(cntnow>0) cfl_line << " (#/sec: " << cps << ")";\
129  cfl_line << std::endl; \
130  ConsoleOut::G()->Write(cfl_line.str(),(cntnow),(cntdone)); LoopCallback(); \
131  faudes_gettimeofday(&start); \
132  prog=cntnow; \
133  } \
134  init=true; }
135 
136 
137 /** Debug: optional report on user functions */
138 #ifdef FAUDES_DEBUG_FUNCTION
139 #define FD_DF(message) FAUDES_WRITE_CONSOLE("FAUDES_FUNCTION: " << message)
140 #else
141 #define FD_DF(message)
142 #endif
143 
144 
145 /** Debug: optional report on generator operations */
146 #ifdef FAUDES_DEBUG_GENERATOR
147 #define FD_DG(message) FAUDES_WRITE_CONSOLE("FAUDES_GENERATOR: " << message)
148 #else
149 #define FD_DG(message)
150 #endif
151 
152 /** Debug: optional report on container operations */
153 #ifdef FAUDES_DEBUG_CONTAINER
154 #define FD_DC(message) FAUDES_WRITE_CONSOLE("FAUDES_CONTAINER: " << message)
155 #else
156 #define FD_DC(message)
157 #endif
158 
159 /** Debug: optional on function and type definition */
160 #ifdef FAUDES_DEBUG_RUNTIMEINTERFACE
161 #define FD_DRTI(message) FAUDES_WRITE_CONSOLE("FAUDES_RTI: " << message)
162 #else
163 #define FD_DRTI(message)
164 #endif
165 
166 /** Debug: optional report registry operations */
167 #ifdef FAUDES_DEBUG_REGISTRY
168 #define FD_DREG(message) FAUDES_WRITE_CONSOLE("FAUDES_REG: " << message)
169 #else
170 #define FD_DREG(message)
171 #endif
172 
173 /** Debug: optional low-level report on iterations and token IO */
174 #ifdef FAUDES_DEBUG_VERBOSE
175 #define FD_DV(message) FAUDES_WRITE_CONSOLE("FAUDES_VERBOSE: " << message)
176 #else
177 #define FD_DV(message)
178 #endif
179 
180 /** Debug: count objects, report on exit */
181 #ifdef FAUDES_DEBUG_CODE
182 #define FAUDES_OBJCOUNT_INC(type) ObjectCount::Inc(type)
183 #define FAUDES_OBJCOUNT_DEC(type) ObjectCount::Dec(type)
184 #else
185 #define FAUDES_OBJCOUNT_INC(type)
186 #define FAUDES_OBJCOUNT_DEC(type)
187 #endif
188 
189 /** Debug: timing */
190 #define FAUDES_TIMER_START(msg) { \
191  FD_WARN("timer start " << msg ); \
192  faudes_gettimeofday(& gPerfTimer1 ); }
193 #define FAUDES_TIMER_LAP(msg) { \
194  faudes_systime_t now; \
195  faudes_mstime_t lap; \
196  faudes_gettimeofday(&now); \
197  faudes_diffsystime(now,gPerfTimer1,&lap); \
198  FD_WARN("timer lap " << msg << " " << lap << "ms");}
199 
200 
201 /** Tutorial/debugging mark */
202 #define FD_DLINE(message) FD_WARN( \
203  std::endl << "################################################ " << \
204  std::endl << message << " at file " << __FILE__ << ", line " << __LINE__ << endl << \
205  std::endl << "################################################ " << std::endl );
206 
207 
208 /** Doxygen: exclude this from doxygen */
209 #ifndef FAUDES_DOXYGEN
210 #define FAUDES_NODOC(a) a
211 #else
212 #define FAUDES_NODOC(a)
213 #endif
214 
215 /* Doxygen: include group definitions */
216 #ifdef FAUDES_DOXYGEN
217 #include "doxygen_groups.h"
218 #endif
219 
220 } // namespace faudes
221 
222 #endif
223 

libFAUDES 2.26g --- 2015.08.17 --- c++ api documentaion by doxygen