[lib] adding missing apis
This commit is contained in:
parent
7bc843b74a
commit
5cd310c4cc
|
@ -28,6 +28,14 @@ ClockNetwork::clock_tree_range ClockNetwork::trees() const {
|
|||
/************************************************************************
|
||||
* Public Accessors : Basic data query
|
||||
***********************************************************************/
|
||||
bool ClockNetwork::find_spine(const std::string& name) const {
|
||||
auto result = spine_name2id_map_.find(name);
|
||||
if (result == spine_name2id_map_.end()) {
|
||||
return ClockSpineId::INVALID();
|
||||
}
|
||||
return result->second;
|
||||
}
|
||||
|
||||
bool ClockNetwork::empty() const { return 0 == tree_ids_.size(); }
|
||||
|
||||
/************************************************************************
|
||||
|
@ -103,6 +111,14 @@ ClockSpineId ClockNetwork::create_spine(const std::string& name) {
|
|||
return spine_id;
|
||||
}
|
||||
|
||||
ClockSpineId ClockNetwork::try_create_spine(const std::string& name) {
|
||||
ClockSpineId spine_id = find_spine(name);
|
||||
if (!spine_id) {
|
||||
spine_id = create_spine(name);
|
||||
}
|
||||
return spine_id;
|
||||
}
|
||||
|
||||
void ClockNetwork::set_spine_parent_tree(const ClockSpineId& spine_id, const ClockTreeId& tree_id) {
|
||||
VTR_ASSERT(valid_spine_id(spine_id));
|
||||
VTR_ASSERT(valid_tree_id(tree_id));
|
||||
|
|
|
@ -49,6 +49,9 @@ class ClockNetwork {
|
|||
clock_tree_range trees() const;
|
||||
|
||||
public: /* Public Accessors: Basic data query */
|
||||
/* Find a spine with a given name, if not found, return an valid id, otherwise return an invalid one */
|
||||
ClockSpineId find_spine(const std::string& name) const;
|
||||
|
||||
/* Check if there are clock tree */
|
||||
bool empty() const;
|
||||
|
||||
|
@ -64,6 +67,8 @@ class ClockNetwork {
|
|||
|
||||
/* Create a new spine, if the spine is already created, return an invalid id */
|
||||
ClockSpineId create_spine(const std::string& name);
|
||||
/* Try to create a new spine, if the spine is already existing, return the id. If not, create a new spine and return its id */
|
||||
ClockSpineId try_create_spine(const std::string& name);
|
||||
|
||||
/* Set the parent tree for a given spine. It is illegal that a spine which does not belong to any tree */
|
||||
void set_spine_parent_tree(const ClockSpineId& spine_id, const ClockTreeId& tree_id);
|
||||
|
|
Loading…
Reference in New Issue