1 | /** |
---|
2 | * @file TrafficCaptureMessageFactory.h |
---|
3 | * This header file defines the TrafficCaptureMessageFactory. |
---|
4 | * @author Tomas Urban |
---|
5 | * @version 0.2 |
---|
6 | * @date 23/07/2009 |
---|
7 | */ |
---|
8 | #ifndef TRAFFIC_CAPTURE_MESSAGE_FACTORY_H |
---|
9 | #define TRAFFIC_CAPTURE_MESSAGE_FACTORY_H |
---|
10 | #include "TrafficCaptureMessage.h" |
---|
11 | #include "Helper/Singleton.h" |
---|
12 | |
---|
13 | /** |
---|
14 | * A singleton factory class for instantiating received data messages. |
---|
15 | */ |
---|
16 | class TrafficCaptureMessageFactory : public Singleton<TrafficCaptureMessageFactory> |
---|
17 | { |
---|
18 | private: |
---|
19 | friend class Singleton<TrafficCaptureMessageFactory>; |
---|
20 | TrafficCaptureMessageFactory(void); |
---|
21 | public: |
---|
22 | ~TrafficCaptureMessageFactory(void); |
---|
23 | /** |
---|
24 | * The factory method for creating message instances from data received via TCP/IP |
---|
25 | * connection. The objects returned by this method are allocated on the heap, so they |
---|
26 | * have to be disposed when they are not needed anymore by the \c delete operator or |
---|
27 | * calling the #DisposeMessage method. When creating the message instances, the |
---|
28 | * factory decodes the payload. Thus, the created object are fully initialized. |
---|
29 | * @param nId Message identification number |
---|
30 | * @param pPayload Buffer containing encoded payload data |
---|
31 | * @param nPayloadLength Lenght of the payload data |
---|
32 | * @return Created message instance or \c NULL if any error has ocurred (e.g. unknown |
---|
33 | * message code, decoding failure). |
---|
34 | */ |
---|
35 | TrafficCaptureMessage * CreateMessage(unsigned short nId, const char * pPayload, |
---|
36 | unsigned int nPayloadLength); |
---|
37 | /** |
---|
38 | * This method is used for disposing instances allocated by the #CreateMessage method. |
---|
39 | * @param pInstance Message instance to be disposed |
---|
40 | */ |
---|
41 | void DisposeMessage(TrafficCaptureMessage * pInstance); |
---|
42 | }; |
---|
43 | |
---|
44 | #endif |
---|