gwnavruntime/visualdebug/messages/messageblob.h Source File

messageblob.h
Go to the documentation of this file.
1 /*
2 * Copyright 2015 Autodesk, Inc. All rights reserved.
3 * Use of this software is subject to the terms of the Autodesk license agreement and any attachments or Appendices thereto provided at the time of installation or download,
4 * or which otherwise accompanies this software in either electronic or hard copy form, or which is signed by you and accepted by Autodesk.
5 */
6 
7 
8 // primary contact: BRGR - secondary contact: NOBODY
9 #ifndef Navigation_MessageBlob_H
10 #define Navigation_MessageBlob_H
11 
19 
20 
21 namespace Kaim
22 {
23 
24 // Message that includes a blob field
25 class MessageBlob : public Net::AMP::Message
26 {
27 public:
28  static const char* GetTypeName() { return "MessageBlob"; }
29  static UInt32 GetLatestVersion() { return Net::AMP::Message::GetLatestVersion(); }
30 
31  MessageBlob() : Message()
32  , m_blobTypeId(0)
33  , m_shallowBlobSize(0)
34  , m_blobHandler(KY_NULL)
35  {
36  Version = GetLatestVersion();
37  }
38 
39  virtual ~MessageBlob() {}
40 
41  virtual void Read(File& str);
42  virtual void Write(File& str) const;
43 
44  virtual String ToString() const;
45 
46  virtual const char* GetMessageTypeName() const { return MessageBlob::GetTypeName(); }
47 
48  UInt32 GetBlobTypeId() const { return m_blobTypeId; }
49  UInt32 GetShallowBlobSize() const { return m_shallowBlobSize; }
50  UInt32 GetDeepBlobSize() const { return (m_blobHandler ? m_blobHandler->GetDeepBlobSize() : (UInt32)m_blob.Data.GetSize()); }
51  const void* GetBlob() const { return (m_blobHandler ? m_blobHandler->GetMutableBlob() : m_blob.Data.GetDataPtr()); }
52 
53  void Init(KyUInt32 blobtypeId, KyUInt32 shallowBlobSize, KyUInt32 deepBlobSize, char* blob);
54  void Init(Ptr<BaseBlobHandler> blobHandler);
55 
56 protected:
57  void SwapBlobEndianness(Endianness::Target target) const; // not really const since it modifies m_blob.Data
58 
59  UInt32 m_blobTypeId;
60  UInt32 m_shallowBlobSize;
61 
62  // m_blobHandler or m_blob are used when sending
63  // m_blob is always the one used at reception
64  Ptr<BaseBlobHandler> m_blobHandler;
65  mutable Net::AMP::RawData m_blob; // mutable so that endianness of m_blob.Data can be swapped in Write, in the socket thread.
66 };
67 
68 
69 // Message that includes a buffer that contains several blobs
70 class MessageAggregatedBlob : public Net::AMP::Message
71 {
72 public:
73  static const char* GetTypeName() { return "MessageAggregatedBlob"; }
74  static UInt32 GetLatestVersion() { return Net::AMP::Message::GetLatestVersion(); }
75 
76  MessageAggregatedBlob() : Message()
77  , m_currentIndex(0)
78  {
79  Version = GetLatestVersion();
80  }
81 
82  virtual ~MessageAggregatedBlob() {}
83 
84  virtual void Read(File& str);
85  virtual void Write(File& str) const;
86 
87  virtual String ToString() const;
88 
89  virtual const char* GetMessageTypeName() const { return MessageAggregatedBlob::GetTypeName(); }
90 
91  bool GoFirst();
92  bool GoNext();
93 
94  KyUInt32 GetCurrentBlobTypeId();
95  KyUInt32 GetCurrentShallowBlobSize();
96  KyUInt32 GetCurrentDeepBlobSize();
97  const void* GetCurrentBlob();
98 
99 
100  void Init(KyUInt32 bufferSize);
101  KyResult Add(KyUInt32 blobTypeId, KyUInt32 shallowBlobSize, KyUInt32 deepBlobSize, char* blob);
102  KyResult Add(Ptr<BaseBlobHandler> blobHandler)
103  { return Add(blobHandler->GetBlobTypeId(), blobHandler->GetShallowBlobSize(), blobHandler->GetDeepBlobSize(), (char*)blobHandler->GetMutableBlob()); }
104 
105  UInt32 GetAggregateSize() { return (UInt32) m_data.Data.GetSize(); }
106 
107 protected:
108  void SwapBlobEndianness(Endianness::Target target, void* blob, KyUInt32 blobTypeId) const; // not really const since it modifies m_blob.Data
109  mutable Net::AMP::RawData m_data; // mutable so that endianness of can be swapped in Write, in the socket thread.
110 
111  UInt32 m_currentIndex;
112 };
113 
114 
115 } // namespace Kaim
116 
117 #endif // Navigation_MessageBlob_H
KyInt32 KyResult
Defines a type that can be returned by methods or functions in the Gameware Navigation SDK to indicat...
Definition: types.h:254
#define KY_NULL
Null value.
Definition: types.h:247
Target
Enumerates the possible endianness types relative to the current platform.
Definition: endianness.h:35
Definition: gamekitcrowddispersion.h:20
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36