The Sparta Modeling Framework
|
Templated ResourceFactoryBase implementation which can be used to trivially define Resource Factories. More...
#include <ResourceFactory.hpp>
Public Types | |
typedef ResourceT | resource_type |
typedef ParamsT | params_type |
Public Member Functions | |
ResourceFactory (const ResourceFactory &rhp)=delete | |
ResourceFactory & | operator= (const ResourceFactory &rhp)=delete |
virtual std::string | getResourceType () const override |
Returns the resource type-name for this resource, demangled. | |
virtual std::string | getResourceTypeRaw () const override |
Returns the resource type-name for this resource as in the typeid. | |
virtual ParameterSet * | createParameters (TreeNode *node) override |
Creates a new set of parameters associated with the resource that can be created by this factory. | |
virtual void | deleteParameters (ParameterSet *params) override |
Deletes a ParameterSet created by the createParameters method of this ResourceFactory. | |
virtual void | createSubtree (sparta::ResourceTreeNode *n) override |
Optionally creates a subtree of TreeNodes for this TreeNode by attaching children to this node. These children may be regular TreeNode or ResourceTreeNodes. | |
virtual void | deleteSubtree (sparta::ResourceTreeNode *n) override |
Optionally deletes the TreeNodes created by createSubtee (if any). | |
virtual void | onBuilding (sparta::ResourceTreeNode *n) override |
Hook for additional building on ResourceTreeNode constructing. | |
virtual void | onConfiguring (sparta::ResourceTreeNode *n) override |
Hook for additional configuring on resource node configure. | |
Resource * | createResource (TreeNode *node, const ParameterSet *params) override |
Finally instantiates the resource with its set of Parameters. | |
void | deleteResource (Resource *res) override final |
Deletes a resource created by the createResource method of this ResourceFactory. | |
void | bindEarly (TreeNode *) override |
Allows contents to be bound together if desired. | |
void | bindLate (TreeNode *) override |
Allows contents to be bound together if desired. | |
Public Member Functions inherited from sparta::ResourceFactoryBase | |
virtual | ~ResourceFactoryBase () |
Destructor. | |
Templated ResourceFactoryBase implementation which can be used to trivially define Resource Factories.
ResourceT | Type of Resource that this factory will instantiate. This type must inherit from sparta::Resource and contain a constructor with the signature: (sparta::TreeNode*, const ParamsT*). |
ParamsT | ParameterSet class type that this factory will instantiate. This type must inherit from sparta::ParameterSet and provide a constructor with the signature: (sparta::TreeNode*) |
Creating a ResourceFactory a ResourceClass is done by instantiating this class with appropriate template arguments.
Example 1 - Explicit Parameter Set types
Example 2 - Implicit nested Parameter Set types
Definition at line 213 of file ResourceFactory.hpp.
typedef ParamsT sparta::ResourceFactory< ResourceT, ParamsT >::params_type |
Definition at line 218 of file ResourceFactory.hpp.
typedef ResourceT sparta::ResourceFactory< ResourceT, ParamsT >::resource_type |
Definition at line 217 of file ResourceFactory.hpp.
|
inline |
Definition at line 223 of file ResourceFactory.hpp.
|
inline |
Definition at line 230 of file ResourceFactory.hpp.
|
inlineoverridevirtual |
Allows contents to be bound together if desired.
Subclasses can use this to bind ports together if needed, which can also be done in Resource::bind* methods or at the Simulation level
This happens before the top-level simulator class has a chance to bind anything
Implements sparta::ResourceFactoryBase.
Definition at line 294 of file ResourceFactory.hpp.
|
inlineoverridevirtual |
Allows contents to be bound together if desired.
Subclasses can use this to bind ports together if needed, which can also be done in Resource::bind* methods or at the Simulation level
Implements sparta::ResourceFactoryBase.
Definition at line 296 of file ResourceFactory.hpp.
|
inlineoverridevirtual |
Creates a new set of parameters associated with the resource that can be created by this factory.
node | TreeNode which which the newly-created parameters will be permanently associated. |
Each ParameterSet created by this parameter set must contain identical parameters down to types and default values.
Implements sparta::ResourceFactoryBase.
Definition at line 240 of file ResourceFactory.hpp.
|
inlineoverridevirtual |
Finally instantiates the resource with its set of Parameters.
Params are cast to ParamsT*. This class would not compile if this cast were impossible.
Implements sparta::ResourceFactoryBase.
Definition at line 275 of file ResourceFactory.hpp.
|
inlineoverridevirtual |
Optionally creates a subtree of TreeNodes for this TreeNode by attaching children to this node. These children may be regular TreeNode or ResourceTreeNodes.
Because this occurs during the tree construction phase, adding child ResourceTreeNodes is valid
Implements sparta::ResourceFactoryBase.
Definition at line 251 of file ResourceFactory.hpp.
|
inlineoverridevirtual |
Deletes a ParameterSet created by the createParameters method of this ResourceFactory.
params | ParameterSet to deallocate |
Implements sparta::ResourceFactoryBase.
Definition at line 245 of file ResourceFactory.hpp.
|
inlinefinaloverridevirtual |
Deletes a resource created by the createResource method of this ResourceFactory.
res | Resource to deallocate. |
Implements sparta::ResourceFactoryBase.
Definition at line 289 of file ResourceFactory.hpp.
|
inlineoverridevirtual |
Optionally deletes the TreeNodes created by createSubtee (if any).
An implementation of ResourceFactoryBase should generally keep a vector of nodes that it allocated and delete them when this method is invoked.
Implements sparta::ResourceFactoryBase.
Definition at line 255 of file ResourceFactory.hpp.
|
inlineoverridevirtual |
Returns the resource type-name for this resource, demangled.
Implements sparta::ResourceFactoryBase.
Definition at line 232 of file ResourceFactory.hpp.
|
inlineoverridevirtual |
Returns the resource type-name for this resource as in the typeid.
Implements sparta::ResourceFactoryBase.
Definition at line 236 of file ResourceFactory.hpp.
|
inlineoverridevirtual |
Hook for additional building on ResourceTreeNode constructing.
Tap into hook for creating more resource nodes, subtrees, etc.
Implements sparta::ResourceFactoryBase.
Definition at line 260 of file ResourceFactory.hpp.
|
inlineoverridevirtual |
Hook for additional configuring on resource node configure.
Tap into hook to configure any resources.
Implements sparta::ResourceFactoryBase.
Definition at line 264 of file ResourceFactory.hpp.