Predicate

class omexmeta::Predicate

The predicate class creates and stores a URI node.

Subclassed by omexmeta::BiomodelsBiologyQualifier, omexmeta::BiomodelsModelQualifier, omexmeta::DCTerm, omexmeta::Foaf, omexmeta::SemSim

Public Functions

Predicate() = default
Predicate(const std::string &namespace_, std::string term, std::string prefix)

construct a Predicate from a namespace, term and prefix portion of a predicate

http://biomodels.net/biology-qualifiers/is ————————————| | | namespace term

is equivalent to

bqbiol:is —| | | prefix term

Parameters
  • namespace_ – the namespace portion of a predicate. i.e. http://biomodels.net/biology-qualifiers/

  • term – the last portion of the predicate, i.e. is

  • prefix – the prefix that can be used instead of the full namespace, i.e. bqbiol

explicit Predicate(LibrdfNode node)
bool operator==(const Predicate &rhs) const
bool operator!=(const Predicate &rhs) const
std::string str()

get the predicate as a full string

Returns

a string representing the predicate

const std::vector<std::string> &getValidTerms() const

stores the valid terms that are allowed in a particular predicate subclass

Subclasses override this method so they return a complete list of valid terms for their own class

Returns

a vector of strings

const std::string &getNamespace() const

getter for the namespace portion of the Predicate

Returns

the string representing the namespace of the current Predicate

const std::string &getTerm() const

getter for term portion of the Predicate

Returns

the string representing the term portion of the Predicate

const std::string &getPrefix() const

getter for the prefix portion of the Predicate

Returns

the string representing the prefix portion of the Predicate

const std::string &getUri() const

getter for uri

For developers. Consider removing since str() method does the same thing

void freeNode()

release resources associated with this Predicate.

Predicate objects contain a librdf_node pointer which needs to be freed by the caller. If a Predicate is passed to a Triple object (which most of the time is it), responsibility for deleting the contained librdf_node is transferred to the Triple object, which automatically clears up resources. If not, then it is the callers responsibility to call this method when they are done with Predicate instances.

void setNode(LibrdfNode &node)

replace the current librdf_node assicated with this Predicate with node

Parameters

node – the new librdf_node pointer to use in the Predicate

LibrdfNode getNode()

Public Static Functions

static std::unordered_map<std::string, std::string> namespaceMap()

get a map namespaces and prefixes

Returns

a unordered_map with namespaces as keys and prefixes as values

static void verify(std::vector<std::string> valid_terms, const std::string &term)

Static method for checking validity of term against valid_terms.

Throws an error when term is not in valid_terms. Used by subclasses to verify user input.

Parameters
  • term – the term to validate

  • valid_terms – the set of terms to validate term against

static bool namespaceKnown(const std::string &ns)

check if we have “know” a namespace. Known namespaces are returned by Predicate::namespaceMap().

Parameters

ns – the namespace to check

Returns

True if we have seen the namespace ns before

static void addSeenNamespaceToSerializer(LibrdfSerializer serializer, LibrdfNode predicate)

utility for checking whether the uri in @parameter predicate has a namespace that we already know. If found, the namespace is added to @parameter serializer

Protected Attributes

std::string namespace_

make a shared pointer from this Predicate

std::string term_
std::string prefix_
std::string uri_
std::vector<std::string> valid_terms_ = {"All"}
LibrdfNode node_