00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #if !defined(__SPARKMACRO_H__)
00026 #define __SPARKMACRO_H__
00027
00028
00029 #include "variable.h"
00030 #include "callback.h"
00031 #include "inverse.h"
00032 #include "object.h"
00033 #include "component.h"
00034 #include "problem.h"
00035 #include "sparkapi.h"
00036 #include "spark.h"
00037
00038
00039
00040
00041
00042
00043
00044
00045 #define _QUOTE_(x) #x
00046
00047
00048 #define _NAMESPACE_(name) _##name
00049
00050
00051
00052
00053
00054
00055
00056
00057 #define START_ARRAY( size ) \
00058 const unsigned Size = size; \
00059 element_type Array[] = { \
00060
00061
00062 #define END_ARRAY };
00063
00064
00065 #define EMPTY_ARRAY \
00066 const unsigned Size = 0; \
00067 element_type* Array = 0; \
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077 #define START_PROBLEM( name ) \
00078 namespace Problem__##name { \
00079 const char* Name = _QUOTE_(name); \
00080
00081
00082
00083
00084 #define END_PROBLEM \
00085 SPARK::TProblem Element( \
00086 Inverses::Size, Inverses::Array, \
00087 Variables::Size, Variables::Array, \
00088 Components::Size, Components::Array \
00089 ); \
00090 bool IsRegistered = SPARK::Problem::RegisterStaticInstance( Name, &Element ); \
00091 }; \
00092
00093
00094
00095
00096
00097
00098
00099
00100 #define START_INVERSES namespace Inverses { \
00101 typedef SPARK::TInverse* element_type; \
00102
00103
00104
00105 #define END_INVERSES };
00106
00107 #define START_INVERSE( handle, name, className, fileName, type ) \
00108 namespace Inverse_##handle { \
00109 unsigned Handle = handle; \
00110 const char* Name = name; \
00111 const char* ClassName = className; \
00112 const char* FileName = fileName; \
00113 SPARK::AtomicTypes Type = SPARK::type; \
00114
00115 #define END_INVERSE \
00116 SPARK::TInverse Element( \
00117 Handle, Name, ClassName, FileName, Type, \
00118 Predict::Callback, Evaluate::Callback, \
00119 Construct::Callback, Destruct::Callback, \
00120 PrepareStep::Callback, CheckIntegrationStep::Callback, \
00121 Rollback::Callback, Commit::Callback, \
00122 StaticConstruct::Callback, StaticDestruct::Callback, \
00123 StaticPrepareStep::Callback, StaticCheckIntegrationStep::Callback, \
00124 StaticRollback::Callback, StaticCommit::Callback \
00125 ); \
00126 }; \
00127
00128 #define INVERSE( handle ) &Inverses::Inverse_##handle::Element
00129
00130
00131
00132
00133
00134
00135
00136 #define DECL_MODIFIER_CALLBACK( type, name, function, returnType ) \
00137 namespace name { \
00138 SPARK::TModifierCallback Callback( SPARK::type, _QUOTE_(function), &function, SPARK::returnType); \
00139 }; \
00140
00141 #define NO_MODIFIER_CALLBACK( type, name ) \
00142 namespace name { \
00143 SPARK::TModifierCallback Callback( SPARK::type ); \
00144 }; \
00145
00146 #define DECL_EVALUATE_CALLBACK( function, returnType ) DECL_MODIFIER_CALLBACK( CallbackType_EVALUATE, Evaluate, function, returnType )
00147 #define NO_EVALUATE_CALLBACK NO_MODIFIER_CALLBACK( CallbackType_EVALUATE, Evaluate )
00148
00149 #define DECL_PREDICT_CALLBACK( function, returnType ) DECL_MODIFIER_CALLBACK( CallbackType_PREDICT, Predict, function, returnType )
00150 #define NO_PREDICT_CALLBACK NO_MODIFIER_CALLBACK( CallbackType_PREDICT, Predict )
00151
00152
00153
00154 #define DECL_NON_MODIFIER_CALLBACK( type, name, function ) \
00155 namespace name { \
00156 SPARK::TNonModifierCallback Callback( SPARK::type, _QUOTE_(function), &function ); \
00157 }; \
00158
00159 #define NO_NON_MODIFIER_CALLBACK( type, name ) \
00160 namespace name { \
00161 SPARK::TNonModifierCallback Callback( SPARK::type ); \
00162 }; \
00163
00164 #define DECL_CONSTRUCT_CALLBACK( function ) DECL_NON_MODIFIER_CALLBACK( CallbackType_CONSTRUCT, Construct, function )
00165 #define NO_CONSTRUCT_CALLBACK NO_NON_MODIFIER_CALLBACK( CallbackType_CONSTRUCT, Construct )
00166
00167 #define DECL_DESTRUCT_CALLBACK( function ) DECL_NON_MODIFIER_CALLBACK( CallbackType_DESTRUCT, Destruct, function )
00168 #define NO_DESTRUCT_CALLBACK NO_NON_MODIFIER_CALLBACK( CallbackType_DESTRUCT, Destruct )
00169
00170 #define DECL_PREPARE_STEP_CALLBACK( function ) DECL_NON_MODIFIER_CALLBACK( CallbackType_PREPARE_STEP, PrepareStep, function )
00171 #define NO_PREPARE_STEP_CALLBACK NO_NON_MODIFIER_CALLBACK( CallbackType_PREPARE_STEP, PrepareStep )
00172
00173 #define DECL_ROLLBACK_CALLBACK( function ) DECL_NON_MODIFIER_CALLBACK( CallbackType_ROLLBACK, Rollback, function )
00174 #define NO_ROLLBACK_CALLBACK NO_NON_MODIFIER_CALLBACK( CallbackType_ROLLBACK, Rollback )
00175
00176 #define DECL_COMMIT_CALLBACK( function ) DECL_NON_MODIFIER_CALLBACK( CallbackType_COMMIT, Commit, function )
00177 #define NO_COMMIT_CALLBACK NO_NON_MODIFIER_CALLBACK( CallbackType_COMMIT, Commit )
00178
00179
00180
00181 #define DECL_PREDICATE_CALLBACK( type, name, function ) \
00182 namespace name { \
00183 SPARK::TPredicateCallback Callback( SPARK::type, _QUOTE_(function), &function ); \
00184 }; \
00185
00186 #define NO_PREDICATE_CALLBACK( type, name ) \
00187 namespace name { \
00188 SPARK::TPredicateCallback Callback( SPARK::type ); \
00189 }; \
00190
00191 #define DECL_CHECK_INTEGRATION_STEP_CALLBACK( function ) DECL_PREDICATE_CALLBACK( CallbackType_CHECK_INTEGRATION_STEP, CheckIntegrationStep, function )
00192 #define NO_CHECK_INTEGRATION_STEP_CALLBACK NO_PREDICATE_CALLBACK( CallbackType_CHECK_INTEGRATION_STEP, CheckIntegrationStep )
00193
00194
00195
00196 #define DECL_STATIC_NON_MODIFIER_CALLBACK( type, name, function ) \
00197 namespace name { \
00198 SPARK::TStaticNonModifierCallback Callback( SPARK::type, _QUOTE_(function), &function ); \
00199 }; \
00200
00201 #define NO_STATIC_NON_MODIFIER_CALLBACK( type, name ) \
00202 namespace name { \
00203 SPARK::TStaticNonModifierCallback Callback( SPARK::type ); \
00204 }; \
00205
00206 #define DECL_STATIC_CONSTRUCT_CALLBACK( function ) DECL_STATIC_NON_MODIFIER_CALLBACK( CallbackType_STATIC_CONSTRUCT, StaticConstruct, function )
00207 #define NO_STATIC_CONSTRUCT_CALLBACK NO_STATIC_NON_MODIFIER_CALLBACK( CallbackType_STATIC_CONSTRUCT, StaticConstruct )
00208
00209 #define DECL_STATIC_DESTRUCT_CALLBACK( function ) DECL_STATIC_NON_MODIFIER_CALLBACK( CallbackType_STATIC_DESTRUCT, StaticDestruct, function )
00210 #define NO_STATIC_DESTRUCT_CALLBACK NO_STATIC_NON_MODIFIER_CALLBACK( CallbackType_STATIC_DESTRUCT, StaticDestruct )
00211
00212 #define DECL_STATIC_PREPARE_STEP_CALLBACK( function ) DECL_STATIC_NON_MODIFIER_CALLBACK( CallbackType_STATIC_PREPARE_STEP, StaticPrepareStep, function )
00213 #define NO_STATIC_PREPARE_STEP_CALLBACK NO_STATIC_NON_MODIFIER_CALLBACK( CallbackType_STATIC_PREPARE_STEP, StaticPrepareStep )
00214
00215 #define DECL_STATIC_ROLLBACK_CALLBACK( function ) DECL_STATIC_NON_MODIFIER_CALLBACK( CallbackType_STATIC_ROLLBACK, StaticRollback, function )
00216 #define NO_STATIC_ROLLBACK_CALLBACK NO_STATIC_NON_MODIFIER_CALLBACK( CallbackType_STATIC_ROLLBACK, StaticRollback )
00217
00218 #define DECL_STATIC_COMMIT_CALLBACK( function ) DECL_STATIC_NON_MODIFIER_CALLBACK( CallbackType_STATIC_COMMIT, StaticCommit, function )
00219 #define NO_STATIC_COMMIT_CALLBACK NO_STATIC_NON_MODIFIER_CALLBACK( CallbackType_STATIC_COMMIT, StaticCommit )
00220
00221
00222
00223 #define DECL_STATIC_PREDICATE_CALLBACK( type, name, function ) \
00224 namespace name { \
00225 SPARK::TStaticPredicateCallback Callback( SPARK::type, _QUOTE_(function), &function ); \
00226 }; \
00227
00228 #define NO_STATIC_PREDICATE_CALLBACK( type, name ) \
00229 namespace name { \
00230 SPARK::TStaticPredicateCallback Callback( SPARK::type ); \
00231 }; \
00232
00233 #define DECL_STATIC_CHECK_INTEGRATION_STEP_CALLBACK( function ) DECL_STATIC_PREDICATE_CALLBACK( CallbackType_STATIC_CHECK_INTEGRATION_STEP, StaticCheckIntegrationStep, function )
00234 #define NO_STATIC_CHECK_INTEGRATION_STEP_CALLBACK NO_STATIC_PREDICATE_CALLBACK( CallbackType_STATIC_CHECK_INTEGRATION_STEP, StaticCheckIntegrationStep )
00235
00236
00237
00238
00239
00240
00241
00242 #define START_VARIABLES \
00243 namespace Variables { \
00244 typedef SPARK::TVariable* element_type; \
00245
00246 #define END_VARIABLES };
00247
00248 #define VARIABLE( handle ) &Variables::Variable_##handle::Element
00249
00250 #define DECL_VARIABLE( handle, name, unit, type, init, min, max, atol, from_link, rd_url, wr_url ) \
00251 namespace Variable_##handle { \
00252 SPARK::TVariable Element( handle, name, unit, SPARK::type, init, min, max, atol, from_link, rd_url, wr_url); \
00253 }; \
00254
00255
00256
00257
00258
00259
00260 #define START_UNKNOWNS( name, size ) \
00261 namespace name { \
00262 typedef SPARK::TUnknown element_type; \
00263 START_ARRAY( size ) \
00264
00265 #define END_UNKNOWNS( name ) \
00266 END_ARRAY \
00267 }; \
00268
00269 #define NO_UNKNOWNS( name ) \
00270 namespace name { \
00271 typedef SPARK::TUnknown element_type; \
00272 EMPTY_ARRAY \
00273 }; \
00274
00275 #define DECL_UNKNOWN( var_id ) SPARK::TUnknown( VARIABLE( var_id ) )
00276
00277
00278
00279
00280
00281
00282
00283 #define START_TARGETS( size ) \
00284 namespace Targets { \
00285 typedef SPARK::TTarget element_type; \
00286 START_ARRAY( size ) \
00287
00288 #define END_TARGETS \
00289 END_ARRAY \
00290 }; \
00291
00292 #define NO_TARGETS \
00293 namespace Targets { \
00294 typedef SPARK::TTarget element_type; \
00295 EMPTY_ARRAY \
00296 }; \
00297
00298 #define DECL_TARGET( var_id ) SPARK::TTarget( VARIABLE( var_id ) )
00299
00300
00301
00302
00303
00304
00305
00306 #define START_ARGUMENTS( name, size ) \
00307 namespace name { \
00308 typedef SPARK::TArgument element_type; \
00309 START_ARRAY( size ) \
00310
00311 #define END_ARGUMENTS( name ) \
00312 END_ARRAY \
00313 }; \
00314
00315 #define NO_ARGUMENTS( name ) \
00316 namespace name { \
00317 typedef SPARK::TArgument element_type; \
00318 EMPTY_ARRAY \
00319 }; \
00320
00321 #define DECL_ARGUMENT( var_id ) SPARK::TArgument( VARIABLE( var_id ) )
00322
00323
00324
00325
00326
00327
00328
00329 #define START_COMPONENTS \
00330 namespace Components { \
00331 typedef SPARK::TComponent* element_type; \
00332
00333 #define END_COMPONENTS };
00334
00335
00336
00337
00338
00339
00340
00341 #define START_COMPONENT( handle ) \
00342 namespace Component_##handle { \
00343 const unsigned Handle = handle; \
00344
00345 #define END_COMPONENT \
00346 SPARK::TComponent Element(\
00347 Handle, \
00348 NormalUnknowns::Size, NormalUnknowns::Array, \
00349 BreakUnknowns::Size, BreakUnknowns::Array, \
00350 Objects::Size, Objects::Array \
00351 ); \
00352 }; \
00353
00354 #define COMPONENT( handle ) &Components::Component_##handle::Element
00355
00356
00357 #define START_NORMAL_UNKNOWNS( size ) START_UNKNOWNS( NormalUnknowns, size )
00358 #define END_NORMAL_UNKNOWNS END_UNKNOWNS( NormalUnknowns )
00359 #define NO_NORMAL_UNKNOWNS NO_UNKNOWNS( NormalUnknowns )
00360
00361 #define START_BREAK_UNKNOWNS( size ) START_UNKNOWNS( BreakUnknowns, size )
00362 #define END_BREAK_UNKNOWNS END_UNKNOWNS( BreakUnknowns )
00363 #define NO_BREAK_UNKNOWNS NO_UNKNOWNS( BreakUnknowns )
00364
00365
00366
00367
00368
00369
00370 #define START_OBJECTS \
00371 namespace Objects { \
00372 typedef SPARK::TObject* element_type; \
00373
00374 #define END_OBJECTS };
00375
00376
00377
00378
00379
00380
00381 #define START_OBJECT( handle, name, inverse ) \
00382 namespace Object_##handle { \
00383 const unsigned Handle = handle; \
00384 const char* Name = name; \
00385 SPARK::TInverse* Inverse = inverse; \
00386
00387 #define END_OBJECT \
00388 SPARK::TObject Element( \
00389 Handle, Name, Inverse, \
00390 Targets::Size, Targets::Array, \
00391 ArgList_Predict::Size, ArgList_Predict::Array, \
00392 ArgList_Evaluate::Size, ArgList_Evaluate::Array, \
00393 ArgList_Construct::Size, ArgList_Construct::Array, \
00394 ArgList_Destruct::Size, ArgList_Destruct::Array, \
00395 ArgList_PrepareStep::Size, ArgList_PrepareStep::Array, \
00396 ArgList_CheckIntegrationStep::Size, ArgList_CheckIntegrationStep::Array, \
00397 ArgList_Rollback::Size, ArgList_Rollback::Array, \
00398 ArgList_Commit::Size, ArgList_Commit::Array \
00399 ); \
00400 }; \
00401
00402 #define OBJECT( handle ) &Object_##handle::Element
00403
00404
00405 #define START_EVALUATE_ARGLIST( size ) START_ARGUMENTS( ArgList_Evaluate, size )
00406 #define END_EVALUATE_ARGLIST END_ARGUMENTS( ArgList_Evaluate )
00407 #define NO_EVALUATE_ARGLIST NO_ARGUMENTS( ArgList_Evaluate )
00408
00409 #define START_PREDICT_ARGLIST( size ) START_ARGUMENTS( ArgList_Predict, size )
00410 #define END_PREDICT_ARGLIST END_ARGUMENTS( ArgList_Predict )
00411 #define NO_PREDICT_ARGLIST NO_ARGUMENTS( ArgList_Predict )
00412
00413 #define START_CONSTRUCT_ARGLIST( size ) START_ARGUMENTS( ArgList_Construct, size )
00414 #define END_CONSTRUCT_ARGLIST END_ARGUMENTS( ArgList_Construct )
00415 #define NO_CONSTRUCT_ARGLIST NO_ARGUMENTS( ArgList_Construct )
00416
00417 #define START_DESTRUCT_ARGLIST( size ) START_ARGUMENTS( ArgList_Destruct, size )
00418 #define END_DESTRUCT_ARGLIST END_ARGUMENTS( ArgList_Destruct )
00419 #define NO_DESTRUCT_ARGLIST NO_ARGUMENTS( ArgList_Destruct )
00420
00421 #define START_PREPARE_STEP_ARGLIST( size ) START_ARGUMENTS( ArgList_PrepareStep, size )
00422 #define END_PREPARE_STEP_ARGLIST END_ARGUMENTS( ArgList_PrepareStep )
00423 #define NO_PREPARE_STEP_ARGLIST NO_ARGUMENTS( ArgList_PrepareStep )
00424
00425 #define START_CHECK_INTEGRATION_STEP_ARGLIST( size ) START_ARGUMENTS( ArgList_CheckIntegrationStep, size )
00426 #define END_CHECK_INTEGRATION_STEP_ARGLIST END_ARGUMENTS( ArgList_CheckIntegrationStep )
00427 #define NO_CHECK_INTEGRATION_STEP_ARGLIST NO_ARGUMENTS( ArgList_CheckIntegrationStep )
00428
00429 #define START_COMMIT_ARGLIST( size ) START_ARGUMENTS( ArgList_Commit, size )
00430 #define END_COMMIT_ARGLIST END_ARGUMENTS( ArgList_Commit )
00431 #define NO_COMMIT_ARGLIST NO_ARGUMENTS( ArgList_Commit )
00432
00433 #define START_ROLLBACK_ARGLIST( size ) START_ARGUMENTS( ArgList_Rollback, size )
00434 #define END_ROLLBACK_ARGLIST END_ARGUMENTS( ArgList_Rollback )
00435 #define NO_ROLLBACK_ARGLIST NO_ARGUMENTS( ArgList_Rollback )
00436
00437
00438 #endif //__SPARKMACRO_H__
00439
00440
00441