WSF
WsfTrackId.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 WSFTRACKID_HPP
13#define WSFTRACKID_HPP
14
15#include "wsf_export.h"
16
17#include <cstddef>
18#include <iosfwd>
19#include <memory>
20#include <string>
21
22#include "UtScriptAccessible.hpp"
23class UtScriptClass;
24class UtScriptTypes;
25#include "WsfStringId.hpp"
26
32class WSF_EXPORT WsfTrackId : public UtScriptAccessible
33{
34public:
36 : mOwningPlatformId()
37 , mLocalTrackNumber(0)
38 {
39 }
40
41 WsfTrackId(WsfStringId aOwningPlatformId, int aLocalTrackNumber)
42 : mOwningPlatformId(aOwningPlatformId)
43 , mLocalTrackNumber(aLocalTrackNumber)
44 {
45 }
46
47 static std::unique_ptr<UtScriptClass> CreateScriptClass(const std::string& aClassName, UtScriptTypes* aScriptTypesPtr);
48
49 const char* GetScriptClassName() const override { return "WsfTrackId"; }
50
54 bool operator==(const WsfTrackId& aRhs) const
55 {
56 return ((mOwningPlatformId == aRhs.mOwningPlatformId) && (mLocalTrackNumber == aRhs.mLocalTrackNumber));
57 }
58
62 bool operator!=(const WsfTrackId& aRhs) const { return (!operator==(aRhs)); }
63
68 bool operator<(const WsfTrackId& aRhs) const
69 {
70 if (mOwningPlatformId < aRhs.mOwningPlatformId)
71 {
72 return true;
73 }
74 else if (mOwningPlatformId > aRhs.mOwningPlatformId)
75 {
76 return false;
77 }
78 return (mLocalTrackNumber < aRhs.mLocalTrackNumber);
79 }
80
82 WsfStringId GetOwningPlatformId() const { return mOwningPlatformId; }
83
85 void SetOwningPlatformId(WsfStringId aOwningPlatformId) { mOwningPlatformId = aOwningPlatformId; }
86
88 int GetLocalTrackNumber() const { return mLocalTrackNumber; }
89
91 void SetLocalTrackNumber(int aLocalTrackNumber) { mLocalTrackNumber = aLocalTrackNumber; }
92
94 bool IsNull() const { return mOwningPlatformId.IsNull(); }
95
98 int IncrementLocalTrackNumber() { return ++mLocalTrackNumber; }
99
101 void Null()
102 {
103 mOwningPlatformId = nullptr;
104 mLocalTrackNumber = 0;
105 }
106
107 friend WSF_EXPORT std::ostream& operator<<(std::ostream& aOut, const WsfTrackId& aTrackId);
108 friend WSF_EXPORT std::istream& operator>>(std::istream& aIn, WsfTrackId& aTrackId);
109
116
117
120#if defined(_WIN32) && _MSC_VER >= 1300
121 static const size_t bucket_size = 4;
122 static const size_t min_buckets = 8;
123#endif
124
126 size_t operator()(const WsfTrackId& aTrackId) const { return static_cast<size_t>(aTrackId.GetLocalTrackNumber()); }
127
129 bool operator()(const WsfTrackId& aLhs, const WsfTrackId& aRhs) const { return (aLhs < aRhs); }
131
133 template<typename T>
134 void Serialize(T& aBuff)
135 {
136 aBuff& mOwningPlatformId& mLocalTrackNumber;
137 }
138
139private:
140 WsfStringId mOwningPlatformId;
141 int32_t mLocalTrackNumber;
142};
143
144#endif
UtStringId WsfStringId
WsfStringId – the same thing as UtStringId.
Definition WsfStringId.hpp:23
std::ostream & operator<<(std::ostream &aStream, const WsfTSPI &aTSPI)
Stream out operator (typically, to a file); units are converted on output.
Definition WsfTSPI.cpp:92
std::istream & operator>>(std::istream &aStream, WsfTSPI &aTSPI)
Stream in operator (typically, from a file); units are converted on input.
Definition WsfTSPI.cpp:108
#define WSF_EXPORT
Definition WsfXIO_Export.hpp:35
Definition WsfTrackId.hpp:33
bool IsNull() const
Indicates whether the ID has been set to reference a platform.
Definition WsfTrackId.hpp:94
int GetLocalTrackNumber() const
Get the platform-relative local track number.
Definition WsfTrackId.hpp:88
void Null()
Invalidate the ID by zeroing out the owning platform and local track number.
Definition WsfTrackId.hpp:101
void SetLocalTrackNumber(int aLocalTrackNumber)
Set the platform-relative local track number.
Definition WsfTrackId.hpp:91
bool operator==(const WsfTrackId &aRhs) const
Definition WsfTrackId.hpp:54
void Serialize(T &aBuff)
For XIO (de)serialization.
Definition WsfTrackId.hpp:134
int IncrementLocalTrackNumber()
Definition WsfTrackId.hpp:98
bool operator()(const WsfTrackId &aLhs, const WsfTrackId &aRhs) const
Only Microsoft Developer Studio seems to require this.
Definition WsfTrackId.hpp:129
bool operator!=(const WsfTrackId &aRhs) const
Definition WsfTrackId.hpp:62
bool operator<(const WsfTrackId &aRhs) const
Definition WsfTrackId.hpp:68
void SetOwningPlatformId(WsfStringId aOwningPlatformId)
Set the owning platform ID (from WsfPlatform::GetNameId());.
Definition WsfTrackId.hpp:85
const char * GetScriptClassName() const override
Definition WsfTrackId.hpp:49
size_t operator()(const WsfTrackId &aTrackId) const
All implementations seem to require this.
Definition WsfTrackId.hpp:126
WsfStringId GetOwningPlatformId() const
Get the owning platform ID (from WsfPlatform::GetNameId());.
Definition WsfTrackId.hpp:82
WsfTrackId(WsfStringId aOwningPlatformId, int aLocalTrackNumber)
Definition WsfTrackId.hpp:41
WsfTrackId()
Definition WsfTrackId.hpp:35
Copyrights Multiple, All Rights Reserved