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
Repositoryclass. If the server supports model download, the repo will attempt to download all models from the server using theModelProviderprovided using theadd_model_providermethod.
Raises: YCPPInvalidArgumentErrorif the search_dir is not a valid directory in the filesystem.
Repository(const std::string &search_dir)¶Constructs an instance of the
Repositoryclass.
Parameters: search_dir – The path in the filesystem where yang files can be found. Raises: YCPPInvalidArgumentErrorif 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::vectorof 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::vectorofCapability.Returns: Pointer to the RootSchemaNodeornullptrif 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::vectorof model providers associated with this repository
- std::string
path¶Location where YANG models are present and/or downloaded to