COPASI API  4.16.103
CRDFNode.h
Go to the documentation of this file.
1 // Begin CVS Header
2 // $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/MIRIAM/CRDFNode.h,v $
3 // $Revision: 1.14 $
4 // $Name: $
5 // $Author: shoops $
6 // $Date: 2010/07/16 19:00:06 $
7 // End CVS Header
8 
9 // Copyright (C) 2010 by Pedro Mendes, Virginia Tech Intellectual
10 // Properties, Inc., University of Heidelberg, and The University
11 // of Manchester.
12 // All rights reserved.
13 
14 // Copyright (C) 2008 by Pedro Mendes, Virginia Tech Intellectual
15 // Properties, Inc., EML Research, gGmbH, University of Heidelberg,
16 // and The University of Manchester.
17 // All rights reserved.
18 
19 // Copyright (C) 2001 - 2007 by Pedro Mendes, Virginia Tech Intellectual
20 // Properties, Inc. and EML Research, gGmbH.
21 // All rights reserved.
22 
23 #ifndef COPASI_CRDFNode
24 #define COPASI_CRDFNode
25 
26 #include <string>
27 #include <map>
28 #include <vector>
29 #include <set>
30 
32 
33 class CRDFGraph;
34 class CRDFSubject;
35 class CRDFObject;
37 
38 class CRDFNode
39 {
40  // Operations
41 private:
42  /**
43  * Default Constructor
44  */
45  CRDFNode();
46 
47  CRDFNode(const CRDFNode & CRDFNode);
48 
49  CRDFNode & operator = (const CRDFNode & rhs);
50 
51 public:
52  /**
53  * Specific Constructor
54  * @param CRDFGraph & graph
55  */
56  CRDFNode(CRDFGraph & graph);
57 
58  /**
59  * Destructor
60  */
61  ~CRDFNode();
62 
63  /**
64  * Set the Id of the node
65  * @param const std::string & id
66  */
67  void setId(const std::string & id);
68 
69  /**
70  * Retrieve the Id of the node
71  * @return const std::string & id
72  */
73  const std::string & getId() const;
74 
75  /**
76  * Set the subject data of the node
77  * @param const CRDFSubject & subject
78  */
79  void setSubject(const CRDFSubject & subject);
80 
81  /**
82  * Retrieve the subject data of the node. It is recommended to
83  * call isSubjectNode before retrieving the subject.
84  * @return const CRDFSubject & subject
85  */
86  const CRDFSubject & getSubject() const;
87 
88  /**
89  * Set the object data of the node
90  * @param const CRDFObject & object
91  */
92  void setObject(const CRDFObject & object);
93 
94  /**
95  * Retrieve the object data of the node. It is recommended to
96  * call isObjectNode before retrieving the object.
97  * @return CRDFObject & object
98  */
100 
101  /**
102  * Retrieve the object data of the node. It is recommended to
103  * call isObjectNode before retrieving the object.
104  * @return const CRDFObject & object
105  */
106  const CRDFObject & getObject() const;
107 
108  /**
109  * Retrieve a predicate path to the node.
110  * @return CRDFPredicate::Path path
111  */
113 
114  /**
115  * Retrieve the string representation of the property predicate
116  * @param const CRDFPredicate::ePredicateType & predicate
117  * @return const std::string & fieldValue
118  */
119  const std::string & getFieldValue(const CRDFPredicate::ePredicateType & predicate) const;
120 
121  /**
122  * Set the field value for the property predicate
123  * @param const CMIRIAMResource & value
124  * @param const CRDFPredicate::ePredicateType & predicate
125  * @param const CRDFPredicate::Path & nodePath
126  * @return bool success
127  */
128  bool setFieldValue(const CMIRIAMResourceObject & value,
129  const CRDFPredicate::ePredicateType & predicate,
130  const CRDFPredicate::Path & nodePath);
131 
132  /**
133  * Set the field value for the property predicate
134  * @param const std::string & value
135  * @param const CRDFPredicate::ePredicateType & predicate
136  * @param const CRDFPredicate::Path & nodePath
137  * @return bool success
138  */
139  bool setFieldValue(const std::string & value,
140  const CRDFPredicate::ePredicateType & predicate,
141  const CRDFPredicate::Path & nodePath);
142 
143  /**
144  * Add a property edge to the node.
145  * @param const CRDFPredicate & edge
146  * @param CRDFNode * pObject
147  * @return CRDFTriplet triplet
148  */
149  CRDFTriplet addEdge(const CRDFPredicate & predicate, CRDFNode * pObject);
150 
151  /**
152  * This method is for internal use only.
153  * The method is declared public since friend declarations may not refer to public methods.
154  * @param const CRDFTriplet & triplet
155  * @return bool success.
156  */
157  bool addTripletToGraph(const CRDFTriplet & triplet) const;
158 
159  /**
160  * Remove a property edge from the node.
161  * @param const CRDFPredicate & edge
162  * @param CRDFNode * pObject
163  * @return bool success
164  */
165  void removeEdge(const CRDFPredicate & predicate, CRDFNode * pObject);
166 
167  /**
168  * This method is for internal use only.
169  * The method is declared public since friend declarations may not refer to public methods.
170  * @param const CRDFTriplet & triplet
171  */
172  void removeTripletFromGraph(const CRDFTriplet & triplet) const;
173 
174  /**
175  *
176  *
177  */
178  std::set< CRDFTriplet > getDescendantsWithPredicate(const CRDFPredicate & predicate) const;
179 
180  /**
181  * Check whether this is a subject node
182  * @return bool isSubjectNode
183  */
184  bool isSubjectNode() const;
185 
186  /**
187  * Check whether this is a object node
188  * @return bool isObjectNode
189  */
190  bool isObjectNode() const;
191 
192  /**
193  * Check whether this is a blank node
194  * @return bool isBlankNode
195  */
196  bool isBlankNode() const;
197 
198  /**
199  * Check whether this is a bag node
200  * @return isBagNode
201  */
202  bool isBagNode() const;
203 
204  /**
205  * Check whether the node is read only
206  * @return bool isReadOnly
207  */
208  bool isReadOnly() const;
209 
210  /**
211  * Check whether the given node is in the path, i.e., has the given node
212  * as an ancestor
213  * @param const CRDFNode * pNode
214  * @return bool hasAncestor
215  */
216  bool hasAncestor(const CRDFNode * pNode) const;
217 
218 private:
219  CRDFNode * createMissingAncestors(const CRDFPredicate::Path & nodePath,
220  const CRDFPredicate::ePredicateType & predicate,
221  CRDFPredicate::sAllowedLocation const *& pLocation);
222 
223  CRDFNode * createMissingAncestors(const CRDFPredicate::Path & predicatePath,
224  const size_t & level);
225 
226  // Attributes
227 private:
228  /**
229  * The graph in which the node is located.
230  */
232 
233  /**
234  * The Id of the node
235  */
236  std::string mId;
237 
238  /**
239  * A pointer to the subject if of type SUBJECT or BOTH
240  */
242 
243  /**
244  * A pointer to the object if of type OBJECT or BOTH
245  */
246  mutable CRDFObject * mpObject;
247 
248  /**
249  * Stores whether this is a blank node
250  */
252 };
253 
254 #endif // COPASI_CRDFNode
bool isBlankNode() const
Definition: CRDFNode.cpp:420
CRDFSubject * mpSubject
Definition: CRDFNode.h:241
CRDFObject * mpObject
Definition: CRDFNode.h:246
std::set< CRDFTriplet > getDescendantsWithPredicate(const CRDFPredicate &predicate) const
Definition: CRDFNode.cpp:398
void setSubject(const CRDFSubject &subject)
Definition: CRDFNode.cpp:52
const CRDFSubject & getSubject() const
Definition: CRDFNode.cpp:69
CRDFGraph & mGraph
Definition: CRDFNode.h:231
bool isBagNode() const
Definition: CRDFNode.cpp:423
const std::string & getId() const
Definition: CRDFNode.cpp:49
~CRDFNode()
Definition: CRDFNode.cpp:40
bool setFieldValue(const CMIRIAMResourceObject &value, const CRDFPredicate::ePredicateType &predicate, const CRDFPredicate::Path &nodePath)
Definition: CRDFNode.cpp:142
CRDFObject & getObject()
Definition: CRDFNode.cpp:94
CRDFPredicate::Path getPath() const
Definition: CRDFNode.cpp:110
bool hasAncestor(const CRDFNode *pNode) const
Definition: CRDFNode.cpp:442
bool isReadOnly() const
Definition: CRDFNode.cpp:436
bool isSubjectNode() const
Definition: CRDFNode.cpp:414
bool mIsBlankNode
Definition: CRDFNode.h:251
CRDFNode & operator=(const CRDFNode &rhs)
void removeEdge(const CRDFPredicate &predicate, CRDFNode *pObject)
Definition: CRDFNode.cpp:361
std::string mId
Definition: CRDFNode.h:236
void setId(const std::string &id)
Definition: CRDFNode.cpp:46
bool isObjectNode() const
Definition: CRDFNode.cpp:417
const std::string & getFieldValue(const CRDFPredicate::ePredicateType &predicate) const
Definition: CRDFNode.cpp:113
CRDFNode * createMissingAncestors(const CRDFPredicate::Path &nodePath, const CRDFPredicate::ePredicateType &predicate, CRDFPredicate::sAllowedLocation const *&pLocation)
Definition: CRDFNode.cpp:246
void setObject(const CRDFObject &object)
Definition: CRDFNode.cpp:77
CRDFTriplet addEdge(const CRDFPredicate &predicate, CRDFNode *pObject)
Definition: CRDFNode.cpp:321
std::vector< ePredicateType > Path
Definition: CRDFPredicate.h:91
bool addTripletToGraph(const CRDFTriplet &triplet) const
Definition: CRDFGraph.cpp:678
void removeTripletFromGraph(const CRDFTriplet &triplet) const
Definition: CRDFGraph.cpp:683