Public Types | Public Member Functions | Protected Member Functions | Protected Attributes

PD_RDFModel Class Reference

An RDF Model is an abstract immutable collection of RDF triples. More...

#include <pd_DocumentRDF.h>

Inheritance diagram for PD_RDFModel:
PD_DocumentRDF PD_RDFModelFromAP PD_RDFModelFromStartEndPos RDFModel_SPARQLLimited RDFModel_XMLIDLimited

List of all members.

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_tgetUriToPrefix ()
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

Detailed Description

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.


Member Typedef Documentation

typedef std::map< std::string, std::string > PD_RDFModel::stringmap_t

Constructor & Destructor Documentation

PD_RDFModel::PD_RDFModel (  )  [protected]
virtual PD_RDFModel::~PD_RDFModel (  )  [inline, virtual]

Member Function Documentation

virtual PD_RDFModelIterator PD_RDFModel::begin (  )  [pure virtual]
bool PD_RDFModel::contains ( const PD_URI s,
const PD_URI p 
) [virtual]

Test if the given subject+predicate is in the RDF or not.

References getObject(), and PD_URI::isValid().

bool PD_RDFModel::contains ( const PD_URI s,
const PD_URI p,
const PD_Object o 
) [virtual]

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]
virtual PD_DocumentRDFMutationHandle PD_RDFModel::createMutation (  )  [pure virtual]
void PD_RDFModel::dumpModel ( const std::string &  headerMsg = "dumpModel()"  )  [virtual]
bool PD_RDFModel::empty (  )  [inline]

References size.

virtual PD_RDFModelIterator PD_RDFModel::end (  )  [pure virtual]
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().

POCol PD_RDFModel::getArcsOut ( const PD_URI s  )  [virtual]
PD_Object PD_RDFModel::getObject ( const PD_URI s,
const PD_URI p 
) [virtual]

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]
PD_URI PD_RDFModel::getSubject ( const PD_URI p,
const PD_Object o 
) [virtual]

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]
long PD_RDFModel::getTripleCount (  )  [virtual]

Reimplemented in PD_DocumentRDF.

References begin(), and end().

Referenced by dumpModel().

PD_RDFModel::uriToPrefix_t & PD_RDFModel::getUriToPrefix (  )  [virtual]

Referenced by prefixedToURI(), and uriToPrefixed().

long PD_RDFModel::getVersion (  )  const [inline]
void PD_RDFModel::incremenetVersion (  )  [protected]
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().


Member Data Documentation


The documentation for this class was generated from the following files: