WSF
WsfXIO_Packet.hpp
Go to the documentation of this file.
1// ****************************************************************************
2// CUI
3//
4// The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
5//
6// Copyright 2003-2015 The Boeing Company. All rights reserved.
7//
8// The use, dissemination or disclosure of data in this file is subject to
9// limitation or restriction. See accompanying README and LICENSE for details.
10// ****************************************************************************
11
12#ifndef WSFXIO_PACKET_HPP
13#define WSFXIO_PACKET_HPP
14
15#include "wsf_export.h"
16
17#include "GenUniqueId.hpp"
18#include "PakPacket.hpp"
20
21// Libraries and applications registering new packets should reserve a range of IDs here.
22// Other libraries should be written to handle a change in the packet ID range.
23
24// Packets that support the unextended WSF
25static const int cXIO_WSF_LAST_PACKET_ID = 74;
26// Packets to support the standard extension to WSF.
29// Packets assigned to application 1
30static const int cXIO_APP_1_FIRST_PACKET_ID = 100;
31static const int cXIO_APP_1_LAST_PACKET_ID = 114;
32// 115-199 unused
33// Packets assigned to application 2
34static const int cXIO_APP_2_FIRST_PACKET_ID = 200;
35static const int cXIO_APP_2_LAST_PACKET_ID = 349;
36// 350+ unused
37
39static const int cXIO_WSF_LAST_TYPE_ID = 10;
40static const int cXIO_WSF_SIM_LAST_TYPE_ID = 20;
41static const int cXIO_WSF_EXTENDED_FIRST_TYPE_ID = 21;
42static const int cXIO_WSF_EXTENDED_LAST_TYPE_ID = 30;
43
45class WSF_EXPORT WsfXIO_Packet : public PakPacket
46{
47public:
48 typedef bool BaseType;
49 static const int cPACKET_ID = -1;
50
52 {
55 };
56
57 WsfXIO_Packet(int aPacketId)
58 : PakPacket(aPacketId)
59 , mFlags(0)
60 {
61 }
62
64 template<typename T>
65 void Serialize(T& aBuff)
66 {
68 }
69
70 float GetTimeStamp() const { return mTimeStamp; }
71 void SetTimeStamp(float aTimeStamp) { mTimeStamp = aTimeStamp; }
72
73 void SetFlags(uint32_t aFlags) { mFlags = aFlags; }
74 void AddFlags(uint32_t aFlags) { mFlags = mFlags | aFlags; }
75 uint32_t GetFlags() const { return mFlags; }
76
77 GenUniqueId mApplicationId;
78
79protected:
80 uint32_t mFlags;
82};
83
85
86#define XIO_DEFINE_PACKET_CTOR(PACKET_NAME__, BASE_TYPE__, PACKET_ID__) \
87 typedef BASE_TYPE__ BaseType; \
88 static const int cPACKET_ID = PACKET_ID__; \
89 PACKET_NAME__(int aPacketId = cPACKET_ID) \
90 : BASE_TYPE__(aPacketId)
91
92#define XIO_DEFINE_PACKET_SERIALIZE() \
93 template<typename T> \
94 void Serialize(T& aBuff) \
95 { \
96 BaseType::Serialize(aBuff); \
97 DoSerialize(aBuff); \
98 } \
99 template<typename T> \
100 void DoSerialize(T& aBuff)
101
102// Macro to implement some boiler plate code for WsfXIO_Packet types, including:
103// defining the packet ID and serializing the base class
104// PACKET_NAME__ - Name of the packet class
105// BASE_TYPE__ - Name of the base class
106// PACKET_ID__ - Unique ID of the packet
107#define XIO_DEFINE_PACKET(PACKET_NAME__, BASE_TYPE__, PACKET_ID__) \
108 XIO_DEFINE_PACKET_CTOR(PACKET_NAME__, BASE_TYPE__, PACKET_ID__) {} \
109 XIO_DEFINE_PACKET_SERIALIZE()
110
112
113#endif
#define WSF_EXPORT
Definition WsfXIO_Export.hpp:35
static const int cXIO_WSF_LAST_PACKET_ID
Definition WsfXIO_Packet.hpp:25
static const int cXIO_WSF_EXTENDED_FIRST_PACKET_ID
Definition WsfXIO_Packet.hpp:27
static const int cXIO_WSF_EXTENDED_LAST_PACKET_ID
Definition WsfXIO_Packet.hpp:28
static const int cXIO_WSF_EXTENDED_LAST_TYPE_ID
Definition WsfXIO_Packet.hpp:42
static const int cXIO_APP_1_LAST_PACKET_ID
Definition WsfXIO_Packet.hpp:31
static const int cXIO_WSF_SIM_LAST_TYPE_ID
Definition WsfXIO_Packet.hpp:40
static const int cXIO_APP_1_FIRST_PACKET_ID
Definition WsfXIO_Packet.hpp:30
static const int cXIO_WSF_EXTENDED_FIRST_TYPE_ID
Definition WsfXIO_Packet.hpp:41
static const int cXIO_WSF_LAST_TYPE_ID
Class type registry for polymorphic serialization.
Definition WsfXIO_Packet.hpp:39
static const int cXIO_APP_2_FIRST_PACKET_ID
Definition WsfXIO_Packet.hpp:34
static const int cXIO_APP_2_LAST_PACKET_ID
Definition WsfXIO_Packet.hpp:35
GenUniqueId mApplicationId
Definition WsfXIO_Packet.hpp:77
float GetTimeStamp() const
Definition WsfXIO_Packet.hpp:70
void Serialize(T &aBuff)
Serializes the packet header. Must be called first from derived class Serialize().
Definition WsfXIO_Packet.hpp:65
PacketFlags
Definition WsfXIO_Packet.hpp:52
@ cSYNCHRONIZED
Indicates the packet should be synchronized if possible.
Definition WsfXIO_Packet.hpp:54
static const int cPACKET_ID
Definition WsfXIO_Packet.hpp:49
WsfXIO_Packet(int aPacketId)
Definition WsfXIO_Packet.hpp:57
bool BaseType
Definition WsfXIO_Packet.hpp:48
void AddFlags(uint32_t aFlags)
Definition WsfXIO_Packet.hpp:74
uint32_t mFlags
Definition WsfXIO_Packet.hpp:80
void SetTimeStamp(float aTimeStamp)
Definition WsfXIO_Packet.hpp:71
void SetFlags(uint32_t aFlags)
Definition WsfXIO_Packet.hpp:73
float mTimeStamp
Definition WsfXIO_Packet.hpp:81
uint32_t GetFlags() const
Definition WsfXIO_Packet.hpp:75
Copyrights Multiple, All Rights Reserved