Skip to content

Commit

Permalink
Deprecate 'cowl_manager_get_ontology' and improve 'cowl_manager_retri…
Browse files Browse the repository at this point in the history
…eve_ontology'
  • Loading branch information
IvanoBilenchi committed Aug 25, 2024
1 parent 6ed4b56 commit ab12e05
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 4 additions & 0 deletions include/cowl_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ CowlOntology *cowl_manager_new_ontology(CowlManager *manager);
* @note You can pass NULL as the IRI and version, in which case the function returns
* a new anonymous ontology.
*/
COWL_DEPRECATED(Use @func{cowl_manager_retrieve_ontology()} or @func{cowl_manager_new_ontology()}.)
COWL_API
COWL_RETAINED
CowlOntology *cowl_manager_get_ontology(CowlManager *manager, CowlIRI *iri, CowlIRI *version);
Expand All @@ -183,6 +184,9 @@ CowlOntology *cowl_manager_get_ontology(CowlManager *manager, CowlIRI *iri, Cowl
* @param iri The ontology IRI.
* @param version The ontology version.
* @return Ontology with the specified IRI and version, or NULL if it does not exist.
*
* @note Passing NULL as the version retrieves the ontology with the specified IRI
* and either NULL version (if it exists) or any other version.
*/
COWL_API
CowlOntology *cowl_manager_retrieve_ontology(CowlManager *manager, CowlIRI *iri, CowlIRI *version);
Expand Down
10 changes: 5 additions & 5 deletions src/cowl_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,13 +252,13 @@ CowlOntology *cowl_manager_get_ontology(CowlManager *manager, CowlIRI *iri, Cowl
}

CowlOntology *cowl_manager_retrieve_ontology(CowlManager *manager, CowlIRI *iri, CowlIRI *version) {
CowlOntology *match = NULL;
uvec_foreach (CowlObjectPtr, &manager->ontos, onto) {
if (cowl_ontology_get_iri(*onto.item) == iri &&
cowl_ontology_get_version(*onto.item) == version) {
return *onto.item;
}
if (cowl_ontology_get_iri(*onto.item) != iri) continue;
match = *onto.item;
if (cowl_ontology_get_version(*onto.item) == version) break;
}
return NULL;
return match;
}

cowl_ret cowl_manager_add_ontology(CowlManager *manager, CowlOntology *onto) {
Expand Down

0 comments on commit ab12e05

Please sign in to comment.