-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIMSim.h
65 lines (51 loc) · 1.86 KB
/
IMSim.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/**
* FIT VUT Brno
* IMS: Projekt "Knihovna pro kombinovanou simulaci"
*
* @author Jiri Petruzelka [email protected]
* @author Petr Mejzlik [email protected]
*/
#ifndef IMSIM_H
#define IMSIM_H
/* Includes */
#include <stdio.h>
/* Load basic symbols */
// load only if loaded from client script
#ifndef IMSIMINTERNAL_H
#include "includes.h"
// default implementation, does not have to be used
//IMSim::Randomness::BasicCongruentGenerator* rnd = new IMSim::Randomness::BasicCongruentGenerator();
#endif
// Inlines
/**
* Wraps the function name as a pointer and casts it to the common parent pointer type
*
* @param function callback
*/
#define NEXT(callback) ((ACTION_CALLBACK)(&callback))
#define ARG(var) ((void*)&(var))
#define CALLSELF new Action( this, NULL, 0.0 )
#define CALLBACK(fnc) new Action( this, NEXT(fnc), 0.0 )
#define NUM(x) (new Block((BLOCK_VALUE)x))
#define B_BLC(x) (new Block(x))
#define B_SIN(x) ((new Block(x))->setStrategy(new SinusBlock))
#define B_LIN(x, c) ((new Block(x))->setStrategy(new LinearBlock(c)))
#define B_ADD(x, y) ((new Block(x, y))->setStrategy(new AddBlock))
#define B_SUB(x, y) ((new Block(x, y))->setStrategy(new SubtrackBlock))
#define B_MUL(x, y) ((new Block(x, y))->setStrategy(new MultiplyBlock))
#define B_DIV(x, y) ((new Block(x, y))->setStrategy(new DivideBlock))
#define B_INTEG(x) ((new Block(x))->setStrategy(new Integrator))
#define B_INTEG_IN(x, v, t) ((new Block(x))->setStrategy( (new Integrator)->setCurrent(v, t) ))
#define B_POW(x, y) ((new Block(x, y))->setStrategy(new PowerBlock))
/*inline void B_REG(IMSim::Simulation* sim, IMSim::Block* bl) {
sim->getBlockContainer()->addBlock(bl);
}*/
/**
* Experimental, not used yet
*
* Returns the adress of the caller's instruction
*/
inline void* back(){
return __builtin_return_address(0);
}
#endif /* IMSIM_H */