The Sparta Modeling Framework
Loading...
Searching...
No Matches
AgedArrayCollector.hpp
1// <ArrayCollector.hpp> -*- C++ -*-
2
7#pragma once
8
9#include <inttypes.h>
10
11#include "sparta/resources/VectorResourceCollectable.hpp"
12
13namespace sparta
14{
15namespace collection
16{
17
26 template <class ArrayType>
27 class AgedArrayCollector : public VectorResourceCollectable<ArrayType>
28 {
29 using VectorResourceCollectable<ArrayType>::collected_resource_;
30 using VectorResourceCollectable<ArrayType>::collectors_;
31 using VectorResourceCollectable<ArrayType>::closeRecord;
32
33 public:
41 VectorResourceCollectable<ArrayType>(parent, array,
42 array->getName() + "_age_ordered",
43 array->getName() + " Age-Ordered")
44 {}
45
50 void collect() override final
51 {
52 // We need to step through the array and validate all valid positions.
53 const typename ArrayType::AgedList & aged_list =
54 collected_resource_->getInternalAgedList_();
55 uint32_t collector_idx = aged_list.size() - 1;
56 for(const auto & obj : aged_list)
57 {
58 collectors_[collector_idx]->collect(collected_resource_->read(obj));
59 --collector_idx;
60 }
61
62 for(uint32_t i = aged_list.size(); i < collected_resource_->capacity(); ++i) {
63 collectors_[i]->closeRecord();
64 }
65
66 }
67 };
68}//namespace collection
69}//namespace sparta
70
71
Node in a composite tree representing a sparta Tree item.
Definition TreeNode.hpp:205
An AgedArrayCollector is created by the Array class in sparta when Pipeline collection is required.
void collect() override final
set up the Collector with the current state of the Array, and begin collection going forward.
AgedArrayCollector(sparta::TreeNode *parent, const ArrayType *array)
Construct an AgedArrayCollector.
Macros for handling exponential backoff.
ArrayType
Defines how a sparta::Array should behave. The array will have different features depending on the ty...
Definition Array.hpp:27