Skip to content

Commit 5657d13

Browse files
committed
zerodefect PR #38: move semantics for AJAAncillaryList:
• added “BFT_AncListMoveSemantics” test case to ut_ajaanc, plus minor edits
1 parent a3ff3a0 commit 5657d13

3 files changed

Lines changed: 53 additions & 18 deletions

File tree

ajaanc/includes/ancillarylist.h

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,6 @@ class AJAExport AJAAncillaryList
176176
///@{
177177
AJAAncillaryList (); ///< @brief Instantiate and initialize with a default set of values.
178178
inline AJAAncillaryList (const AJAAncillaryList & inRHS) {*this = inRHS;} ///< @brief My copy constructor.
179-
#if defined(AJA_USE_CPLUSPLUS11)
180-
AJAAncillaryList (AJAAncillaryList && inRHS); ///< @brief Move-construct constructor.
181-
#endif
182179
virtual ~AJAAncillaryList (); ///< @brief My destructor.
183180

184181
/**
@@ -187,16 +184,24 @@ class AJAExport AJAAncillaryList
187184
@return A non-const reference to myself.
188185
**/
189186
virtual AJAAncillaryList & operator = (const AJAAncillaryList & inRHS);
190-
///@}
191187

192188
#if defined(AJA_USE_CPLUSPLUS11)
193189
/**
194-
@brief Move-assignment operator -- moves contents from the right-hand-side to my contents, replacing my contents, and resets the right-hand-side.
195-
@param[in] inRHS The list of packets to be move into me.
196-
@return An r-value reference to myself.
190+
@brief Move-assignment constructor -- moves contents from the right-hand-side to my contents,
191+
replacing my contents, and resets the right-hand-side.
192+
@param[in] inRHS The list of packets to move into me.
193+
@return A non-const reference to myself.
197194
**/
198-
virtual AJAAncillaryList & operator = (AJAAncillaryList && inRHS); ///< @brief Move-construct constructor.
199-
#endif
195+
AJAAncillaryList (AJAAncillaryList && inRHS) noexcept; // (New in SDK 17.5)
196+
/**
197+
@brief Move-assignment operator -- moves contents from the right-hand-side to my contents,
198+
replacing my contents, and resets the right-hand-side.
199+
@param[in] inRHS The list of packets to move into me.
200+
@return A non-const reference to myself.
201+
**/
202+
virtual AJAAncillaryList & operator = (AJAAncillaryList && inRHS); // (New in SDK 17.5)
203+
#endif // AJA_USE_CPLUSPLUS11
204+
///@}
200205

201206

202207
/**

ajaanc/src/ancillarylist.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -167,19 +167,19 @@ AJAAncillaryList::AJAAncillaryList ()
167167
}
168168

169169
#if defined(AJA_USE_CPLUSPLUS11)
170-
AJAAncillaryList::AJAAncillaryList(AJAAncillaryList && inRHS)
171-
: m_ancList(std::move(inRHS.m_ancList)),
172-
m_rcvMultiRTP(inRHS.m_rcvMultiRTP), // By default, handle receiving multiple RTP packets
173-
m_xmitMultiRTP(inRHS.m_xmitMultiRTP), // By default, transmit single RTP packet
174-
m_ignoreCS(inRHS.m_ignoreCS)
170+
AJAAncillaryList::AJAAncillaryList (AJAAncillaryList && inRHS) noexcept
171+
: m_ancList (std::move(inRHS.m_ancList)),
172+
m_rcvMultiRTP (inRHS.m_rcvMultiRTP), // By default, handle receiving multiple RTP packets
173+
m_xmitMultiRTP (inRHS.m_xmitMultiRTP), // By default, transmit single RTP packet
174+
m_ignoreCS (inRHS.m_ignoreCS)
175175
{
176-
// Reset RHS.
176+
// Reset RHS...
177177
inRHS.m_rcvMultiRTP = true;
178178
inRHS.m_xmitMultiRTP = false;
179179
inRHS.m_ignoreCS = false;
180-
// inRHS.m_ancList - already moved/reset.
180+
// inRHS.m_ancList - already moved/reset
181181
}
182-
#endif
182+
#endif // defined(AJA_USE_CPLUSPLUS11)
183183

184184

185185
AJAAncillaryList::~AJAAncillaryList ()
@@ -222,7 +222,7 @@ AJAAncillaryList & AJAAncillaryList::operator = (AJAAncillaryList && inRHS)
222222
}
223223
return *this;
224224
}
225-
#endif
225+
#endif // defined(AJA_USE_CPLUSPLUS11)
226226

227227
AJAAncillaryData * AJAAncillaryList::GetAncillaryDataAtIndex (const uint32_t inIndex) const
228228
{

ajaanc/test/main.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3452,6 +3452,36 @@ cout << "AnalogTest -- " << pkts << endl;
34523452
#endif // DISABLED FOR NOW
34533453

34543454

3455+
#if defined(AJA_USE_CPLUSPLUS11)
3456+
TEST_CASE("BFT_AncListMoveSemantics")
3457+
{
3458+
const string myPacketData ("This is a test packet to be used with the new move semantics added to AJAAncillaryList");
3459+
AJAAncillaryData pkt;
3460+
pkt.SetDID(0xAA); pkt.SetSID(0xBB);
3461+
pkt.SetPayloadData(reinterpret_cast<const uint8_t*>(myPacketData.c_str()), myPacketData.length());
3462+
AJAAncillaryList pktsC;
3463+
3464+
// Create "A" list of 1024 packets...
3465+
AJAAncillaryList pktsA;
3466+
while (pktsA.CountAncillaryData() < 1024)
3467+
pktsA.AddAncillaryData(pkt);
3468+
CHECK_EQ(pktsA.CountAncillaryData(), 1024);
3469+
CHECK_EQ(pktsC.CountAncillaryData(), 0);
3470+
3471+
// Move A's packets into new "B" list...
3472+
AJAAncillaryList pktsB(std::move(pktsA));
3473+
CHECK_EQ(pktsC.CountAncillaryData(), 0);
3474+
CHECK_EQ(pktsA.CountAncillaryData(), 0);
3475+
CHECK_EQ(pktsB.CountAncillaryData(), 1024);
3476+
3477+
// Move B's packets into "C"...
3478+
pktsC = std::move(pktsB);
3479+
CHECK_EQ(pktsB.CountAncillaryData(), 0);
3480+
CHECK_EQ(pktsC.CountAncillaryData(), 1024);
3481+
} // TEST_CASE("BFT_AncDataCompare")
3482+
#endif // defined(AJA_USE_CPLUSPLUS11)
3483+
3484+
34553485
// This explicitly tests AJAAncillaryData::GenerateTransmitData:
34563486
#if 0
34573487
static bool GenerateIPPacketWordsBFT (void)

0 commit comments

Comments
 (0)