The Sparta Modeling Framework
Loading...
Searching...
No Matches
CollectableTreeNode.hpp
Go to the documentation of this file.
1// <CollectableTreeNode> -*- C++ -*-
2
3
11#pragma once
12
13#include <string>
14#include <inttypes.h>
15
18
19namespace sparta{
20namespace collection
21{
22
30 {
31 public:
40 CollectableTreeNode(sparta::TreeNode* parent, const std::string& name,
41 const std::string& group, uint32_t index,
42 const std::string& desc = "CollectableTreeNode <no desc>") :
43 sparta::TreeNode(parent, name, group, index, desc)
44 {
45 markHidden(); // Mark self as hidden from the default
46 // printouts (to reduce clutter)
47 }
48
55 CollectableTreeNode(sparta::TreeNode* parent, const std::string& name,
56 const std::string& desc= "CollectableTreeNode <no desc>") :
59 {}
60
63 {}
64
74 void startCollecting(Collector * collector) {
75 is_collected_ = true;
76 setCollecting_(true, collector);
77 }
78
83 void stopCollecting(Collector * collector)
84 {
85 setCollecting_(false, collector);
86 is_collected_ = false;
87 }
88
93 bool isCollected() const { return is_collected_; }
94
97 virtual void collect() = 0;
98
103 virtual void restartRecord() {}
104
113 virtual void closeRecord(const bool & simulation_ending = false) { (void) simulation_ending; }
114
115 protected:
116
121 virtual void setCollecting_(bool collect, Collector *) { (void) collect; }
122
123 private:
124
129 bool is_collected_ = false;
130
131 };
132
133}
134}
Define a base Collector class.
Basic Node framework in sparta device tree composite pattern.
Node in a composite tree representing a sparta Tree item.
Definition TreeNode.hpp:205
static const group_idx_type GROUP_IDX_NONE
GroupIndex indicating that a node has no group index because it belongs to no group.
Definition TreeNode.hpp:303
void markHidden(bool hidden=true)
Marks this TreeNode hidden for the purposes of printint out nodes. This does not make the node inacce...
static constexpr char GROUP_NAME_NONE[]
Group name indicating that a node belongs to no group.
Definition TreeNode.hpp:314
An abstract type of TreeNode that has virtual calls to start collection on this node,...
virtual void closeRecord(const bool &simulation_ending=false)
CollectableTreeNode(sparta::TreeNode *parent, const std::string &name, const std::string &group, uint32_t index, const std::string &desc="CollectableTreeNode <no desc>")
Construct.
virtual ~CollectableTreeNode()
Virtual destructor.
virtual void setCollecting_(bool collect, Collector *)
Indicate to sub-classes that collection has flipped.
CollectableTreeNode(sparta::TreeNode *parent, const std::string &name, const std::string &desc="CollectableTreeNode <no desc>")
Construct.
void startCollecting(Collector *collector)
Method that tells this treenode that is now running collection.
bool isCollected() const
Determine whether or not this node has collection turned on or off.
void stopCollecting(Collector *collector)
Method that tells this treenode that is now not running collection.
A non-templated base class that all Collectors should inherit from.
Definition Collector.hpp:23
Macros for handling exponential backoff.