COPASI API  4.16.103
CRDFGraph.cpp
Go to the documentation of this file.
1 // Copyright (C) 2010 - 2013 by Pedro Mendes, Virginia Tech Intellectual
2 // Properties, Inc., University of Heidelberg, and The University
3 // of Manchester.
4 // All rights reserved.
5 
6 // Copyright (C) 2008 - 2009 by Pedro Mendes, Virginia Tech Intellectual
7 // Properties, Inc., EML Research, gGmbH, University of Heidelberg,
8 // and The University of Manchester.
9 // All rights reserved.
10 
11 // Copyright (C) 2007 by Pedro Mendes, Virginia Tech Intellectual
12 // Properties, Inc. and EML Research, gGmbH.
13 // All rights reserved.
14 
15 #include <iostream>
16 #include <fstream>
17 #include <sstream>
18 
19 #include "copasi.h"
20 
21 #include "model/CReaction.h"
22 #include "function/CFunction.h"
24 
25 #include "CRDFGraph.h"
26 #include "CRDFSubject.h"
27 #include "CRDFObject.h"
28 #include "CRDFLiteral.h"
29 #include "CRDFParser.h"
30 #include "CRDFWriter.h"
31 #include "CConstants.h"
32 
34  mpAbout(NULL),
35  mPrefix2Namespace(),
36  mBlankNodeId2Node(),
37  mLocalResource2Node(),
38  mRemoteResourceNodes(),
39  mLiteralNodes(),
40  mTriplets(),
41  mSubject2Triplet(),
42  mObject2Triplet(),
43  mPredicate2Triplet(),
44  mGeneratedIds(),
45  mIdMap()
46 {}
47 
49 {
50  // We first clear the sets and maps
51  // This is necessary since they refer to the nodes which are destroyed later.
52  mTriplets.clear();
53  mSubject2Triplet.clear();
54  mObject2Triplet.clear();
55  mPredicate2Triplet.clear();
56 
57  // Note: mpAbout is not explicitly destroyed since it is contained in the map
58  // of resource nodes.
59  std::map< std::string, CRDFNode * >::iterator itMap;
60  std::map< std::string, CRDFNode * >::iterator endMap;
61 
62  for (itMap = mBlankNodeId2Node.begin(), endMap = mBlankNodeId2Node.end();
63  itMap != endMap; ++itMap)
64  pdelete(itMap->second);
65 
66  for (itMap = mLocalResource2Node.begin(), endMap = mLocalResource2Node.end();
67  itMap != endMap; ++itMap)
68  pdelete(itMap->second);
69 
70  std::vector< CRDFNode *>::iterator itVector;
71  std::vector< CRDFNode *>::iterator endVector;
72 
73  for (itVector = mRemoteResourceNodes.begin(), endVector = mRemoteResourceNodes.end();
74  itVector != endVector; ++itVector)
75  pdelete(*itVector);
76 
77  for (itVector = mLiteralNodes.begin(), endVector = mLiteralNodes.end();
78  itVector != endVector; ++itVector)
79  pdelete(*itVector);
80 }
81 
83 {return mpAbout;}
84 
85 const std::map< std::string, std::string > & CRDFGraph::getNameSpaceMap() const
86 {return mPrefix2Namespace;}
87 
88 const std::map< std::string, CRDFNode * > & CRDFGraph::getBlankNodeMap() const
89 {return mBlankNodeId2Node;}
90 
91 const std::map< std::string, CRDFNode * > & CRDFGraph::getLocalResourceNodeMap() const
92 {return mLocalResource2Node;}
93 
94 const std::vector< CRDFNode * > & CRDFGraph::getRemoteResourceNodes() const
95 {return mRemoteResourceNodes;}
96 
97 bool CRDFGraph::guessGraphRoot(const std::string & about)
98 {
99  mpAbout = NULL;
100  CRDFNode * pNode;
101 
102  std::map< std::string, CRDFNode * >::iterator itMap = mLocalResource2Node.begin();
103  std::map< std::string, CRDFNode * >::iterator endMap = mLocalResource2Node.end();
104 
105  for (; itMap != endMap; ++itMap)
106  {
107  pNode = itMap->second;
108 
109  if (pNode->isSubjectNode() &&
110  pNode->getSubject().isLocal() &&
111  pNode->getSubject().getType() == CRDFSubject::RESOURCE &&
112  (about == " " ||
113  pNode->getSubject().getResource() == about))
114  {
115  if (mpAbout != NULL)
116  {
117  mpAbout = NULL;
118  break;
119  }
120 
121  mpAbout = pNode;
122  }
123  }
124 
125  return mpAbout != NULL;
126 }
127 
128 bool CRDFGraph::addNameSpace(const std::string & prefix, const std::string & uri)
129 {
130  std::pair< std::map< std::string, std::string >::iterator, bool > inserted =
131  mPrefix2Namespace.insert(std::pair< std::string, std::string >(prefix, uri));
132 
133  if (inserted.second || (inserted.first->second == uri))
134  return true;
135 
137  prefix.c_str(), inserted.first->second.c_str(), uri.c_str());
138  return false;
139 }
140 
142  const CRDFPredicate & predicate,
143  const CRDFObject & object)
144 {
145  // Find or create the subject node
146  std::map< std::string, CRDFNode * >::iterator found;
147  CRDFNode * pSubjectNode = NULL;
148 
149  switch (subject.getType())
150  {
152 
153  if (subject.isLocal())
154  {
155  found = mLocalResource2Node.find(subject.getResource());
156 
157  if (found != mLocalResource2Node.end())
158  {
159  pSubjectNode = found->second;
160 
161  if (!pSubjectNode->isSubjectNode())
162  pSubjectNode->setSubject(subject);
163  }
164  else
165  {
166  pSubjectNode = new CRDFNode(*this);
167  pSubjectNode->setSubject(subject);
168  mLocalResource2Node[subject.getResource()] = pSubjectNode;
169  }
170  }
171  else
172  {
173  pSubjectNode = new CRDFNode(*this);
174  pSubjectNode->setSubject(subject);
175  mRemoteResourceNodes.push_back(pSubjectNode);
176  }
177 
178  break;
179 
181  found = mBlankNodeId2Node.find(subject.getBlankNodeID());
182 
183  if (found != mBlankNodeId2Node.end())
184  pSubjectNode = found->second;
185  else
186  {
187  pSubjectNode = new CRDFNode(*this);
188  pSubjectNode->setSubject(subject);
189  mBlankNodeId2Node[subject.getBlankNodeID()] = pSubjectNode;
190  }
191 
192  break;
193  }
194 
195  // Find or create the object node
196  CRDFNode * pObjectNode = NULL;
197 
198  switch (object.getType())
199  {
201 
202  if (object.isLocal())
203  {
204  found = mLocalResource2Node.find(object.getResource());
205 
206  if (found != mLocalResource2Node.end())
207  {
208  pObjectNode = found->second;
209 
210  if (!pObjectNode->isObjectNode())
211  pObjectNode->setObject(object);
212  }
213  else
214  {
215  pObjectNode = new CRDFNode(*this);
216  pObjectNode->setObject(object);
217  mLocalResource2Node[object.getResource()] = pObjectNode;
218  }
219  }
220  else
221  {
222  pObjectNode = new CRDFNode(*this);
223  pObjectNode->setObject(object);
224  mRemoteResourceNodes.push_back(pObjectNode);
225  }
226 
227  break;
228 
230  found = mBlankNodeId2Node.find(object.getBlankNodeID());
231 
232  if (found != mBlankNodeId2Node.end())
233  pObjectNode = found->second;
234  else
235  {
236  pObjectNode = new CRDFNode(*this);
237  pObjectNode->setObject(object);
238  mBlankNodeId2Node[object.getBlankNodeID()] = pObjectNode;
239  }
240 
241  break;
242 
243  case CRDFObject::LITERAL:
244  pObjectNode = new CRDFNode(*this);
245  pObjectNode->setObject(object);
246  mLiteralNodes.push_back(pObjectNode);
247  break;
248  }
249 
250  if (predicate == CRDFPredicate::rdf_predicate &&
251  pObjectNode->getObject().getType() == CRDFObject::RESOURCE &&
254 
255  return pSubjectNode->addEdge(predicate, pObjectNode);
256 }
257 
258 bool CRDFGraph::addTriplet(const CRDFTriplet & triplet)
259 {
260  if (!triplet)
261  return false;
262 
263  std::pair< std::set< CRDFTriplet >::iterator, bool> Insert = mTriplets.insert(triplet);
264 
265  if (Insert.second)
266  {
267  mSubject2Triplet.insert(std::pair< CRDFNode * const, CRDFTriplet >(triplet.pSubject, triplet));
268  mObject2Triplet.insert(std::pair< CRDFNode * const, CRDFTriplet >(triplet.pObject, triplet));
269  mPredicate2Triplet.insert(std::pair< const CRDFPredicate , CRDFTriplet >(triplet.Predicate, triplet));
270 
271  // DebugFile << "Inserted: " << triplet;
272  }
273 
274  return true;
275 }
276 
278  const CRDFPredicate & predicate,
279  CRDFNode * pObject)
280 {pSubject->removeEdge(predicate, pObject);}
281 
283 {
284  if (!triplet)
285  return;
286 
287  // DebugFile << "Removed: " << triplet;
288 
289  // Remove the triplet
290  mTriplets.erase(triplet);
291 
292  // Remove its references
293  // Subject2Triplets
294  std::pair< Node2Triplet::iterator, Node2Triplet::iterator> Range = mSubject2Triplet.equal_range(triplet.pSubject);
295 
296  for (; Range.first != Range.second; ++Range.first)
297  if (Range.first->second == triplet)
298  {
299  mSubject2Triplet.erase(Range.first);
300 
301  // We must stop or make sure that the iterator Range is still valid. Since
302  // triplets are unique (we have at most one reference) we can stop.
303  break;
304  }
305 
306  Range = mObject2Triplet.equal_range(triplet.pObject);
307 
308  for (; Range.first != Range.second; ++Range.first)
309  if (Range.first->second == triplet)
310  {
311  mObject2Triplet.erase(Range.first);
312 
313  // We must stop or make sure that the iterator Range is still valid. Since
314  // triplets are unique (we have at most one reference) we can stop.
315  break;
316  }
317 
318  std::pair< Predicate2Triplet::iterator, Predicate2Triplet::iterator> RangeP = mPredicate2Triplet.equal_range(triplet.Predicate);
319 
320  for (; RangeP.first != RangeP.second; ++RangeP.first)
321  if (RangeP.first->second == triplet)
322  {
323  mPredicate2Triplet.erase(RangeP.first);
324 
325  // We must stop or make sure that the iterator RangeP is still valid. Since
326  // triplets are unique (we have at most one reference) we can stop.
327  break;
328  }
329 
331  return;
332 }
333 
335 {
336  CRDFTriplet Triplet = triplet;
337 
338  if (pNewSubject == NULL || !Triplet)
339  return Triplet;
340 
341  // We first create the new triplet before we remove the old to avoid
342  // destruction of the object/
343  Triplet = pNewSubject->addEdge(triplet.Predicate, triplet.pObject);
344  triplet.pSubject->removeEdge(triplet.Predicate, triplet.pObject);
345 
346  return Triplet;
347 }
348 
350 {
351  CRDFPredicate::Path Path;
352  CRDFNode * pCurrent = const_cast< CRDFNode * >(pNode);
353  Node2TripletRange Range = mObject2Triplet.equal_range(pCurrent);
354  std::set< const CRDFNode * > Visited;
355 
356  while ((Range.first != Range.second) &&
357  pCurrent != mpAbout)
358  {
359  // We ignore rdf_li predicates
360  if (Range.first->second.Predicate != CRDFPredicate::rdf_li)
361  Path.insert(Path.begin(), Range.first->second.Predicate.getType());
362 
363  pCurrent = Range.first->second.pSubject;
364 
365  std::pair< std::set< const CRDFNode * >::iterator, bool > Inserted =
366  Visited.insert(pCurrent);
367 
368  if (!Inserted.second)
369  break;
370 
371  Range = mObject2Triplet.equal_range(pCurrent);
372  }
373 
374  if (pCurrent == mpAbout)
375  Path.insert(Path.begin(), CRDFPredicate::about);
376 
377  return Path;
378 }
379 
380 std::string CRDFGraph::generatedNodeId(const std::string & existingId)
381 {
382  // If we have an existing Id we check whether we have already mapped it.
383  if (existingId != "")
384  {
385  std::map< std::string, std::string >::const_iterator found = mIdMap.find(existingId);
386 
387  if (found != mIdMap.end())
388  return found->second;
389  }
390 
391  unsigned int Id = 0;
392 
393  if (mGeneratedIds.rbegin() != mGeneratedIds.rend())
394  Id = *mGeneratedIds.rbegin();
395 
396  std::stringstream IdStream;
397  IdStream << "CopasiId" << ++Id;
398 
399  while (mBlankNodeId2Node.count(IdStream.str()) != 0)
400  {
401  mGeneratedIds.insert(Id);
402 
403  IdStream.str("");
404  IdStream << "CopasiId" << ++Id;
405  }
406 
407  mGeneratedIds.insert(Id);
408 
409  // Remember the mapping for an existing Id
410  if (existingId != "")
411  mIdMap[existingId] = IdStream.str();
412 
413  return IdStream.str();
414 }
415 
416 CRDFNode * CRDFGraph::createAboutNode(const std::string & key)
417 {
418  std::string About = "#" + key;
419 
420  if (!guessGraphRoot(About))
421  {
422  CRDFSubject subject;
423  mpAbout = new CRDFNode(*this);
424 
426  subject.setResource(About, true);
427  mpAbout->setSubject(subject);
428  mLocalResource2Node[About] = mpAbout;
429  }
430 
431  return mpAbout;
432 }
433 
434 const std::set< CRDFTriplet > & CRDFGraph::getTriplets() const
435 {return mTriplets;}
436 
437 std::set< CRDFTriplet > CRDFGraph::getTriplets(const CRDFPredicate & predicate,
438  const bool & expandBag) const
439 {
440  std::set< CRDFTriplet > Triplets;
441 
442  Predicate2TripletConstRange Range = mPredicate2Triplet.equal_range(predicate);
443 
444  for (; Range.first != Range.second; ++Range.first)
445  if (expandBag &&
446  Range.first->second.pObject->isBagNode())
447  {
448  std::set< CRDFTriplet > LiTriplets = getTriplets(Range.first->second.pObject, CRDFPredicate::rdf_li);
449  std::set< CRDFTriplet >::const_iterator it = LiTriplets.begin();
450  std::set< CRDFTriplet >::const_iterator end = LiTriplets.end();
451 
452  for (; it != end; ++it)
453  Triplets.insert(CRDFTriplet(Range.first->second.pSubject, predicate, it->pObject));
454  }
455  else
456  Triplets.insert(Range.first->second);
457 
458  return Triplets;
459 }
460 
461 std::set< CRDFTriplet > CRDFGraph::getTriplets(const CRDFNode * pSubject) const
462 {
463  std::set< CRDFTriplet > Triplets;
464 
465  Node2TripletConstRange Range = mSubject2Triplet.equal_range(const_cast< CRDFNode * >(pSubject));
466 
467  for (; Range.first != Range.second; ++Range.first)
468  Triplets.insert(Range.first->second);
469 
470  return Triplets;
471 }
472 
473 std::set< CRDFTriplet > CRDFGraph::getTriplets(const CRDFNode * pSubject,
474  const CRDFPredicate & predicate) const
475 {
476  std::set< CRDFTriplet > Triplets;
477 
478  Predicate2TripletConstRange Range = mPredicate2Triplet.equal_range(predicate);
479 
480  for (; Range.first != Range.second; ++Range.first)
481  if (Range.first->second.pSubject == pSubject)
482  Triplets.insert(Range.first->second);
483 
484  return Triplets;
485 }
486 
487 std::set< CRDFTriplet > CRDFGraph::getIncomingTriplets(const CRDFNode * pObject) const
488 {
489  std::set< CRDFTriplet > Triplets;
490 
491  Node2TripletConstRange Range = mObject2Triplet.equal_range(const_cast< CRDFNode * >(pObject));
492 
493  for (; Range.first != Range.second; ++Range.first)
494  Triplets.insert(Range.first->second);
495 
496  return Triplets;
497 }
498 
499 std::set< const CRDFNode * > CRDFGraph::getParentSubjects(const CRDFNode * pObject) const
500 {
501  std::set< const CRDFNode * > Nodes;
502 
503  Node2TripletConstRange Range = mObject2Triplet.equal_range(const_cast< CRDFNode * >(pObject));
504 
505  for (; Range.first != Range.second; ++Range.first)
506  Nodes.insert(Range.first->second.pSubject);
507 
508  return Nodes;
509 }
510 
512 {
513  while (removeEmptyNodes()) {};
514 }
515 
517 {
518  CRDFNode * pNode;
519 
520  std::map< std::string, CRDFNode * >::iterator it = mBlankNodeId2Node.begin();
521  std::map< std::string, CRDFNode * >::iterator end = mBlankNodeId2Node.end();
522 
523  std::set< CRDFNode * > ToBeRemoved;
524 
525  for (; it != end; ++it)
526  {
527  pNode = it->second;
528  size_t Edges =
529  mSubject2Triplet.count(pNode);
530 
531  if (Edges == 0 ||
532  (pNode->isBagNode() && Edges == 1))
533  ToBeRemoved.insert(pNode);
534  }
535 
536  std::set< CRDFNode * >::iterator itRemove = ToBeRemoved.begin();
537  std::set< CRDFNode * >::iterator endRemove = ToBeRemoved.end();
538 
539  for (; itRemove != endRemove; ++itRemove)
540  {
541  std::set< CRDFTriplet > Triplets = getIncomingTriplets(*itRemove);
542  std::set< CRDFTriplet >::const_iterator itTriplet = Triplets.begin();
543  std::set< CRDFTriplet >::const_iterator endTriplet = Triplets.end();
544 
545  if (itTriplet == endTriplet)
546  destroyUnreferencedNode(*itRemove);
547 
548  for (; itTriplet != endTriplet; ++itTriplet)
549  {
550  itTriplet->pSubject->removeEdge(itTriplet->Predicate,
551  itTriplet->pObject);
552  }
553  }
554 
555  return ToBeRemoved.size() > 0;
556 }
557 
559 {
560  // We make sure that all namespaces COPASI uses are known.
561  addNameSpace("CopasiMT", "http://www.copasi.org/RDF/MiriamTerms#");
562  addNameSpace("dcterms", "http://purl.org/dc/terms/");
563  addNameSpace("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#");
564  addNameSpace("vCard", "http://www.w3.org/2001/vcard-rdf/3.0#");
565 
566  std::vector< bool > Used(mPrefix2Namespace.size(), false);
567  std::vector< bool >::iterator itUsed;
568 
569  // We loop over all triplets
570  const_iterator it = mTriplets.begin();
571  const_iterator end = mTriplets.end();
572 
573  std::map< std::string, std::string >::iterator itNamespace;
574  std::map< std::string, std::string >::iterator endNamespace = mPrefix2Namespace.end();
575 
576  for (; it != end; ++it)
577  {
578  for (itNamespace = mPrefix2Namespace.begin(), itUsed = Used.begin();
579  itNamespace != endNamespace;
580  ++itNamespace, ++itUsed)
581  if (!*itUsed)
582  {
583  const std::string & Predicate = it->Predicate.getURI();
584 
585  if (Predicate.compare(0, itNamespace->second.length(), itNamespace->second) == 0)
586  {
587  *itUsed = true;
588  break;
589  }
590  }
591  }
592 
593  itNamespace = mPrefix2Namespace.begin();
594  itUsed = Used.begin();
595  std::vector< std::string > ToBeRemoved;
596 
597  for (itNamespace = mPrefix2Namespace.begin(), itUsed = Used.begin();
598  itNamespace != endNamespace;
599  ++itNamespace, ++itUsed)
600  if (!*itUsed)
601  ToBeRemoved.push_back(itNamespace->first);
602 
603  std::vector< std::string >::iterator itRemove = ToBeRemoved.begin();
604  std::vector< std::string >::iterator endRemove = ToBeRemoved.end();
605 
606  for (; itRemove != endRemove; ++itRemove)
607  mPrefix2Namespace.erase(*itRemove);
608 }
609 
611 {
612  // We only can remove nodes which are no longer objects.
613  if (mObject2Triplet.count(pNode) > 0)
614  return;
615 
616  // Remove all triplets where the node is subject
617  std::pair< Node2Triplet::iterator, Node2Triplet::iterator> Range = mSubject2Triplet.equal_range(pNode);
618  std::set< CRDFTriplet > RemoveTriplets;
619 
620  for (; Range.first != Range.second; ++Range.first)
621  RemoveTriplets.insert(Range.first->second);
622 
623  std::set< CRDFTriplet >::const_iterator itTriplet = RemoveTriplets.begin();
624  std::set< CRDFTriplet >::const_iterator endTriplet = RemoveTriplets.end();
625 
626  for (; itTriplet != endTriplet; ++itTriplet)
627  itTriplet->pSubject->removeEdge(itTriplet->Predicate, itTriplet->pObject);
628 
629  // Remove the object from the appropriate container.
630  switch (pNode->getObject().getType())
631  {
633 
634  if (pNode->getObject().isLocal())
635  mLocalResource2Node.erase(pNode->getObject().getResource());
636  else
637  {
638  // Check whether the pointer still exists mRemoteResourceNodes
639  std::vector< CRDFNode * >::iterator it = mRemoteResourceNodes.begin();
640  std::vector< CRDFNode * >::iterator end = mRemoteResourceNodes.end();
641 
642  for (; it != end; ++it)
643  if (pNode == *it)
644  {
645  mRemoteResourceNodes.erase(it);
646  break;
647  }
648  }
649 
650  break;
651 
653  mBlankNodeId2Node.erase(pNode->getObject().getBlankNodeID());
654  break;
655 
656  case CRDFObject::LITERAL:
657  {
658  // Check whether the pointer still exists in mLiteralNodes
659  std::vector< CRDFNode * >::iterator it = mLiteralNodes.begin();
660  std::vector< CRDFNode * >::iterator end = mLiteralNodes.end();
661 
662  for (; it != end; ++it)
663  if (pNode == *it)
664  {
665  mLiteralNodes.erase(it);
666  break;
667  }
668  }
669  break;
670  }
671 
672  // Finally delete the object
673  delete pNode;
674 }
675 
676 // The next two methods are coded here to allows for easier debugging of the calls
677 // to the private methods addTriplet and removeTriplet from its only friends.
678 bool CRDFNode::addTripletToGraph(const CRDFTriplet & triplet) const
679 {
680  return mGraph.addTriplet(triplet);
681 }
682 
684 {
685  mGraph.removeTriplet(triplet);
686 }
const std::map< std::string, CRDFNode * > & getBlankNodeMap() const
Definition: CRDFGraph.cpp:88
CRDFNode * createAboutNode(const std::string &key)
Definition: CRDFGraph.cpp:416
Node2Triplet mSubject2Triplet
Definition: CRDFGraph.h:293
bool removeEmptyNodes()
Definition: CRDFGraph.cpp:516
#define pdelete(p)
Definition: copasi.h:215
const std::string & getResource() const
Definition: CRDFSubject.cpp:82
CRDFNode * mpAbout
Definition: CRDFGraph.h:258
void removeTriplet(CRDFNode *pSubject, const CRDFPredicate &predicate, CRDFNode *pObject)
Definition: CRDFGraph.cpp:277
void updateNamespaces()
Definition: CRDFGraph.cpp:558
const eObjectType & getType() const
Definition: CRDFObject.cpp:85
const bool & isLocal() const
Definition: CRDFObject.cpp:97
CRDFNode * pSubject
Definition: CRDFTriplet.h:38
const std::string & getBlankNodeID() const
Definition: CRDFObject.cpp:103
const std::map< std::string, CRDFNode * > & getLocalResourceNodeMap() const
Definition: CRDFGraph.cpp:91
std::vector< CRDFNode * > mLiteralNodes
Definition: CRDFGraph.h:283
void setSubject(const CRDFSubject &subject)
Definition: CRDFNode.cpp:52
const CRDFSubject & getSubject() const
Definition: CRDFNode.cpp:69
const std::string & getBlankNodeID() const
Definition: CRDFSubject.cpp:91
std::set< const CRDFNode * > getParentSubjects(const CRDFNode *pObject) const
Definition: CRDFGraph.cpp:499
CRDFGraph & mGraph
Definition: CRDFNode.h:231
bool isBagNode() const
Definition: CRDFNode.cpp:423
static ePredicateType getPredicateFromURI(const std::string &URI)
std::map< std::string, CRDFNode * > mBlankNodeId2Node
Definition: CRDFGraph.h:268
CRDFTriplet moveTriplet(CRDFNode *pNewSubject, const CRDFTriplet &triplet)
Definition: CRDFGraph.cpp:334
bool guessGraphRoot(const std::string &about=" ")
Definition: CRDFGraph.cpp:97
const std::vector< CRDFNode * > & getRemoteResourceNodes() const
Definition: CRDFGraph.cpp:94
std::map< std::string, std::string > mPrefix2Namespace
Definition: CRDFGraph.h:263
std::set< CRDFTriplet > getIncomingTriplets(const CRDFNode *pObject) const
Definition: CRDFGraph.cpp:487
Node2Triplet mObject2Triplet
Definition: CRDFGraph.h:298
CRDFObject & getObject()
Definition: CRDFNode.cpp:94
CRDFTriplet addTriplet(const CRDFSubject &subject, const CRDFPredicate &predicate, const CRDFObject &object)
Definition: CRDFGraph.cpp:141
const std::set< CRDFTriplet > & getTriplets() const
Definition: CRDFGraph.cpp:434
CRDFPredicate::Path getPredicatePath(const CRDFNode *pNode)
Definition: CRDFGraph.cpp:349
void setResource(const std::string &resource, const bool &isLocal)
Definition: CRDFSubject.cpp:76
#define MCAnnotation
std::set< unsigned int > mGeneratedIds
Definition: CRDFGraph.h:308
std::pair< Node2Triplet::iterator, Node2Triplet::iterator > Node2TripletRange
Definition: CRDFGraph.h:43
bool isSubjectNode() const
Definition: CRDFNode.cpp:414
std::map< std::string, CRDFNode * > mLocalResource2Node
Definition: CRDFGraph.h:273
const std::map< std::string, std::string > & getNameSpaceMap() const
Definition: CRDFGraph.cpp:85
Predicate2Triplet mPredicate2Triplet
Definition: CRDFGraph.h:303
std::set< CRDFTriplet > mTriplets
Definition: CRDFGraph.h:288
CRDFPredicate Predicate
Definition: CRDFTriplet.h:40
void removeEdge(const CRDFPredicate &predicate, CRDFNode *pObject)
Definition: CRDFNode.cpp:361
bool addNameSpace(const std::string &prefix, const std::string &uri)
Definition: CRDFGraph.cpp:128
void setResource(const std::string &resource, const bool &isLocal)
Definition: CRDFObject.cpp:88
bool isObjectNode() const
Definition: CRDFNode.cpp:417
const std::string & getURI() const
const bool & isLocal() const
Definition: CRDFSubject.cpp:85
std::map< std::string, std::string > mIdMap
Definition: CRDFGraph.h:313
void clean()
Definition: CRDFGraph.cpp:511
const CRDFNode * getAboutNode() const
Definition: CRDFGraph.cpp:82
std::vector< CRDFNode * > mRemoteResourceNodes
Definition: CRDFGraph.h:278
std::pair< Node2Triplet::const_iterator, Node2Triplet::const_iterator > Node2TripletConstRange
Definition: CRDFGraph.h:44
std::pair< Predicate2Triplet::const_iterator, Predicate2Triplet::const_iterator > Predicate2TripletConstRange
Definition: CRDFGraph.h:48
void setObject(const CRDFObject &object)
Definition: CRDFNode.cpp:77
void destroyUnreferencedNode(CRDFNode *pNode)
Definition: CRDFGraph.cpp:610
void setType(const eSubjectType &type)
Definition: CRDFSubject.cpp:70
std::string generatedNodeId(const std::string &existingId="")
Definition: CRDFGraph.cpp:380
CRDFNode * pObject
Definition: CRDFTriplet.h:42
CRDFTriplet addEdge(const CRDFPredicate &predicate, CRDFNode *pObject)
Definition: CRDFNode.cpp:321
std::vector< ePredicateType > Path
Definition: CRDFPredicate.h:91
const std::string & getResource() const
Definition: CRDFObject.cpp:94
const eSubjectType & getType() const
Definition: CRDFSubject.cpp:73
std::set< CRDFTriplet >::const_iterator const_iterator
Definition: CRDFGraph.h:40
bool addTripletToGraph(const CRDFTriplet &triplet) const
Definition: CRDFGraph.cpp:678
void removeTripletFromGraph(const CRDFTriplet &triplet) const
Definition: CRDFGraph.cpp:683