Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 243b28f97531a42c1c997b933d8342c1794ff83c (plain) (blame)
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
/*******************************************************************************
 * Copyright (c) 2012 protos software gmbh (http://www.protos.de).
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * CONTRIBUTORS:
 * 		Thomas Schuetz (initial contribution)
 *
 *******************************************************************************/

/**
 * \file etMSCLogger.h
 *
 * A collection of methods that can be used to write a message sequence chart (MSC,
 * also called sequence diagram in UML).
 * The format used is compatible with Astade Trace2UML, an open source MSC viewer.
 *
 * \author Thomas Schuetz
 */
#ifndef _ETMSCLOGGER_H_
#define _ETMSCLOGGER_H_

#include "etRuntimeConfig.h"

/**
 * opens a log file for the MSC. Only one at a time can be open.
 *
 * \param logPath the file path
 * \param mscName the file name
 */
void etMSCLogger_open(const char* logPath, const char* mscName);
/**
 * closes the MSC
 */
void etMSCLogger_close(void);

/**
 * sets an object name (for internal use)
 *
 * \param objectName the object name
 */
void etMSCLogger_setObjectName(const char* objectName);
/**
 * returns the object name previously set
 *
 * \return the object name
 */
const char* etMSCLogger_getObjectName(void);

/**
 * logs a synchronous call
 *
 * \param sourceName the calling instance
 * \param messageName the message
 * \param targetName the called instance
 */
void etMSCLogger_syncCall(const char* sourceName, const char* messageName, const char* targetName);
/**
 * logs a synchronous return
 *
 * \param sourceName the calling instance
 * \param targetName the called instance
 */
void etMSCLogger_syncReturn(const char* sourceName, const char* targetName);

/**
 * logs an outgoing asynchronous message
 *
 * \param sourceName the calling instance
 * \param messageName the message
 * \param targetName the called instance
 */
void etMSCLogger_asyncOut(const char* sourceName, const char* messageName, const char* targetName);
/**
 * logs an incoming asynchronous message
 *
 * \param sourceName the calling instance
 * \param messageName the message
 * \param targetName the called instance
 */
void etMSCLogger_asyncIn(const char* sourceName, const char* messageName, const char* targetName);

/**
 * logs a state change
 *
 * \param objectName the stateful instance
 * \param stateName the new state
 */
void etMSCLogger_setState(const char* objectName, const char* stateName);

#ifdef ET_MSC_LOGGER_ACTIVATE
	#define ET_MSC_LOGGER_OPEN(object) \
		etMSCLogger_open("tmp/log", "msc"); \
		etMSCLogger_setObjectName(object);

	#define ET_MSC_LOGGER_CLOSE etMSCLogger_close();

	#define ET_MSC_LOGGER_CHANGE_STATE(objectName, stateName) \
		etMSCLogger_setState(objectName, stateName);

	#ifdef ET_SYNC_MSC_LOGGER_ACTIVATE
		#define ET_MSC_LOGGER_SYNC_ENTRY(object, message) 			\
			const char* sourceName = etMSCLogger_getObjectName(); 	\
			const char* targetName = object;							\
			etMSCLogger_syncCall(sourceName, message, targetName); 	\
			etMSCLogger_setObjectName(targetName);
		#define ET_MSC_LOGGER_SYNC_EXIT \
			etMSCLogger_syncReturn(sourceName, targetName); \
			etMSCLogger_setObjectName(sourceName);
	#else
		#define ET_MSC_LOGGER_SYNC_ENTRY(object, message)
		#define ET_MSC_LOGGER_SYNC_EXIT
	#endif


	#ifdef ET_ASYNC_MSC_LOGGER_ACTIVATE
		#define ET_MSC_LOGGER_ASYNC_OUT(sourceName, message, targetName) 			\
			etMSCLogger_asyncOut(sourceName, message, targetName);

		#define ET_MSC_LOGGER_ASYNC_IN(sourceName, message, targetName) 			\
			etMSCLogger_asyncIn(sourceName, message, targetName);
	#else
		#define ET_MSC_LOGGER_ASYNC_OUT(sourceName, message, targetName)
		#define ET_MSC_LOGGER_ASYNC_IN(sourceName, message, targetName)
	#endif


#else

/**
 * calls \ref etMSCLogger_open(const char*, const char*) with <code>tmp/log</code> as path
 * and <code>msc</code> as file name for the log. Then it calls \ref etMSCLogger_setObjectName(const char*)
 * with object.
 * \par
 * If \ref ET_MSC_LOGGER_ACTIVATE isn't defined this macro is void
 *
 * \param object the object name to be set
 */
#define ET_MSC_LOGGER_OPEN(object)

/**
 * calls \ref etMSCLogger_close()
 * \par
 * If \ref ET_MSC_LOGGER_ACTIVATE isn't defined this macro is void
 */
#define ET_MSC_LOGGER_CLOSE

/**
 * this macro has to be used together with \ref ET_MSC_LOGGER_SYNC_EXIT to log
 * method entry and exit. It declares local variables and calls \ref etMSCLogger_syncCall
 * \par
 * If \ref ET_MSC_LOGGER_ACTIVATE or \ref ET_SYNC_MSC_LOGGER_ACTIVATE
 * aren't defined this macro is void
 */
#define ET_MSC_LOGGER_SYNC_ENTRY(object, message)
/**
 * this macro has to be used together with \ref ET_MSC_LOGGER_SYNC_ENTRY to log
 * method entry and exit. It uses local variables defined before by \ref ET_MSC_LOGGER_SYNC_ENTRY and
 * calls \ref etMSCLogger_syncCall
 * \par
 * If \ref ET_MSC_LOGGER_ACTIVATE or \ref ET_SYNC_MSC_LOGGER_ACTIVATE
 * aren't defined this macro is void
 */
#define ET_MSC_LOGGER_SYNC_EXIT

/**
 * calls \ref etMSCLogger_asyncOut(const char*, const char*, const char*)
 * \par
 * If \ref ET_MSC_LOGGER_ACTIVATE or \ref ET_ASYNC_MSC_LOGGER_ACTIVATE
 * aren't defined this macro is void
 */
#define ET_MSC_LOGGER_ASYNC_OUT(sourceName, message, targetName)

/**
 * calls \ref etMSCLogger_asyncIn(const char*, const char*, const char*)
 * \par
 * If \ref ET_MSC_LOGGER_ACTIVATE or \ref ET_ASYNC_MSC_LOGGER_ACTIVATE
 * aren't defined this macro is void
 */
#define ET_MSC_LOGGER_ASYNC_IN(sourceName, message, targetName)

/**
 * calls \ref etMSCLogger_setState(const char*, const char*)
 * \par
 * If \ref ET_MSC_LOGGER_ACTIVATE isn't defined this macro is void
 */
#define ET_MSC_LOGGER_CHANGE_STATE(objectName, stateName)
#endif


#endif /* _ETMSCLOGGER_H_ */

Back to the top