An RDF Model is an abstract immutable collection of RDF triples. More...
#include <pd_DocumentRDF.h>
Public Types | |
typedef std::map< std::string, std::string > | stringmap_t |
typedef stringmap_t | uriToPrefix_t |
Public Member Functions | |
virtual | ~PD_RDFModel () |
virtual PD_ObjectList | getObjects (const PD_URI &s, const PD_URI &p) |
virtual PD_Object | getObject (const PD_URI &s, const PD_URI &p) |
Get an object which has the given subject and predicate. | |
virtual PD_URIList | getSubjects (const PD_URI &p, const PD_Object &o) |
virtual PD_URI | getSubject (const PD_URI &p, const PD_Object &o) |
Similar to getSubjects but returns any one of the matches if there are more than one. | |
virtual PD_URIList | getAllSubjects () |
Get a list of every subject in the model. | |
virtual POCol | getArcsOut (const PD_URI &s) |
virtual bool | contains (const PD_URI &s, const PD_URI &p, const PD_Object &o) |
Test if the given triple is in the RDF or not. | |
virtual bool | contains (const PD_URI &s, const PD_URI &p) |
Test if the given subject+predicate is in the RDF or not. | |
virtual bool | contains (const PD_RDFStatement &st) |
virtual long | getTripleCount () |
virtual PD_RDFModelIterator | begin ()=0 |
virtual PD_RDFModelIterator | end ()=0 |
virtual uriToPrefix_t & | getUriToPrefix () |
virtual void | dumpModel (const std::string &headerMsg="dumpModel()") |
virtual PD_DocumentRDFMutationHandle | createMutation ()=0 |
virtual std::string | uriToPrefixed (const std::string &uri) |
virtual std::string | prefixedToURI (const std::string &prefixed) |
long | size () |
bool | empty () |
long | getVersion () const |
Protected Member Functions | |
PD_URI | front (const PD_URIList &l) const |
Grab the first URI in the list or a default constructed one for empty lists. | |
PD_Object | front (const PD_ObjectList &l) const |
PD_RDFModel () | |
void | incremenetVersion () |
Protected Attributes | |
long | m_version |
An RDF Model is an abstract immutable collection of RDF triples.
You can query if the model contains a statement, and navigate around by supplying one or more parts of a triple.
Having the RDF Model abstract like this allows slices of the whole RDF to be returned in various places. For example, to get all the RDF that is explicitly "related" to a location in the document.
To make implementing custom models simpler many methods have defaults which rely on other methods. For example, the getObject() method simply returns the first object from the getObjects() method. Many of the default implementations rely on begin() and end() and simply loop over all the RDF to find the result. Compare the linear performance of the default to the contant time performance which might be possible for contains(s,p,o) if the model uses more knowledge.
The uriToPrefixed() and prefixedToURI() rely on getUriToPrefix() returning a suitable prefix map.
Methods with default implementations remain virtual because a subclass might have a more efficient method of finding the result than the default implementation.
typedef std::map< std::string, std::string > PD_RDFModel::stringmap_t |
PD_RDFModel::PD_RDFModel | ( | ) | [protected] |
virtual PD_RDFModel::~PD_RDFModel | ( | ) | [inline, virtual] |
virtual PD_RDFModelIterator PD_RDFModel::begin | ( | ) | [pure virtual] |
Implemented in PD_DocumentRDF.
Referenced by contains(), dumpModel(), getAllSubjects(), getArcsOut(), getObjects(), getSubjects(), and getTripleCount().
Test if the given subject+predicate is in the RDF or not.
References getObject(), and PD_URI::isValid().
Test if the given triple is in the RDF or not.
Reimplemented in PD_RDFModelFromStartEndPos, and PD_DocumentRDF.
References begin(), and end().
Referenced by contains().
bool PD_RDFModel::contains | ( | const PD_RDFStatement & | st | ) | [virtual] |
Reimplemented in PD_DocumentRDF.
References contains(), PD_RDFStatement::getObject(), PD_RDFStatement::getPredicate(), and PD_RDFStatement::getSubject().
virtual PD_DocumentRDFMutationHandle PD_RDFModel::createMutation | ( | ) | [pure virtual] |
Implemented in RDFModel_SPARQLLimited, RDFModel_XMLIDLimited, and PD_DocumentRDF.
void PD_RDFModel::dumpModel | ( | const std::string & | headerMsg = "dumpModel()" |
) | [virtual] |
Reimplemented in PD_RDFModelFromStartEndPos, and PD_DocumentRDF.
References begin(), end(), getTripleCount(), PD_RDFStatement::toString(), UT_DEBUG_ONLY_ARG, and UT_DEBUGMSG.
bool PD_RDFModel::empty | ( | ) | [inline] |
References size.
virtual PD_RDFModelIterator PD_RDFModel::end | ( | ) | [pure virtual] |
Implemented in PD_DocumentRDF.
Referenced by contains(), dumpModel(), getAllSubjects(), getArcsOut(), getObjects(), getSubjects(), and getTripleCount().
PD_URI PD_RDFModel::front | ( | const PD_URIList & | l | ) | const [protected] |
Grab the first URI in the list or a default constructed one for empty lists.
Referenced by PD_RDFModelFromStartEndPos::getObject(), getObject(), PD_RDFModelFromStartEndPos::getSubject(), and getSubject().
PD_Object PD_RDFModel::front | ( | const PD_ObjectList & | l | ) | const [protected] |
PD_URIList PD_RDFModel::getAllSubjects | ( | ) | [virtual] |
Get a list of every subject in the model.
If you want to get all triples, then first get all subjects and then use getArcsOut() to get the predicate-object combinations for each of the subjects.
Reimplemented in PD_RDFModelFromStartEndPos, and PD_DocumentRDF.
References begin(), end(), and PD_RDFStatement::getSubject().
Reimplemented in PD_RDFModelFromStartEndPos, and PD_DocumentRDF.
References begin(), end(), PD_RDFStatement::getObject(), PD_RDFStatement::getPredicate(), and PD_RDFStatement::getSubject().
Get an object which has the given subject and predicate.
If there are more than one such object, any one of those will be returned. So you should only use this method when the RDF only allows a single matching triple.
Reimplemented in PD_RDFModelFromStartEndPos.
References front(), and getObjects().
Referenced by contains(), and PD_DocumentRDF::runMilestone2Test2().
PD_ObjectList PD_RDFModel::getObjects | ( | const PD_URI & | s, | |
const PD_URI & | p | |||
) | [virtual] |
Reimplemented in PD_RDFModelFromStartEndPos, and PD_DocumentRDF.
References begin(), end(), PD_RDFStatement::getObject(), PD_RDFStatement::getPredicate(), and PD_RDFStatement::getSubject().
Referenced by getObject().
Similar to getSubjects but returns any one of the matches if there are more than one.
Use this method when the RDF schema only allows a single matching triple.
Reimplemented in PD_RDFModelFromStartEndPos.
References front(), and getSubjects().
Referenced by PD_DocumentRDF::runMilestone2Test2().
PD_URIList PD_RDFModel::getSubjects | ( | const PD_URI & | p, | |
const PD_Object & | o | |||
) | [virtual] |
Reimplemented in PD_RDFModelFromStartEndPos, and PD_DocumentRDF.
References begin(), end(), PD_RDFStatement::getObject(), PD_RDFStatement::getPredicate(), and PD_RDFStatement::getSubject().
Referenced by getSubject().
long PD_RDFModel::getTripleCount | ( | ) | [virtual] |
PD_RDFModel::uriToPrefix_t & PD_RDFModel::getUriToPrefix | ( | ) | [virtual] |
Referenced by prefixedToURI(), and uriToPrefixed().
long PD_RDFModel::getVersion | ( | ) | const [inline] |
Referenced by RDFModel_XMLIDLimited::update(), and RDFModel_SPARQLLimited::update().
void PD_RDFModel::incremenetVersion | ( | ) | [protected] |
References m_version.
Referenced by PD_DocumentRDF::maybeSetDocumentDirty().
std::string PD_RDFModel::prefixedToURI | ( | const std::string & | prefixed | ) | [virtual] |
References getUriToPrefix().
long PD_RDFModel::size | ( | ) | [inline] |
std::string PD_RDFModel::uriToPrefixed | ( | const std::string & | uri | ) | [virtual] |
References getUriToPrefix(), and starts_with().
long PD_RDFModel::m_version [protected] |
Referenced by incremenetVersion(), and RDFModel_SPARQLLimited::update().