The ontology manager

Ontology reading and writing functionality is exposed via the CowlManager API. A CowlManager instance manages one or more ontology documents, and allows reading and writing ontologies from/to files, memory buffers, or byte streams. Its architecture allows for multiple readers and writers, either built-in or provided by the user.

struct CowlManager

Manages ontology documents.

Pseudo-extends: CowlObject

CowlManager *cowl_manager(void)

Returns a manager that uses the default reader and writer.

Note

You can specify the default reader and writer via cowl_set_reader() and cowl_set_writer() .

Note

You must release the returned object via cowl_release().

Returns:

Manager, or NULL on error.

CowlReader cowl_manager_get_reader(CowlManager *manager)

Gets the reader.

Parameters:
  • manager – The manager.

Returns:

The reader.

void cowl_manager_set_reader(CowlManager *manager, CowlReader reader)

Sets the reader.

Parameters:
  • manager – The manager.

  • reader – The reader.

CowlWriter cowl_manager_get_writer(CowlManager *manager)

Gets the writer.

Parameters:
  • manager – The manager.

Returns:

The writer.

void cowl_manager_set_writer(CowlManager *manager, CowlWriter writer)

Sets the writer.

Parameters:
  • manager – The manager.

  • writer – The writer.

CowlImportLoader cowl_manager_get_import_loader(CowlManager *manager)

Gets the import loader.

Parameters:
  • manager – The manager.

Returns:

The import loader.

void cowl_manager_set_import_loader(CowlManager *manager, CowlImportLoader loader)

Sets the import loader.

Parameters:
  • manager – The manager.

  • loader – The import loader.

CowlErrorHandler cowl_manager_get_error_handler(CowlManager *manager)

Gets the error handler.

Parameters:
  • manager – The manager.

Returns:

The error handler.

void cowl_manager_set_error_handler(CowlManager *manager, CowlErrorHandler handler)

Sets the error handler.

Parameters:
  • manager – The manager.

  • handler – The error handler.

ulib_uint cowl_manager_ontology_count(CowlManager *manager)

Returns the number of ontologies managed by this manager.

Parameters:
  • manager – The manager.

Returns:

Number of ontologies.

bool cowl_manager_iterate_ontologies(CowlManager *manager, CowlIterator *iter)

Iterates over the ontologies held by the manager.

Parameters:
  • manager – The manager.

  • iter – The iterator.

Returns:

True if iteration was completed, false if it was stopped.

CowlOntology *cowl_manager_get_ontology(CowlManager *manager, CowlOntologyId const *id)

Gets the ontology with the specified identifier.

If no existing ontology has the specified identifier, a new ontology is returned.

Note

You can pass NULL as the ontology identifier, in which case the function returns a new anonymous ontology.

Note

You must release the returned object via cowl_release().

Parameters:
  • manager – The manager.

  • id – The ontology identifier.

Returns:

Ontology with the specified identifier.

CowlOntology *cowl_manager_retrieve_ontology(CowlManager *manager, CowlOntologyId const *id)

Gets the ontology with the specified identifier, if it exists.

Parameters:
  • manager – The manager.

  • id – The ontology identifier.

Returns:

Ontology with the specified identifier, or NULL if it does not exist.

CowlOntology *cowl_manager_read_path(CowlManager *manager, UString path)

Reads an ontology from the file at the specified path.

Note

You must release the returned object via cowl_release().

Parameters:
  • manager – The manager.

  • path – The file path.

Returns:

The read ontology, or NULL on error.

CowlOntology *cowl_manager_read_file(CowlManager *manager, FILE *file)

Reads an ontology from the specified file.

Note

You must release the returned object via cowl_release().

Parameters:
  • manager – The manager.

  • file – The input file.

Returns:

The read ontology, or NULL on error.

CowlOntology *cowl_manager_read_string(CowlManager *manager, UString const *string)

Reads an ontology from the specified string.

Note

You must release the returned object via cowl_release().

Parameters:
  • manager – The manager.

  • string – The input string.

Returns:

The read ontology, or NULL on error.

CowlOntology *cowl_manager_read_stream(CowlManager *manager, UIStream *stream)

Reads an ontology from the specified input stream.

Note

The stream is not released by the manager, you must do it yourself.

Note

You must release the returned object via cowl_release().

Parameters:
  • manager – The manager.

  • stream – The input stream.

Returns:

The read ontology, or NULL on error.

cowl_ret cowl_manager_write_path(CowlManager *manager, CowlOntology *onto, UString path)

Writes the ontology to the file at the specified path.

Parameters:
  • manager – The manager.

  • onto – The ontology.

  • path – The file path.

Returns:

Return code.

cowl_ret cowl_manager_write_file(CowlManager *manager, CowlOntology *onto, FILE *file)

Writes the ontology to the specified file.

Parameters:
  • manager – The manager.

  • onto – The ontology.

  • file – The output file.

Returns:

Return code.

cowl_ret cowl_manager_write_strbuf(CowlManager *manager, CowlOntology *onto, UStrBuf *buf)

Writes the ontology to the specified string buffer.

Parameters:
  • manager – The manager.

  • onto – The ontology.

  • buf – The string buffer.

Returns:

Return code.

cowl_ret cowl_manager_write_stream(CowlManager *manager, CowlOntology *onto, UOStream *stream)

Writes the ontology to the specified output stream.

Note

The stream is not released by the manager, you must do it yourself.

Parameters:
  • manager – The manager.

  • onto – The ontology.

  • stream – The output stream.

Returns:

Return code.

CowlIStream *cowl_manager_get_istream(CowlManager *manager, CowlIStreamHandlers handlers)

Returns an ontology input stream.

Note

You must release the returned object via cowl_release().

Parameters:
  • manager – The manager.

  • handlers – The handlers.

Returns:

Ontology input stream.

CowlIStream *cowl_manager_get_istream_to_ontology(CowlManager *manager, CowlOntology *onto)

Returns an ontology input stream that stores constructs in the specified ontology.

Note

You must release the returned object via cowl_release().

Parameters:
  • manager – The manager.

  • onto – The ontology.

Returns:

Ontology input stream.

CowlOStream *cowl_manager_get_ostream(CowlManager *manager, UOStream *stream)

Returns an ontology output stream.

Note

You must release the returned object via cowl_release().

Parameters:
  • manager – The manager.

  • stream – The output stream.

Returns:

Ontology output stream.