Component Class Reference

Back to the index.

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

A Component is a node in the configuration tree that makes up an emulation setup. More...

#include <Component.h>

Inheritance diagram for Component:
ReferenceCountable CacheComponent CPUComponent DummyComponent MachineComponent MainbusComponent MemoryMappedComponent RootComponent CPUDyntransComponent RAMComponent M88K_CPUComponent MIPS_CPUComponent

Public Member Functions

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 RootComponentAsRootComponent ()
 Returns the component's RootComponent interface. 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 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...
 

Protected Member Functions

 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 bool CheckVariableWrite (StateVariable &var, const string &oldValue)
 Checks whether a write to a variable is OK. More...
 
virtual void ResetState ()
 Resets the state variables of this component. More...
 
virtual bool PreRunCheckForComponent (GXemul *gxemul)
 Checks the state of this component, before starting execution. 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 is a node in the configuration tree that makes up an emulation setup.

The Component is the core concept in GXemul. All devices, CPUs, networks, and so on are components.

Definition at line 62 of file Component.h.

Constructor & Destructor Documentation

Component::Component ( const string &  className,
const string &  visibleClassName 
)
protected

Base constructor for a Component.

See also: the Create() function.

Parameters
classNameThe name of the component class. It should be a short, descriptive name. For e.g. a PCI bus class, it can be "pcibus". For a MIPS CPU, it can be "mips_cpu".
visibleClassNameThe visible name of the component class. It should be a short, descriptive name. For e.g. a PCI bus class, it can be "pcibus". For a MIPS CPU, it can be "cpu".

Definition at line 42 of file Component.cc.

References AddVariable(), and Component().

Referenced by Component().

virtual Component::~Component ( )
inlinevirtual

Definition at line 83 of file Component.h.

Member Function Documentation

void Component::AddChecksum ( Checksum checksum) const

Adds this component's state, including children, to a checksum.

Parameters
checksumThe checksum to add to.

Definition at line 1253 of file Component.cc.

References Checksum::Add(), and Serialize().

Referenced by CheckConsistency().

void Component::AddChild ( refcount_ptr< Component childComponent,
size_t  insertPosition = (size_t) -1 
)

Adds a reference to a child component.

Parameters
childComponentA reference counted pointer to the child component to add.
insertPositionIf specified, this is the position in the vector of child components where the child will be inserted. If not specified (or -1), then the child will be added to the end of the vector.

Definition at line 595 of file Component.cc.

References GetParent(), GetVariable(), GetVisibleClassName(), SetParent(), SetVariableValue(), and StateVariable::ToString().

Referenced by Clone(), SGI_IP32_Machine::Create(), TestM88KMachine::Create(), TestMIPSMachine::Create(), SGI_IP30_Machine::Create(), MVME187Machine::Create(), Deserialize(), MoveComponentCommand::Execute(), AddComponentCommand::Execute(), and CopyComponentCommand::Execute().

bool Component::AddCustomVariable ( const string &  name,
CustomStateVariableHandler variableHandler 
)
inlineprotected

Adds a custom state variable to the Component.

This function is only meant to be called from the component's constructor.

Parameters
nameThe variable name.
variableHandlerA pointer to the handler that knows how to serialize/deserialize the variable.
Returns
True if the state variable was added, false if the name was already in use.

Definition at line 586 of file Component.h.

Referenced by RAMComponent::RAMComponent().

template<class T >
bool Component::AddVariable ( const string &  name,
T *  variablePointer 
)
inlineprotected

Adds a state variable of type T to the Component.

This function is only meant to be called from the component's constructor.

Parameters
nameThe variable name.
variablePointerA pointer to the variable that the name should be connected to.
Returns
True if the state variable was added, false if the name was already in use.

Definition at line 563 of file Component.h.

Referenced by CacheComponent::CacheComponent(), Component(), CPUComponent::CPUComponent(), M88K_CPUComponent::M88K_CPUComponent(), MemoryMappedComponent::MemoryMappedComponent(), MIPS_CPUComponent::MIPS_CPUComponent(), RAMComponent::RAMComponent(), and RootComponent::RootComponent().

AddressDataBus * Component::AsAddressDataBus ( )
virtual

Returns the component's AddressDataBus interface, if any.

Returns
A pointer to an AddressDataBus, or NULL if the component does not support that interface.

Reimplemented in RAMComponent, CacheComponent, CPUComponent, and MainbusComponent.

Definition at line 367 of file Component.cc.

Referenced by FileLoader::Load(), FileLoader_raw::LoadIntoComponent(), FileLoader_ELF::LoadIntoComponent(), and FileLoader_aout::LoadIntoComponent().

CPUComponent * Component::AsCPUComponent ( )
virtual

Returns the component's CPUComponent interface.

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

Reimplemented in CPUComponent.

Definition at line 360 of file Component.cc.

Referenced by FileLoader_aout::LoadIntoComponent(), and FileLoader_ELF::LoadIntoComponent().

RootComponent * Component::AsRootComponent ( )
virtual

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 in RootComponent.

Definition at line 353 of file Component.cc.

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

bool Component::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.

Returns
true if the serialization/deserialization was correct, false if there was some inconsistency

Definition at line 1226 of file Component.cc.

References AddChecksum(), Deserialize(), refcount_ptr< T >::IsNULL(), and Serialize().

bool Component::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 in M88K_CPUComponent, MIPS_CPUComponent, and RootComponent.

Definition at line 969 of file Component.cc.

References StateVariable::GetName(), GetParent(), GetRunningGXemulInstance(), GXemul::GetSnapshottingEnabled(), GetUI(), GXemul::ModifyStep(), StringHelper::ParseNumber(), UI::ShowDebugMessage(), and StateVariable::ToInteger().

Referenced by RootComponent::CheckVariableWrite(), MIPS_CPUComponent::CheckVariableWrite(), M88K_CPUComponent::CheckVariableWrite(), and SetVariableValue().

refcount_ptr< Component > Component::Clone ( ) const

Clones the component and all its children.

The new copy is a complete copy; modifying either the copy or the original will not affect the other.

Returns
A reference counted pointer to the clone.

Definition at line 76 of file Component.cc.

References AddChild(), Clone(), ComponentFactory::CreateComponent(), GetClassName(), and refcount_ptr< T >::IsNULL().

Referenced by Clone(), CopyComponentCommand::Execute(), and GXemul::ModifyStep().

refcount_ptr< Component > Component::Deserialize ( ostream &  messages,
const string &  str,
size_t &  pos 
)
static

Deserializes a string into a component tree.

Parameters
messagesA stream where errors/warnings may be reported.
strThe string to deserialize.
posInitial deserialization position in the string; should be 0 when invoked manually. (Used for recursion, to avoid copying.)
Returns
If deserialization was successful, the reference counted pointer will point to a component tree; on error, it will be set to NULL

Definition at line 1130 of file Component.cc.

References AddChild(), ComponentFactory::CreateComponent(), refcount_ptr< T >::IsNULL(), and SetVariableValue().

Referenced by CheckConsistency().

void Component::DetectChanges ( const refcount_ptr< Component > &  oldClone,
ostream &  changeMessages 
) const

Compare an older clone to the current tree, to find changes.

Any changes found are written as messages to changeMessages. Typical use of this function is to input a "light clone" which is taken before running a single execution step, to find out any side effects of that execution step.

Parameters
oldCloneThe original component tree to compare to.
changeMessagesAn output stream where to send messages.

Definition at line 198 of file Component.cc.

References GenerateShortestPossiblePath(), GetChildren(), GetClassName(), GetVariable(), and StateVariable::ToString().

Referenced by BackwardStepCommand::Execute(), and GXemul::Execute().

int Component::Execute ( GXemul gxemul,
int  nrOfCycles 
)
virtual

Execute one or more cycles.

Note 1: A component must attempt to execute exactly the number of specified cycles.

Note 2: If e.g. a breakpoint is reached, or some fatal error occurs (such as an unimplemented feature in the emulation of the component is triggered), then it is ok to return fewer than the requested number of cycles. Execution will then stop (or the breakpoint will be handled, etc).

Note 3: The framework will only call this function if the component has a StateVariable named "frequency". Components that do not have any frequency do not execute anything periodically by themselves.

Parameters
gxemulA pointer to the GXemul instance.
nrOfCyclesThe requested number of cycles to run.
Returns
The number of cycles actually executed.

Reimplemented in CPUDyntransComponent.

Definition at line 333 of file Component.cc.

void Component::ExecuteMethod ( GXemul gxemul,
const string &  methodName,
const vector< string > &  arguments 
)
virtual

Executes a method on the component.

Note 1: The method name must be one of those returned by GetMethodNames(vector<string>&), either in the class itself or by one of the base implementations.

Note 2: The base class' member function should only be called if this class does not handle the method.

Parameters
gxemulA reference to the GXemul instance.
methodNameThe name of the method.
argumentsA vector of arguments to the method.

Reimplemented in RAMComponent, CacheComponent, and CPUComponent.

Definition at line 406 of file Component.cc.

Referenced by CPUComponent::ExecuteMethod(), CacheComponent::ExecuteMethod(), and RAMComponent::ExecuteMethod().

vector< string > Component::FindPathByPartialMatch ( const string &  partialPath,
bool  shortestPossible = false 
) const

Finds complete component paths, given a partial path.

E.g. if the following components are available:

     root.machine0.isabus0
     root.machine1.pcibus0
     root.machine1.pcibus1
     root.machine2.pcibus0
     root.machine3.otherpci

then a search for "pci" would return

     root.machine1.pcibus0
     root.machine1.pcibus1
     root.machine2.pcibus0

(note: not otherpci)

A search for machine1 would return

     root.machine1

Multiple words separated by "." should also be possible, so "machine2.pcibus" will find "root.machine2.pcibus0", but "machine.pcibus" will not match anything.

Searching for an empty string ("") returns a vector of all component paths.

Parameters
partialPathThe partial path to complete.
shortestPossibleReturn shortest possible paths, instead of full paths.
Returns
A vector of possible complete paths.

Definition at line 912 of file Component.cc.

References GenerateShortestPossiblePath(), GetParent(), and LookupPath().

void Component::FlushCachedState ( )

Resets the cached state of this component and all its children.

For performance reasons, while an emulation is running, it is usually a good idea to cache e.g. pointers to various things. However, after pausing an emulation, and continuing again, these pointers may not be valid. FlushCachedState() should be called before Run() is called.

Definition at line 317 of file Component.cc.

References FlushCachedStateForComponent().

Referenced by ConsoleUI::MainLoop().

void Component::FlushCachedStateForComponent ( )
protectedvirtual

Resets the cached state of this component.

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

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

The implementation of this function ususally takes the form of setting a number of pointers to NULL, and then the call to the base class' FlushCachedStateForComponent() function.

Reimplemented in CPUComponent, and MainbusComponent.

Definition at line 327 of file Component.cc.

Referenced by FlushCachedState(), MainbusComponent::FlushCachedStateForComponent(), and CPUComponent::FlushCachedStateForComponent().

string Component::GenerateDetails ( ) const
virtual

Generate details about the component.

Returns
A string containing details about the component.

Reimplemented in CacheComponent, and MemoryMappedComponent.

Definition at line 417 of file Component.cc.

References GetCurrentFrequency(), GetVariable(), StateVariable::ToInteger(), and StateVariable::ToString().

Referenced by MemoryMappedComponent::GenerateDetails(), CacheComponent::GenerateDetails(), and GenerateTreeDump().

string Component::GeneratePath ( ) const

Generates a string representation of the path to the Component.

The path consists of "name.name...name.name" where the last name is the name of this component, and the preceding names are names of parents.

If a component does not have a "name" state variable, then the class name in parentheses is used instead (which may make the path non-unique).

Returns
A path to the component, as a string.

Definition at line 686 of file Component.cc.

References GeneratePath(), GetClassName(), GetVariable(), and StateVariable::ToString().

Referenced by GeneratePath(), and GenerateShortestPossiblePath().

string Component::GenerateShortestPossiblePath ( ) const

Generates a short string representation of the path to the Component.

This function generates a string which is the shortest possible sub-path required to uniqely identify a component in the tree. (Actually, not really the shortest. For example if a component is called root.machine0.mainbus0.ram0, then the shortest string may be "ra". This function will return "ram0".)

If there are components a.b.x, a.b.y, and a.c.x, then the shortest possible paths for the three components are "b.x", "y", and "c.x" respectively.

Returns
A string which is part of the path of the component.

Definition at line 721 of file Component.cc.

References GeneratePath(), and GetParent().

Referenced by DetectChanges(), FindPathByPartialMatch(), FileLoader::Load(), and ConsoleUI::ShowDebugMessage().

string Component::GenerateTreeDump ( const string &  branchTemplate,
bool  htmlLinksForClassNames = false,
string  prefixForComponentUrls = "" 
) const

Generates an ASCII tree dump of a component tree.

Parameters
branchTemplateUsed for recursion. Start with an empty string ("").
htmlLinksForClassNamesUsed to generate HTML links by 'make documentation'.
prefixForComponentUrlsPlaced before component/xyz.html in html links to components.
Returns
An ASCII string containing the tree.

Definition at line 459 of file Component.cc.

References GenerateDetails(), GetChildren(), GetClassName(), GetVariable(), and StateVariable::ToString().

Referenced by GXemul::DumpMachineAsHTML(), GXemul::GenerateHTMLListOfComponents(), MainbusComponent::PreRunCheckForComponent(), and GXemul::Run().

string Component::GetAttribute ( const string &  attributeName)
static

Creates a Component.

The reason for having this helper, instead of simply calling the constructor of a specific Component, is to make templates work in a reasonable and straight-forward manner. (Note: This concept of templates is unrelated to the C++ concept of templates. It just happens to be the same word.)

E.g. DummyComponent::Create() returns a new DummyComponent, but TestMIPSMachine::Create() returns a new MachineComponent (with some pre-defined child components), not a TestMIPS component. Get attribute information about a Component.

Parameters
attributeNameThe attribute name.
Returns
A string representing the attribute value. The base implementation returns an empty string; it is up to individual Components to return other values.

Definition at line 66 of file Component.cc.

Referenced by DummyComponent::GetAttribute(), MainbusComponent::GetAttribute(), MachineComponent::GetAttribute(), CacheComponent::GetAttribute(), RAMComponent::GetAttribute(), MIPS_CPUComponent::GetAttribute(), and M88K_CPUComponent::GetAttribute().

Components & Component::GetChildren ( )

Gets pointers to child components.

Returns
Reference counted pointers to child components.

Definition at line 674 of file Component.cc.

Referenced by DetectChanges(), GXemul::DumpMachineAsHTML(), GXemul::GenerateHTMLListOfComponents(), GenerateTreeDump(), and GXemul::Run().

const Components & Component::GetChildren ( ) const

Gets pointers to child components, as a const reference.

Returns
Reference counted pointers to child components.

Definition at line 680 of file Component.cc.

string Component::GetClassName ( ) const

Gets the class name of the component.

Returns
the class name of the component, e.g. "pcibus" for a PCI bus component class, or "mips_cpu" for a MIPS CPU.

Definition at line 54 of file Component.cc.

Referenced by Clone(), DetectChanges(), GeneratePath(), and GenerateTreeDump().

double Component::GetCurrentFrequency ( ) const
virtual

Returns the current frequency (in Hz) that the component runs at.

Returns
The component's frequency in Hz.

Reimplemented in CPUComponent.

Definition at line 343 of file Component.cc.

Referenced by GenerateDetails().

void Component::GetMethodNames ( vector< string > &  names) const
virtual

Retrieves a component's implemented method names.

Note that a component's implementation should call its base class' GetMethodNames(vector<string>&) too. However, when methods are executed, the most specific implementation (i.e. not the base class) will get a chance first to execute the method.

Parameters
namesA vector of strings, where method names should be added.

Reimplemented in RAMComponent, CacheComponent, and CPUComponent.

Definition at line 393 of file Component.cc.

Referenced by CPUComponent::GetMethodNames(), CacheComponent::GetMethodNames(), and RAMComponent::GetMethodNames().

Component * Component::GetParent ( )

Gets this component's parent component, if any.

Note: Not reference counted.

Returns NULL if there is no parent component.

Returns
the pointer to the parent component, or NULL

Definition at line 381 of file Component.cc.

Referenced by AddChild(), CheckVariableWrite(), RemoveComponentCommand::Execute(), MoveComponentCommand::Execute(), FindPathByPartialMatch(), GenerateShortestPossiblePath(), GetRunningGXemulInstance(), and LookupPath().

const Component * Component::GetParent ( ) const

Definition at line 387 of file Component.cc.

GXemul * Component::GetRunningGXemulInstance ( )
protected

Returns a reference to the current GXemul instance.

Returns
NULL if there was no currently running instance, otherwise a pointer to the currently running GXemul instance.

Definition at line 569 of file Component.cc.

References AsRootComponent(), RootComponent::GetOwner(), and GetParent().

Referenced by CheckVariableWrite(), CPUDyntransComponent::DyntransToBeTranslatedDone(), CPUComponent::FunctionTraceCall(), CPUComponent::FunctionTraceReturn(), and GetUI().

UI * Component::GetUI ( )
protected

Gets an UI reference for outputting debug messages during runtime.

Returns
NULL if debug messages are turned off, or if there is no owning GXemul instance. Otherwise, a pointer to an UI.

Definition at line 583 of file Component.cc.

References GetRunningGXemulInstance(), and GXemul::GetUI().

Referenced by RootComponent::CheckVariableWrite(), MIPS_CPUComponent::CheckVariableWrite(), M88K_CPUComponent::CheckVariableWrite(), CheckVariableWrite(), CPUDyntransComponent::DyntransReadInstruction(), CPUDyntransComponent::DyntransToBeTranslatedDone(), CPUComponent::FunctionTraceCall(), CPUComponent::FunctionTraceReturn(), and SetVariableValue().

StateVariable * Component::GetVariable ( const string &  name)

Gets a pointer to a state variable.

NOTE: The returned pointer should be used immediately after the call. It will in general not be valid after e.g. an AddVariable call.

Parameters
nameThe variable name.
Returns
A pointer to the variable, it the name was known; NULL otherwise.

Definition at line 949 of file Component.cc.

Referenced by AddChild(), DetectChanges(), BackwardStepCommand::Execute(), MemoryMappedComponent::GenerateDetails(), GenerateDetails(), GeneratePath(), GenerateTreeDump(), GXemul::GetStep(), and FileLoader_aout::LoadIntoComponent().

const StateVariable * Component::GetVariable ( const string &  name) const

Gets a pointer to a state variable.

NOTE: The returned pointer should be used immediately after the call. It will in general not be valid after e.g. an AddVariable call.

Parameters
nameThe variable name.
Returns
A pointer to the variable, it the name was known; NULL otherwise.

Definition at line 959 of file Component.cc.

void Component::GetVariableNames ( vector< string > &  names) const

Retrieves a component's state variable names.

Parameters
namesA vector of strings, where method names should be added.

Definition at line 941 of file Component.cc.

string Component::GetVisibleClassName ( ) const

Gets the visible class name of the component.

Returns
the class name of the component, e.g. "pcibus" for a PCI bus component class, or "cpu" for a MIPS CPU.

Definition at line 60 of file Component.cc.

Referenced by AddChild().

const refcount_ptr< Component > Component::LightClone ( ) const

Makes a light clone of the component and all its children.

Modifying the original component will not affect the component returned by this function.

The new copy is not a complete copy. Expensive data structures are not copied, only "light" data structures. For example, RAM memory cell contents is not cloned.

The main purpose of this function is to allow e.g. a single stepper to take a light clone, run one step, and the compare the current component tree with the light clone, to see what was modified in the step.

Returns
A const reference counted pointer to the light clone.

Definition at line 192 of file Component.cc.

Referenced by BackwardStepCommand::Execute(), and GXemul::Execute().

const refcount_ptr< Component > Component::LookupPath ( string  path) const

Looks up a path from this Component, and returns a pointer to the found Component, if any.

The first name in the path should match the name of this component. If so, this function moves on to the next part of the path (if there are more parts) and looks up a child with that name, and so on.

Alternatively, the path may be a partial match.

Parameters
pathThe path to the component, consisting of names with "." (period) between names.
Returns
A reference counted pointer to the looked up component, which is set to NULL if the path was not found.

Definition at line 778 of file Component.cc.

References GetParent(), refcount_ptr< T >::IsNULL(), and LookupPath().

Referenced by SaveCommand::Execute(), AddComponentCommand::Execute(), RemoveComponentCommand::Execute(), CopyComponentCommand::Execute(), LoadCommand::Execute(), MoveComponentCommand::Execute(), FindPathByPartialMatch(), and LookupPath().

bool Component::MethodMayBeReexecutedWithoutArgs ( const string &  methodName) const
virtual

Returns whether a method name may be re-executed without args.

Typical examples may be a RAMComponent which has a "dump" method, or a CPUComponent which has "dump" and "unassemble" methods.

Note that a component's implementation should call its base class' MethodMayBeReexecutedWithoutArgs(cosnt string&) too.

Parameters
methodNameThe name of the method.
Returns
true if the method may be re-executed without arguments, false otherwise.

Reimplemented in RAMComponent, CacheComponent, and CPUComponent.

Definition at line 399 of file Component.cc.

Referenced by CPUComponent::MethodMayBeReexecutedWithoutArgs(), CacheComponent::MethodMayBeReexecutedWithoutArgs(), and RAMComponent::MethodMayBeReexecutedWithoutArgs().

bool Component::PreRunCheck ( GXemul gxemul)

Checks the state of this component and all its children, before starting execution.

Returns
true if the component and all its children are ready to run, false otherwise.

Definition at line 298 of file Component.cc.

References PreRunCheckForComponent().

Referenced by ConsoleUI::MainLoop().

bool Component::PreRunCheckForComponent ( GXemul gxemul)
protectedvirtual

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 in M88K_CPUComponent, MIPS_CPUComponent, CPUComponent, MainbusComponent, and RootComponent.

Definition at line 310 of file Component.cc.

Referenced by PreRunCheck().

size_t Component::RemoveChild ( Component childToRemove)

Removes a reference to a child component.

Parameters
childToRemoveA pointer to the child to remove.
Returns
A zero-based index, which is the position in the vector of children where the child was. (Needed for e.g. Undo functionality.)

Definition at line 655 of file Component.cc.

References SetParent().

Referenced by MoveComponentCommand::Execute(), and RemoveComponentCommand::Execute().

void Component::Reset ( )

Resets the state of this component and all its children.

Definition at line 281 of file Component.cc.

References ResetState().

Referenced by GXemul::Reset().

void Component::ResetState ( )
protectedvirtual

Resets the state variables of this component.

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

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

The implementation of this function ususally takes the form of a number of assignment of values to member variables, and then the call to the base class' ResetState() function.

Reimplemented in M88K_CPUComponent, MIPS_CPUComponent, RAMComponent, CacheComponent, and CPUComponent.

Definition at line 291 of file Component.cc.

Referenced by Reset(), and CPUComponent::ResetState().

void Component::Serialize ( ostream &  ss,
SerializationContext context 
) const

Serializes the Component into a string stream.

Parameters
ssAn ostream which the Component will be serialized to.
contextA serialization context (used for TAB indentation).

Definition at line 1070 of file Component.cc.

References SerializationContext::Indented(), and SerializationContext::Tabs().

Referenced by AddChecksum(), CheckConsistency(), and SaveCommand::Execute().

void Component::SetParent ( Component parentComponent)

Sets the parent component of this component.

Note: Not reference counted.

Parameters
parentComponenta pointer to the parent component.

Definition at line 375 of file Component.cc.

Referenced by AddChild(), and RemoveChild().

bool Component::SetVariableValue ( const string &  name,
const string &  expression 
)

Sets a variable to a new value.

Parameters
nameThe variable name.
expressionThe new value.
Returns
True if the value was set, false otherwise. (E.g. if the name was not known, or if there was a parse error when parsing the value expression.)

Definition at line 1030 of file Component.cc.

References CheckVariableWrite(), GetUI(), StateVariable::SerializeValue(), StateVariable::SetValue(), and UI::ShowDebugMessage().

Referenced by AddChild(), MVME187Machine::Create(), SGI_IP30_Machine::Create(), SGI_IP32_Machine::Create(), TestM88KMachine::Create(), TestMIPSMachine::Create(), MIPS_CPUComponent::Create(), M88K_CPUComponent::Create(), Deserialize(), BackwardStepCommand::Execute(), FileLoader_aout::LoadIntoComponent(), FileLoader_ELF::LoadIntoComponent(), FileLoader_raw::LoadIntoComponent(), and RootComponent::RootComponent().


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

Generated on Sun Aug 17 2014 10:51:03 for GXemul by doxygen 1.8.3.1