add SystemC ISS factory
This commit is contained in:
@@ -80,9 +80,17 @@ class core_factory {
|
||||
public:
|
||||
static core_factory & instance() { static core_factory bf; return bf; }
|
||||
|
||||
bool register_creator(const std::string &, create_fn const&);
|
||||
bool register_creator(const std::string & className, create_fn const& fn) {
|
||||
registry[className] = fn;
|
||||
return true;
|
||||
}
|
||||
|
||||
base_t create(const std::string &, unsigned gdb_port=0, void* init_data=nullptr) const;
|
||||
base_t create(std::string const& className, unsigned gdb_port=0, void* init_data=nullptr) const {
|
||||
registry_t::const_iterator regEntry = registry.find(className);
|
||||
if (regEntry != registry.end())
|
||||
return regEntry->second(gdb_port, init_data);
|
||||
return {nullptr, nullptr};
|
||||
}
|
||||
|
||||
std::vector<std::string> get_names() {
|
||||
std::vector<std::string> keys{registry.size()};
|
||||
@@ -93,18 +101,6 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
inline bool core_factory::register_creator(const std::string & className, create_fn const& fn) {
|
||||
registry[className] = fn;
|
||||
return true;
|
||||
}
|
||||
|
||||
inline core_factory::base_t core_factory::create(const std::string &className, unsigned gdb_port, void* data) const {
|
||||
registry_t::const_iterator regEntry = registry.find(className);
|
||||
if (regEntry != registry.end())
|
||||
return regEntry->second(gdb_port, data);
|
||||
return {nullptr, nullptr};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif /* _ISS_FACTORY_H_ */
|
||||
|
Reference in New Issue
Block a user