Generic Trace Generator (GTG)  0.1
GTGOTF_Structs.h
Go to the documentation of this file.
00001 
00017 #ifndef _GTG_OTF_STRUCTS_H_
00018 #define _GTG_OTF_STRUCTS_H_
00019 
00020 #include <stdint.h>
00021 #include "GTGList.h"
00022 #include "GTGStack.h"
00023 
00024 /* todo: remove this */
00025 #define MAX_PROCESS 64
00026 
00028 typedef struct StateType { /* Func group */
00029     char           *name;
00030     char           *alias;
00031     int             groupId;
00032     int             id;
00033     struct gtg_list token;      /* stored in the stateTypes list */
00034 } StateType_t;
00035 
00037 typedef struct State {
00038     int             value;
00039     int             cont;
00040     int             stateType;
00041     gtg_stack token;    /* stored in the states list */
00042 } State_t;
00043 
00044 /* ContainerTypes */
00045 typedef struct ContainerType {
00046     char           *name;
00047     char           *alias;
00048     int             id;
00049     struct gtg_list token;      /* stored in the ctType list */
00050 } ContainerType_t;
00051 
00053 typedef struct Container {
00054     char            *name;
00055     char            *alias;
00056     int             ctType;
00057     int             id;
00058     struct gtg_list token;      /* stored in the conts list */
00059     State_t state_stack;
00060 } Container_t;
00061 
00063 typedef struct EntityValue {
00064     char           *name;
00065     char           *alias;
00066     int             groupId;
00067     int             id;
00068     struct gtg_list token;      /* not used */
00069 } EntityValue_t;
00070 
00072 typedef struct EventType {
00073     char           *name;
00074     char           *alias;
00075     int             contType;
00076     int             id;
00077     struct gtg_list token;      /* stored in the eventTypes list */
00078 } EventType_t;
00079 
00081 typedef struct LinkType {
00082     char           *name;
00083     char           *alias;
00084     int             contType;
00085     int             srcType;
00086     int             destType;
00087     int             id;
00088     struct gtg_list token;      /* stored in the linkTypes lisk */
00089 } LinkType_t;
00090 
00091 typedef struct Link {
00092     varPrec time;
00093     int src;
00094 } Link_t;
00095 
00096 
00098 typedef struct VariableType {
00099     char           *name;
00100     char           *alias;
00101     int             contType;
00102     int             id;
00103     struct gtg_list token;      /* stored in the variableTypes list */
00104 } VariableType_t;
00105 
00106 typedef struct Variable {
00107     int             parent;
00108     int             type;
00109     uint64_t        value;
00110     int             id;
00111     struct gtg_list token;      /* stored in the variables list */
00112 } Variable_t;
00113 
00114 struct otf_color {
00115     char *colorID;
00116     uint8_t red;
00117     uint8_t green;
00118     uint8_t blue;
00119 };
00120 
00121 typedef struct otf_color* otf_color_t;
00122 
00123 #define ContainerType_NIL 0
00124 #define Container_NIL     0
00125 #define StateType_NIL     0
00126 #define State_NIL         0
00127 #define EntityValue_NIL   0
00128 #define EventType_NIL     0
00129 #define LinkType_NIL      0
00130 #define VariableType_NIL  0
00131 #define Variable_NIL      0
00132 
00133 #define init_ContainerType(var)\
00134   do {                            \
00135     (var).name  = NULL;           \
00136     (var).alias = NULL;           \
00137     (var).id    = ContainerType_NIL;              \
00138     GTG_LIST_INIT(&(var).token);  \
00139   }while(0)
00140 
00141 #define init_Container(var)                     \
00142   do {                                          \
00143     (var).name   = NULL;                        \
00144     (var).alias  = NULL;                        \
00145     (var).ctType = ContainerType_NIL;           \
00146     (var).id     = Container_NIL;               \
00147     GTG_LIST_INIT(&(var).token);                \
00148     GTG_STACK_INIT(&(var).state_stack.token);   \
00149   }while(0)
00150 
00151 #define init_StateType(var)               \
00152   do {                                    \
00153     (var).name    = NULL;                 \
00154     (var).alias   = NULL;                 \
00155     (var).groupId = 0;                    \
00156     (var).id      = StateType_NIL;        \
00157     GTG_LIST_INIT(&(var).token);          \
00158   }while(0)
00159 
00160 #define init_EntityValue(var)                   \
00161   do {                                          \
00162     (var).name    = NULL;                       \
00163     (var).alias   = NULL;                       \
00164     (var).groupId = 0;                          \
00165     (var).id      = EntityValue_NIL;            \
00166     GTG_LIST_INIT(&(var).token);                \
00167   }while(0)
00168 
00169 #define init_EventType(var)                     \
00170   do {                                          \
00171     (var).name     = NULL;                      \
00172     (var).alias   = NULL;                       \
00173     (var).contType = ContainerType_NIL;         \
00174     (var).id       = EventType_NIL;             \
00175     GTG_LIST_INIT(&(var).token);                \
00176   }while(0)
00177 
00178 #define init_LinkType(var)                      \
00179   do {                                          \
00180     (var).name     = NULL;                      \
00181     (var).alias   = NULL;                       \
00182     (var).contType = ContainerType_NIL;         \
00183     (var).srcType  = ContainerType_NIL;         \
00184     (var).destType = ContainerType_NIL;         \
00185     (var).id       = LinkType_NIL;              \
00186     GTG_LIST_INIT(&(var).token);                \
00187   }while(0)
00188 
00189 #define init_VariableType(var)                  \
00190   do {                                          \
00191     (var).name     = NULL;                      \
00192     (var).alias    = NULL;                      \
00193     (var).contType = ContainerType_NIL;         \
00194     (var).id       = VariableType_NIL;          \
00195     GTG_LIST_INIT(&(var).token);                \
00196   }while(0)
00197 
00198 #define init_Variable(var)                      \
00199   do {                                          \
00200     (var).parent = Container_NIL;               \
00201     (var).parent = VariableType_NIL;            \
00202     (var).value  = 0;                           \
00203     (var).id     = Variable_NIL;                \
00204     GTG_LIST_INIT(&(var).token);                \
00205   }while(0)
00206 
00207 #define init_State(var)                         \
00208   do {                                          \
00209     (var).value   = EntityValue_NIL;            \
00210     (var).cont    = Container_NIL;              \
00211     (var).stateType = StateType_NIL;            \
00212     GTG_STACK_INIT(&(var).token);               \
00213   }while(0)
00214 
00215 
00216 #define alloc_struct(ptr, type, list_head)                              \
00217   do {                                                                  \
00218     ptr = (type*) malloc(sizeof(type));                         \
00219     GTG_LIST_INIT(&(ptr->token));                                       \
00220     ptr->id = (gtg_list_entry((list_head)->prev, type, token)->id) + 1; \
00221     gtg_list_add_tail(&(ptr->token), list_head);                        \
00222   } while(0)
00223 
00224 #define alloc_init_struct(type, ptr, list_head, _name_, _alias_)        \
00225   do {                                                                  \
00226   alloc_struct(ptr, type, list_head);                                   \
00227   (ptr)->name = (char *)malloc(sizeof(char)*(strlen(_name_)+1));        \
00228   strcpy((ptr)->name, _name_);                                          \
00229   (ptr)->alias = (char *)malloc(sizeof(char)*(strlen(_alias_)+1));      \
00230   strcpy((ptr)->alias, _alias_);                                        \
00231   }while(0)
00232 
00233 #define alloc_Variable(_ptr_, _id_, _parent_, _type_, _value_)  \
00234   do {                                                          \
00235     (_ptr_) = (Variable_t*) malloc(sizeof(Variable_t));         \
00236     init_Variable(*(_ptr_));                                    \
00237     (_ptr_)->id = _id_;                                         \
00238     (_ptr_)->parent = _parent_;                                 \
00239     (_ptr_)->type = _type_;                                     \
00240     (_ptr_)->value = _value_;                                   \
00241   }while(0)
00242 
00243 #define alloc_State(_ptr_, _value_, _cont_, _stateType_)        \
00244   do {                                                          \
00245     _ptr_ = (State_t*) malloc(sizeof(State_t));                 \
00246     init_State(*(_ptr_));                                       \
00247     (_ptr_)->value = _value_;                                   \
00248     (_ptr_)->cont = _cont_;                                     \
00249     (_ptr_)->stateType = _stateType_;                           \
00250   }while(0)
00251 
00252 #define free_struct(_type_, _list_head_)\
00253   do{\
00254     _type_ *ptr, *tmp;                                  \
00255     gtg_list_for_each_entry_safe(ptr, tmp, &(_list_head_).token, token) {       \
00256     gtg_list_del(&(ptr->token));\
00257     free(ptr->name);\
00258     free(ptr->alias);\
00259     free(ptr);\
00260   }\
00261   }while(0)
00262 
00263 #endif /* _GTG_OTF_STRUCTS_H_ */