Repository¶
-
class
Repository
¶
Represents the Repository of YANG models.
A instance of the Repository
will be used to create a RootSchemaNode
given a set of Capabilities
.
Behind the scenes the repository is responsible for loading and parsing the YANG modules and creating the SchemaNode
tree. The ServiceProvider
is expected to use the method create_root_schema
to generate the RootSchemaNode
.
Repository
()¶Constructs an instance of the
Repository
class. If the server supports model download, the repo will attempt to download all models from the server using theModelProvider
provided using theadd_model_provider
method.
Raises: YCPPInvalidArgumentError
if the search_dir is not a valid directory in the filesystem.
Repository
(const std::string &search_dir)¶Constructs an instance of the
Repository
class.
Parameters: search_dir – The path in the filesystem where yang files can be found. Raises: YCPPInvalidArgumentError
if the search_dir is not a valid directory in the filesystem.
- std::unique_ptr<RootSchemaNode>
create_root_schema
(const std::vector<Capability> capabilities) const¶Creates the root schema based on the
std::vector
of capabilities passed in.This method verifies the said capabilities and can throw exceptions if a module is not found in the search directory or cannot be loaded.
Parameters: capabilities – std::vector
ofCapability
.Returns: Pointer to the RootSchemaNode
ornullptr
if one could not be created.
- void
add_model_provider
(ModelProvider *model_provider)¶Adds a model provider to this Repository. If the repository does not find a model while trying to create a SchemaTree it calls on the model_provider to see if the said model can be downloaded by one of them. If that fails it tries the next.
Parameters: model_provider – The model provider to add
- void
remove_model_provider
(ModelProvider *model_provider)¶Removes the given model provider from this repository
Parameters: model_provider – The model provider to remove
- std::vector<ModelProvider *>
get_model_providers
() const¶Gets all model providers registered with this repository.
Returns: std::vector
of model providers associated with this repository
- std::string
path
¶Location where YANG models are present and/or downloaded to