Skip to content
Snippets Groups Projects
Commit 525d7235 authored by scott snyder's avatar scott snyder Committed by Melissa Yexley
Browse files

AthContainersRoot: Update clear to work on AuxVectorData.

Update the clear method of IAuxTypeVectorFactory / AuxTypeRegistry to take
AuxVectorData instances rather than bare pointers.  Remove the clear static
method from AuxTypeVector.
Also alter clear to operate on a range, rather than a single element.

Refactoring to make possible dependencies between auxiliary variables,
as would be used to support packed links / jagged vectors.
parent e7fad846
2 merge requests!707402024-04-19: merge of 24.0 into main,!67647Online Event Displays to CA
......@@ -385,11 +385,15 @@ public:
/**
* @brief Clear an element within a vector (static method).
* @param dst Pointer to the start of the vector's data.
* @param dst_index Index of the element in the vector.
* @brief Clear a range of elements within a vector.
* @param auxid The aux data item being operated on.
* @param dst Container holding the element
* @param dst_index Index of the first element in the vector.
* @param n Number of elements to clear.
*/
virtual void clear (void* dst, size_t dst_index) const override;
virtual void clear (SG::auxid_t auxid,
AuxVectorData& dst, size_t dst_index,
size_t n) const override;
/**
......
......@@ -537,13 +537,17 @@ void RootAuxVectorFactory::swap (SG::auxid_t auxid,
/**
* @brief Clear an element within a vector (static method).
* @param dst Pointer to the start of the vector's data.
* @param dst_index Index of the element in the vector.
* @brief Clear a range of elements within a vector.
* @param auxid The aux data item being operated on.
* @param dst Container holding the element
* @param dst_index Index of the first element in the vector.
* @param n Number of elements to clear.
*/
void RootAuxVectorFactory::clear (void* dst, size_t dst_index) const
void RootAuxVectorFactory::clear (SG::auxid_t auxid,
AuxVectorData& dst, size_t dst_index,
size_t n) const
{
m_type.clear (dst, dst_index);
m_type.clearRange (dst.getDataArray (auxid), dst_index, n);
}
......
......@@ -283,18 +283,23 @@ void test3()
int* ptr = reinterpret_cast<int*> (vec->toPtr());
ptr[0] = 1;
ptr[1] = 2;
ptr[2] = 3;
ptr[3] = 4;
fac.copy (ptr, 5, ptr, 1);
assert (ptr[1] == 2);
assert (ptr[5] == 2);
fac.clear (ptr, 1);
assert (ptr[1] == 0);
AuxVectorData_test avd1;
AuxStoreInternal_test store1;
avd1.setStore (&store1);
store1.addVector (std::move(vec), false);
fac.clear (1, avd1, 1, 2);
assert (ptr[0] == 1);
assert (ptr[1] == 0);
assert (ptr[2] == 0);
assert (ptr[3] == 4);
ptr[0] = 1;
ptr[1] = 2;
ptr[2] = 3;
......@@ -326,18 +331,23 @@ void test4()
std::string* ptr = reinterpret_cast<std::string*> (vec->toPtr());
ptr[0] = "1";
ptr[1] = "2";
ptr[2] = "3";
ptr[3] = "4";
fac.copy (ptr, 5, ptr, 1);
assert (ptr[1] == "2");
assert (ptr[5] == "2");
fac.clear (ptr, 1);
assert (ptr[1] == "");
AuxVectorData_test avd1;
AuxStoreInternal_test store1;
avd1.setStore (&store1);
store1.addVector (std::move(vec), false);
fac.clear (1, avd1, 1, 2);
assert (ptr[0] == "1");
assert (ptr[1] == "");
assert (ptr[2] == "");
assert (ptr[3] == "4");
fac.swap (1, avd1, 0, avd1, 5, 1);
assert (ptr[0] == "2");
assert (ptr[5] == "1");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment