RootComponent Class Reference

Back to the index.

Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
RootComponent Class Reference

A Component which is the default root node in the configuration. More...

#include <RootComponent.h>

Inheritance diagram for RootComponent:
Component UnitTestable ReferenceCountable

Public Member Functions

 RootComponent (GXemul *owner=NULL)
 Constructs a RootComponent. More...
 
virtual RootComponentAsRootComponent ()
 Returns the component's RootComponent interface. More...
 
virtual bool PreRunCheckForComponent (GXemul *gxemul)
 Checks the state of this component, before starting execution. More...
 
GXemulGetOwner ()
 
void SetOwner (GXemul *owner)
 
- Public Member Functions inherited from Component
virtual ~Component ()
 
string GetClassName () const
 Gets the class name of the component. More...
 
string GetVisibleClassName () const
 Gets the visible class name of the component. More...
 
refcount_ptr< ComponentClone () const
 Clones the component and all its children. More...
 
const refcount_ptr< ComponentLightClone () const
 Makes a light clone of the component and all its children. More...
 
void DetectChanges (const refcount_ptr< Component > &oldClone, ostream &changeMessages) const
 Compare an older clone to the current tree, to find changes. More...
 
string GenerateTreeDump (const string &branchTemplate, bool htmlLinksForClassNames=false, string prefixForComponentUrls="") const
 Generates an ASCII tree dump of a component tree. More...
 
virtual string GenerateDetails () const
 Generate details about the component. More...
 
void Reset ()
 Resets the state of this component and all its children. More...
 
bool PreRunCheck (GXemul *gxemul)
 Checks the state of this component and all its children, before starting execution. More...
 
void FlushCachedState ()
 Resets the cached state of this component and all its children. More...
 
virtual int Execute (GXemul *gxemul, int nrOfCycles)
 Execute one or more cycles. More...
 
virtual double GetCurrentFrequency () const
 Returns the current frequency (in Hz) that the component runs at. More...
 
virtual CPUComponentAsCPUComponent ()
 Returns the component's CPUComponent interface. More...
 
virtual AddressDataBusAsAddressDataBus ()
 Returns the component's AddressDataBus interface, if any. More...
 
void SetParent (Component *parentComponent)
 Sets the parent component of this component. More...
 
ComponentGetParent ()
 Gets this component's parent component, if any. More...
 
const ComponentGetParent () const
 
virtual void GetMethodNames (vector< string > &names) const
 Retrieves a component's implemented method names. More...
 
virtual bool MethodMayBeReexecutedWithoutArgs (const string &methodName) const
 Returns whether a method name may be re-executed without args. More...
 
virtual void ExecuteMethod (GXemul *gxemul, const string &methodName, const vector< string > &arguments)
 Executes a method on the component. More...
 
string GeneratePath () const
 Generates a string representation of the path to the Component. More...
 
string GenerateShortestPossiblePath () const
 Generates a short string representation of the path to the Component. More...
 
const refcount_ptr< ComponentLookupPath (string path) const
 Looks up a path from this Component, and returns a pointer to the found Component, if any. More...
 
vector< string > FindPathByPartialMatch (const string &partialPath, bool shortestPossible=false) const
 Finds complete component paths, given a partial path. More...
 
void AddChild (refcount_ptr< Component > childComponent, size_t insertPosition=(size_t) -1)
 Adds a reference to a child component. More...
 
size_t RemoveChild (Component *childToRemove)
 Removes a reference to a child component. More...
 
ComponentsGetChildren ()
 Gets pointers to child components. More...
 
const ComponentsGetChildren () const
 Gets pointers to child components, as a const reference. More...
 
void GetVariableNames (vector< string > &names) const
 Retrieves a component's state variable names. More...
 
StateVariableGetVariable (const string &name)
 Gets a pointer to a state variable. More...
 
const StateVariableGetVariable (const string &name) const
 Gets a pointer to a state variable. More...
 
bool SetVariableValue (const string &name, const string &expression)
 Sets a variable to a new value. More...
 
void Serialize (ostream &ss, SerializationContext &context) const
 Serializes the Component into a string stream. More...
 
bool CheckConsistency () const
 Checks consistency by serializing and deserializing the component (including all its child components), and comparing the checksum of the original tree with the deserialized tree. More...
 
void AddChecksum (Checksum &checksum) const
 Adds this component's state, including children, to a checksum. More...
 
- Public Member Functions inherited from ReferenceCountable
 ReferenceCountable ()
 Default constructor, which initializes the reference count to zero. More...
 
 ~ReferenceCountable ()
 

Static Public Member Functions

static void RunUnitTests (int &nSucceeded, int &nFailures)
 
- Static Public Member Functions inherited from Component
static string GetAttribute (const string &attributeName)
 Creates a Component. More...
 
static refcount_ptr< ComponentDeserialize (ostream &messages, const string &str, size_t &pos)
 Deserializes a string into a component tree. More...
 
- Static Public Member Functions inherited from UnitTestable
static void RunUnitTests (int &nSucceeded, int &nFailures)
 Runs unit test cases. More...
 

Protected Member Functions

virtual bool CheckVariableWrite (StateVariable &var, const string &oldValue)
 Checks whether a write to a variable is OK. More...
 
- Protected Member Functions inherited from Component
 Component (const string &className, const string &visibleClassName)
 Base constructor for a Component. More...
 
template<class T >
bool AddVariable (const string &name, T *variablePointer)
 Adds a state variable of type T to the Component. More...
 
bool AddCustomVariable (const string &name, CustomStateVariableHandler *variableHandler)
 Adds a custom state variable to the Component. More...
 
virtual void ResetState ()
 Resets the state variables of this component. More...
 
virtual void FlushCachedStateForComponent ()
 Resets the cached state of this component. More...
 
GXemulGetRunningGXemulInstance ()
 Returns a reference to the current GXemul instance. More...
 
UIGetUI ()
 Gets an UI reference for outputting debug messages during runtime. More...
 

Detailed Description

A Component which is the default root node in the configuration.

This Component is mostly a dummy component, but it holds the 'step' count for the entire emulation (inherited from Component), and the following settings:

NOTE: A RootComponent is not registered in the component registry, and can thus not be created interactively by the user at runtime.

Definition at line 57 of file RootComponent.h.

Constructor & Destructor Documentation

◆ RootComponent()

RootComponent::RootComponent ( GXemul owner = NULL)

Constructs a RootComponent.

Definition at line 33 of file RootComponent.cc.

References Component::AddVariable(), and Component::SetVariableValue().

Referenced by CheckVariableWrite().

Member Function Documentation

◆ AsRootComponent()

virtual RootComponent* RootComponent::AsRootComponent ( )
inlinevirtual

Returns the component's RootComponent interface.

Returns
A pointer to the component as a RootComponent, or NULL if the component isn't a RootComponent.

Reimplemented from Component.

Definition at line 67 of file RootComponent.h.

References PreRunCheckForComponent().

◆ CheckVariableWrite()

bool RootComponent::CheckVariableWrite ( StateVariable var,
const string &  oldValue 
)
protectedvirtual

Checks whether a write to a variable is OK.

This function is called after the variable has been written. By returning false, the component indicates that the value which was written is invalid, and the write will be undone.

An implementation should first check variables defined for the implementation class, and then call its base class' function.

The implementation in the base Component class handles the variables that are defined for all components, and returns true for anything else.

Parameters
varThe variable to check.
oldValueThe serialized previous value.
Returns
true if the write was ok, false otherwise.

Reimplemented from Component.

Definition at line 61 of file RootComponent.cc.

References UnitTest::Assert(), Component::CheckVariableWrite(), ComponentFactory::CreateComponent(), StateVariable::GetName(), Component::GetUI(), Component::GetVariable(), refcount_ptr< T >::IsNULL(), Component::PreRunCheck(), RootComponent(), StateVariable::SetValue(), UI::ShowDebugMessage(), StateVariable::ToInteger(), StateVariable::ToString(), UNITTEST, and UNITTESTS.

Referenced by GetOwner().

◆ GetOwner()

GXemul* RootComponent::GetOwner ( )
inline

Definition at line 74 of file RootComponent.h.

References CheckVariableWrite(), RunUnitTests(), and SetOwner().

Referenced by Component::GetRunningGXemulInstance().

◆ PreRunCheckForComponent()

bool RootComponent::PreRunCheckForComponent ( GXemul gxemul)
virtual

Checks the state of this component, before starting execution.

Note 1: This function is not recursive, so children should not be traversed.

Note 2: After a component's state variables have been checked, the base class' PreRunCheckForComponent(GXemul*) function should also be called.

The implementation of this function may choose to print warning messages but still return true, or it can print error messages and return false.

Typical examples of pre-run-check failures are:

Returns
true if the component is ready to run, false otherwise.

Reimplemented from Component.

Definition at line 44 of file RootComponent.cc.

References GXemul::GetUI(), and UI::ShowDebugMessage().

Referenced by AsRootComponent().

◆ RunUnitTests()

static void RootComponent::RunUnitTests ( int &  nSucceeded,
int &  nFailures 
)
static

Referenced by GetOwner().

◆ SetOwner()

void RootComponent::SetOwner ( GXemul owner)

Definition at line 55 of file RootComponent.cc.

Referenced by GetOwner(), and GXemul::SetRootComponent().


The documentation for this class was generated from the following files:

Generated on Fri Dec 7 2018 19:52:23 for GXemul by doxygen 1.8.13