50#ifndef __SIM_CXX_MANAGER_HH__
51#define __SIM_CXX_MANAGER_HH__
87 Exception(
const std::string &name_,
const std::string &message_) :
107 const std::string &to_prefix) :
134 const std::string &responsePort,
PortID responsePortIndex);
144 std::string
rename(
const std::string &from_name);
148 std::string
unRename(
const std::string &to_name);
181 const std::string &object_name, std::string &object_type);
211 bool visit_children =
false);
238 template<
typename SimObjectType>
247 SimObjectType *
object =
dynamic_cast<SimObjectType *
>(
252 " type", object_name));
267 static void parsePort(
const std::string &inp,
268 std::string &path, std::string &port,
unsigned int &
index);
287 unsigned int drain();
308 void setParam(
const std::string &object_name,
309 const std::string ¶m_name,
const std::string ¶m_value);
311 const std::string ¶m_name,
Similar to ParamDesc to describe ports.
Config details entry for a SimObject.
Config file wrapper providing a common interface to CxxConfigManager.
Exception for instantiate/post-instantiate errors.
Exception(const std::string &name_, const std::string &message_)
const char * what() const
Class for resolving SimObject names to SimObjects usable by the checkpoint restore mechanism.
SimObject * resolveSimObject(const std::string &name)
Find a SimObject given a full path name.
CxxConfigManager & configManager
SimObjectResolver(CxxConfigManager &configManager_)
This class allows a config file to be read into gem5 (generating the appropriate SimObjects) from C++...
std::set< std::string > inVisit
While configuring, inVisit contains names of SimObjects visited in this recursive configuration walk.
std::list< SimObject * > objectsInOrder
SimObjects in order.
void drainResume()
Resume from drain.
static void parsePort(const std::string &inp, std::string &path, std::string &port, unsigned int &index)
Parse a port string of the form 'path(.path)*.port[index]' into path, port and index.
void startup()
Call startup on all objects.
void deleteObjects()
Delete all objects and clear objectsByName and objectsByOrder.
CxxConfigManager(CxxConfigFileBase &configFile_)
void serialize(std::ostream &os)
Serialize (checkpoint) all objects to the given stream.
std::string rename(const std::string &from_name)
Apply the first matching renaming in renamings to the given name.
std::string unRename(const std::string &to_name)
Apply the first matching renaming in reverse (toPrefix -> fromPrefix for the given name.
CxxConfigParams::Flags flags
Flags to pass to affect param setting.
void setParamVector(const std::string &object_name, const std::string ¶m_name, const std::vector< std::string > ¶m_values)
CxxConfigFileBase & configFile
Configuration file being read.
SimObjectResolver & getSimObjectResolver()
Get the resolver used to map SimObject names to SimObjects for checkpoint restore.
void bindPort(SimObject *requestorObject, const std::string &requestPort, PortID requestPortIndex, SimObject *responderObject, const std::string &responsePort, PortID responsePortIndex)
Bind a single connection between two objects' ports.
SimObjectType & getObject(const std::string &object_name)
Find an object from objectsByName with a type-checking cast.
void addRenaming(const Renaming &renaming)
Add a name prefix renaming to those currently applied.
unsigned int drain()
Drain all objects.
void initState()
Call initState on all objects.
std::list< Renaming > renamings
All the renamings applicable when instantiating objects.
void findTraversalOrder(const std::string &object_name)
Populate objectsInOrder with a preorder, depth first traversal from the given object name down throug...
std::map< std::string, SimObject * > objectsByName
SimObject indexed by name.
void setParam(const std::string &object_name, const std::string ¶m_name, const std::string ¶m_value)
Convenience functions for calling set... member functions on a CxxConfigParams for an object.
void forEachObject(void(SimObject::*mem_func)())
Perform mem_func on each SimObject.
void bindRequestPort(SimObject *object, const CxxConfigDirectoryEntry::PortDesc &port, const std::vector< std::string > &peers)
Bind a single (possibly vectored) request port to peers from the unparsed list peers with elements in...
CxxConfigParams * findObjectParams(const std::string &object_name)
Find the parameters for the named object.
void bindObjectPorts(SimObject *object)
Bind the ports of a single SimObject.
std::map< std::string, CxxConfigParams * > objectParamsByName
...Params objects created by this manager
void loadState(CheckpointIn &checkpoint)
Load all objects' state from the given Checkpoint.
void findAllObjects()
Find all objects by iterating over the object names in the config file with findObject.
SimObject * findObject(const std::string &object_name, bool visit_children=false)
Walk the configuration starting with object object_name and fill in all the elements of this object o...
SimObjectResolver simObjectResolver
Singleton instance of SimObjectResolver.
void bindAllPorts()
Bind the ports of all the objects in objectInOrder order.
void instantiate(bool build_all=true)
Build all objects (if build_all is true, otherwise objects must have been individually findObject-ed ...
const CxxConfigDirectoryEntry & findObjectType(const std::string &object_name, std::string &object_type)
Find the type field for a named object and return both the name of the type to object_type and the ob...
Base for peer classes of SimObjectParams derived classes with parameter modifying member functions.
Base class to wrap object resolving functionality.
Abstract superclass for simulation objects.
C++-only configuration and instantiation support.
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
std::string csprintf(const char *format, const Args &...args)
Name substitution when instantiating any object whose name starts with fromPrefix.
Renaming(const std::string &from_prefix, const std::string &to_prefix)
const std::string & name()