The Sparta Modeling Framework
Loading...
Searching...
No Matches
TreeNode.hpp File Reference

Basic Node framework in sparta device tree composite pattern. More...

#include <cstddef>
#include <cstdint>
#include <iostream>
#include <fstream>
#include <string>
#include <ostream>
#include <vector>
#include <sstream>
#include <set>
#include <map>
#include <unordered_map>
#include <regex>
#include <functional>
#include <memory>
#include <type_traits>
#include <typeinfo>
#include <utility>
#include "sparta/utils/StaticInit.hpp"
#include "sparta/simulation/ResourceContainer.hpp"
#include "sparta/functional/ArchDataContainer.hpp"
#include "sparta/utils/Utils.hpp"
#include "sparta/utils/SpartaException.hpp"
#include "sparta/utils/SpartaAssert.hpp"
#include "sparta/utils/Printing.hpp"
#include "sparta/utils/StringManager.hpp"
#include "sparta/kernel/PhasedObject.hpp"

Go to the source code of this file.

Classes

class  sparta::TreeNode
 Node in a composite tree representing a sparta Tree item. More...
 
struct  sparta::TreeNode::ANY_TYPE
 Type for indicating that ANY notification source type should be included in a search performed by locateNotificationSources. More...
 
class  sparta::TreeNode::ExtensionsBase
 Base class used to extend TreeNode parameter sets. More...
 
class  sparta::TreeNode::delegate
 Temporary delegate for notificaiton invokation until the implementation is working. This will then be merged with sparta::SpartaHandler. More...
 
class  sparta::TreeNode::type_info_container
 Container for std::type_info. More...
 
struct  sparta::TreeNode::NotificationInfo
 Notification type/name information. More...
 

Namespaces

namespace  sparta
 Macros for handling exponential backoff.
 
namespace  sparta::app
 Sparta Application framework.
 

Macros

#define ALPHANUM_CHARS    "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890_"
 Enables tracing of TreeNode lifetimes in a set of output txt files.
 
#define DIGIT_CHARS   "0123456789"
 Digit characters (for valid TreeNode groups)
 
#define RESERVED_WORDS
 Reserved words in Python language, Python builtins, and other reservations. TreeNode names and groups are note allowed to exactly match any of these (case sensitive)
 
#define REGISTER_FOR_NOTIFICATION(func, datat, name)
 Convenience macro for registering for a notification on a TreeNode.
 
#define DEREGISTER_FOR_NOTIFICATION(func, datat, name)
 Convenience macro for deregistering for a notification on a TreeNode.
 
#define NOTIFY(func, datat, name)   \
 

Typedefs

typedef std::vector< std::unique_ptr< ExtensionDescriptor > > sparta::ExtensionDescriptorVec
 

Functions

template<class Ch , class Tr >
std::basic_ostream< Ch, Tr > & sparta::operator<< (std::basic_ostream< Ch, Tr > &out, sparta::TreeNode const &tn)
 TreeNode stream operator.
 
std::ostream & sparta::operator<< (std::ostream &out, sparta::TreeNode const *tn)
 TreeNode stream operator.
 

Detailed Description

Basic Node framework in sparta device tree composite pattern.

Definition in file TreeNode.hpp.

Macro Definition Documentation

◆ ALPHANUM_CHARS

#define ALPHANUM_CHARS    "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890_"

Enables tracing of TreeNode lifetimes in a set of output txt files.

This can be used along with the tools/check_treenode_dtors.py script. Generates construction.txt and destruction.txt files. Delete these files before running the simulator again since they are always appended to and never overwritten

Alphanumeric characters (valid for TreeNode names and groups)

Definition at line 57 of file TreeNode.hpp.

◆ DEREGISTER_FOR_NOTIFICATION

#define DEREGISTER_FOR_NOTIFICATION (   func,
  datat,
  name 
)
Value:
deregisterForNotification<datat, \
typename std::remove_reference<decltype(*this)>::type, \
&std::remove_reference<decltype(*this)>::type::func>(this, name);

Convenience macro for deregistering for a notification on a TreeNode.

See also
REGISTER_FOR_NOTIFICATION

Definition at line 158 of file TreeNode.hpp.

◆ DIGIT_CHARS

#define DIGIT_CHARS   "0123456789"

Digit characters (for valid TreeNode groups)

Definition at line 61 of file TreeNode.hpp.

◆ NOTIFY

#define NOTIFY (   func,
  datat,
  name 
)    \

Definition at line 163 of file TreeNode.hpp.

◆ REGISTER_FOR_NOTIFICATION

#define REGISTER_FOR_NOTIFICATION (   func,
  datat,
  name 
)
Value:
registerForNotification<datat, \
typename std::remove_reference<decltype(*this)>::type, \
&std::remove_reference<decltype(*this)>::type::func>(this, name);

Convenience macro for registering for a notification on a TreeNode.

Parameters
funcName of class member function that will be called when the specified notification is posted. This function must have one of the following signatures:
  1. ClassName::func( // TreeNode from which the notification originated
    const TreeNode& origin_node,
    // TreeNode at which the notifications was observed,
    // causing this callback
    const TreeNode& observation_node,
    // Notification event data
    const datat& data );
  2. ClassName::func( // Notification event data
    const datat& data );
datattype of notification data for which this notification will register. See sparta::TreeNode::registerForNotification for information on how these types can be found in the tree.
nameName of the notification to register for. If "", will receive all notifications from the subtree matching datat. See sparta::TreeNode::registerForNotification for more details about the name parameter.
Exceptions
SpartaExceptionif a registration is made on a datat/name combination that cannot be posted by this the node's subtree (since there are no ancestor NotificationSource nodes matching datat/name).
Note
Deregister with DEREGISTER_FOR_NOTIFICATION. Failing to do so may cause errors.

This macro must be used within the class instance for which the callback function is being registered. This macro uses the this pointer to determine the observer class.

This macro resolves to a function call to "registerForNotification" which is should be used in a context such that it refers to sparta::TreeNode::registerForNotification.

Example

MyClass::setup() {
node->REGISTER_FOR_NOTIFICATION(handle_int1, int, "int_happened");
node->REGISTER_FOR_NOTIFICATION(handle_int2, int, "int_happened");
}
MyClass::destroy() {
node->DEREGISTER_FOR_NOTIFICATION(handle_int1, int, "int_happened");
node->DEREGISTER_FOR_NOTIFICATION(handle_int2, int, "int_happened");
}
MyClass::handle_int1(const TreeNode& origin,
const TreeNode& observation_node,
const int& data) {
(void) origin;
(void) observation_node;
(void) data;
// ...
}
MyClass::handle_int2(const int& data) {
(void) data;
// ...
}

Definition at line 148 of file TreeNode.hpp.

◆ RESERVED_WORDS

#define RESERVED_WORDS
Value:
{"and", "del", "from", "not", \
"while", "as", "elif", "global", \
"or", "with", "assert", "else", \
"if", "pass", "yield", "break", \
"except", "import", "print", "class", \
"exec", "in", "raise", "continue", \
"finally", "is", "return", "def", \
"for", "lambda", "try", "__init__", \
"__del__", "__cinit__", "__dealloc__", \
/* End of Python reserved names */ \
"name", "author", "report", "content", \
"include", \
/* End of SPARTA Report definition reserved nodes */ \
"extension" \
/* End of SPARTA extensions reserved words */ \
}

Reserved words in Python language, Python builtins, and other reservations. TreeNode names and groups are note allowed to exactly match any of these (case sensitive)

Definition at line 68 of file TreeNode.hpp.