COPASI API  4.16.103
CRDFPredicate.cpp
Go to the documentation of this file.
1 // Begin CVS Header
2 // $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/MIRIAM/CRDFPredicate.cpp,v $
3 // $Revision: 1.10 $
4 // $Name: $
5 // $Author: shoops $
6 // $Date: 2011/03/07 19:30:19 $
7 // End CVS Header
8 
9 // Copyright (C) 2011 - 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 #include "copasi.h"
20 
21 #include "CRDFPredicate.h"
22 
23 // static
24 const std::string CRDFPredicate::PredicateURI[] =
25 {
26  /* These are proposed to replace:
27  * http://biomodels.net/biology-qualifiers/...
28  * http://biomodels.net/model-qualifiers/...
29  */
30  "http://www.copasi.org/RDF/MiriamTerms#encodes", // copasi_encodes
31  "http://www.copasi.org/RDF/MiriamTerms#hasPart", // copasi_hasPart
32  "http://www.copasi.org/RDF/MiriamTerms#hasVersion", // copasi_hasVersion
33  "http://www.copasi.org/RDF/MiriamTerms#is", // copasi_is
34  "http://www.copasi.org/RDF/MiriamTerms#isDescribedBy", // copasi_isDescribedBy
35  "http://www.copasi.org/RDF/MiriamTerms#isEncodedBy", // copasi_isEncodedBy
36  "http://www.copasi.org/RDF/MiriamTerms#isHomologTo", // copasi_isHomologTo
37  "http://www.copasi.org/RDF/MiriamTerms#isPartOf", // copasi_isPartOf
38  "http://www.copasi.org/RDF/MiriamTerms#isVersionOf", // copasi_isVersionOf
39  "http://www.copasi.org/RDF/MiriamTerms#occursIn", // copasi_occursIn
40  // "http://www.copasi.org/RDF/MiriamTerms#modification", // copasi_modification
41  "http://biomodels.net/biology-qualifiers/encodes", // bqbiol_encodes
42  "http://biomodels.net/biology-qualifiers/hasPart", // bqbiol_hasPart
43  "http://biomodels.net/biology-qualifiers/hasVersion", // bqbiol_hasVersion
44  "http://biomodels.net/biology-qualifiers/is", // bqbiol_is
45  "http://biomodels.net/biology-qualifiers/isDescribedBy", // bqbiol_isDescribedBy
46  "http://biomodels.net/biology-qualifiers/isEncodedBy", // bqbiol_isEncodedBy
47  "http://biomodels.net/biology-qualifiers/isHomologTo", // bqbiol_isHomologTo
48  "http://biomodels.net/biology-qualifiers/isPartOf", // bqbiol_isPartOf
49  "http://biomodels.net/biology-qualifiers/isVersionOf", // bqbiol_isVersionOf
50  "http://biomodels.net/biology-qualifiers/occursIn", // copasi_occursIn
51  "http://biomodels.net/model-qualifiers/is", // bqmodel_is
52  "http://biomodels.net/model-qualifiers/isDescribedBy", // bqmodel_isDescribedBy
53  "http://purl.org/dc/elements/1.1/creator", // dc_creator
54  "http://purl.org/dc/terms/creator", // dcterms_creator
55  "http://purl.org/dc/terms/bibliographicCitation", // dcterms_bibliographicCitation
56  // "http://purl.org/dc/terms/contributor", // dcterms_contributor
57  "http://purl.org/dc/terms/created", // dcterms_created
58  "http://purl.org/dc/terms/description", // dcterms_description,
59  // "http://purl.org/dc/terms/license", // dcterms_license
60  "http://purl.org/dc/terms/modified", // dcterms_modified
61  // "http://purl.org/dc/terms/rights", // dcterms_rights
62  // "http://purl.org/dc/terms/rightsHolder", // dcterms_rightsHolder
63  "http://purl.org/dc/terms/W3CDTF", // dcterms_W3CDTF
64  "http://www.w3.org/2001/vcard-rdf/3.0#EMAIL", // vcard_EMAIL
65  "http://www.w3.org/2001/vcard-rdf/3.0#Family", // vcard_Family
66  "http://www.w3.org/2001/vcard-rdf/3.0#Given", // vcard_Given
67  "http://www.w3.org/2001/vcard-rdf/3.0#N", // vcard_N
68  "http://www.w3.org/2001/vcard-rdf/3.0#ORG", // vcard_ORG
69  "http://www.w3.org/2001/vcard-rdf/3.0#Orgname", // vcard_Orgname
70  "http://www.w3.org/1999/02/22-rdf-syntax-ns#type", // rdf_type,
71  "http://www.w3.org/1999/02/22-rdf-syntax-ns#li", // rdf_li
72  "http://www.w3.org/1999/02/22-rdf-syntax-ns#_", // rdf__n
73  "http://www.w3.org/1999/02/22-rdf-syntax-ns#subject", //rdf_subject
74  "http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate", //rdf_predicate
75  "http://www.w3.org/1999/02/22-rdf-syntax-ns#object", //rdf_object
76  "", // unknown
77  // For internal use
78  "about", // about
79  "any", // any
80  "end" // end
81 };
82 
83 // static
84 std::map< std::string, CRDFPredicate::ePredicateType > CRDFPredicate::URI2Predicate;
85 
86 // static
88 {
89  int Predicate = 0;
90 
91  for (; PredicateURI[Predicate] != "end"; Predicate++)
92  URI2Predicate[PredicateURI[Predicate]] = (ePredicateType) Predicate;
93 
94  URI2Predicate[PredicateURI[Predicate]] = (ePredicateType) Predicate;
95 
96  // Now we now the number of supported predicates.
99 }
100 
101 // static
102 const std::string CRDFPredicate::PredicateDisplayName[] =
103 {
104  /* These are proposed to replace:
105  * http://biomodels.net/biology-qualifiers/...
106  * http://biomodels.net/model-qualifiers/...
107  */
108  "encodes", // copasi_encodes
109  "has part", // copasi_hasPart
110  "has version", // copasi_hasVersion
111  "is", // copasi_is
112  "is described by", // copasi_isDescribedBy
113  "is encoded by", // copasi_isEncodedBy
114  "is homolog to", // copasi_isHomologTo
115  "is part of", // copasi_isPartOf
116  "is version of", // copasi_isVersionOf
117  "occurs in", // copasi_occursIn
118  // "modification", // copasi_modification
119  "encodes", // bqbiol_encodes
120  "has part", // bqbiol_hasPart
121  "has version", // bqbiol_hasVersion
122  "is", // bqbiol_is
123  "is described by", // bqbiol_isDescribedBy
124  "is encoded by", // bqbiol_isEncodedBy
125  "is homolog to", // bqbiol_isHomologTo
126  "is part of", // bqbiol_isPartOf
127  "is version of", // bqbiol_isVersionOf
128  "occurs in", // bqbiol_occursIn
129  "is", // bqmodel_is
130  "is described by", // bqmodel_isDescribedBy
131  "creator", // dc_creator
132  "creator", // dcterms_creator
133  "bibliographic citation", // dcterms_bibliographicCitation
134  // "contributor", // dcterms_contributor
135  "created at", // dcterms_created
136  "description", // dcterms_description
137  // "license", // dcterms_license
138  "modified at", // dcterms_modified
139  // "rights", // dcterms_rights
140  // "rights holder", // dcterms_rightsHolder
141  "date", // dcterms_W3CDTF
142  "EMAIL", // vcard_EMAIL
143  "family name", // vcard_Family
144  "given name", // vcard_Given
145  "name", // vcard_N
146  "organization", // vcard_ORG
147  "name", // vcard_Orgname
148  "type", // rdf_type,
149  "*", // rdf_li
150  "*", // rdf__n
151  "subject", // rdf_subject,
152  "predicate", // rdf_predicate,
153  "object", // rdf_object
154  "", // unknown
155  // For internal use
156  "about", // about
157  "any", // any
158  "end" // end
159 };
160 
161 // static
162 std::map< std::string, CRDFPredicate::ePredicateType > CRDFPredicate::DisplayName2Predicate;
163 
164 // static
166 {
167  int Predicate = 0;
168 
169  for (; PredicateDisplayName[Predicate] != "end"; Predicate++)
170  DisplayName2Predicate.insert(std::map< std::string, ePredicateType >::value_type(PredicateDisplayName[Predicate], (ePredicateType) Predicate));
171 
172  DisplayName2Predicate.insert(std::map< std::string, ePredicateType >::value_type(PredicateDisplayName[Predicate], (ePredicateType) Predicate));
173 }
174 
175 // static
176 std::vector< CRDFPredicate::AllowedLocationList > CRDFPredicate::Predicate2AllowedLocationsRelative;
177 
178 // static
180 {
181  AllowedLocationList AboutUnboundedResource;
182  AboutUnboundedResource.resize(1);
183  AboutUnboundedResource[0].MaxOccurance = C_INVALID_INDEX;
184  AboutUnboundedResource[0].ReadOnly = false;
185  AboutUnboundedResource[0].Type = CRDFObject::RESOURCE;
186  AboutUnboundedResource[0].Location.resize(1);
187  AboutUnboundedResource[0].Location[0] = about;
188 
189  AllowedLocationList AboutOneLiteral;
190  AboutOneLiteral.resize(1);
191  AboutOneLiteral[0].MaxOccurance = 1;
192  AboutOneLiteral[0].ReadOnly = false;
193  AboutOneLiteral[0].Type = CRDFObject::LITERAL;
194  AboutOneLiteral[0].Location.resize(1);
195  AboutOneLiteral[0].Location[0] = about;
196 
197  /* These are proposed to replace:
198  * http://biomodels.net/biology-qualifiers/...
199  * http://biomodels.net/model-qualifiers/...
200  */
201  // copasi_encodes:
202  Predicate2AllowedLocationsRelative[copasi_encodes] = AboutUnboundedResource;
203 
204  // copasi_hasPart:
205  Predicate2AllowedLocationsRelative[copasi_hasPart] = AboutUnboundedResource;
206 
207  // copasi_hasVersion:
208  Predicate2AllowedLocationsRelative[copasi_hasVersion] = AboutUnboundedResource;
209 
210  // copasi_is:
211  Predicate2AllowedLocationsRelative[copasi_is] = AboutUnboundedResource;
212 
213  // copasi_isDescribedBy:
215  // *.dcterms_bibliographicCitation, *
222 
223  // copasi_isEncodedBy:
224  Predicate2AllowedLocationsRelative[copasi_isEncodedBy] = AboutUnboundedResource;
225 
226  // copasi_isHomologTo:
227  Predicate2AllowedLocationsRelative[copasi_isHomologTo] = AboutUnboundedResource;
228 
229  // copasi_isPartOf:
230  Predicate2AllowedLocationsRelative[copasi_isPartOf] = AboutUnboundedResource;
231 
232  // copasi_isVersionOf:
233  Predicate2AllowedLocationsRelative[copasi_isVersionOf] = AboutUnboundedResource;
234 
235  // copasi_occursIn:
236  Predicate2AllowedLocationsRelative[copasi_occursIn] = AboutUnboundedResource;
237 
238  /*
239  copasi_modification:
240  about, *
241  */
242 
243  // bq* is read only
244  AboutUnboundedResource[0].ReadOnly = true;
245 
246  // bqbiol_encodes:
247  Predicate2AllowedLocationsRelative[bqbiol_encodes] = AboutUnboundedResource;
248 
249  // bqbiol_hasPart:
250  Predicate2AllowedLocationsRelative[bqbiol_hasPart] = AboutUnboundedResource;
251 
252  // bqbiol_hasVersion:
253  Predicate2AllowedLocationsRelative[bqbiol_hasVersion] = AboutUnboundedResource;
254 
255  // bqbiol_is:
256  Predicate2AllowedLocationsRelative[bqbiol_is] = AboutUnboundedResource;
257 
258  // bqbiol_isDescribedBy:
260 
261  // bqbiol_isEncodedBy:
262  Predicate2AllowedLocationsRelative[bqbiol_isEncodedBy] = AboutUnboundedResource;
263 
264  // bqbiol_isHomologTo:
265  Predicate2AllowedLocationsRelative[bqbiol_isHomologTo] = AboutUnboundedResource;
266 
267  // bqbiol_isPartOf:
268  Predicate2AllowedLocationsRelative[bqbiol_isPartOf] = AboutUnboundedResource;
269 
270  // bqbiol_isVersionOf:
271  Predicate2AllowedLocationsRelative[bqbiol_isVersionOf] = AboutUnboundedResource;
272 
273  // bqbiol_occursIn:
274  Predicate2AllowedLocationsRelative[bqbiol_occursIn] = AboutUnboundedResource;
275 
276  // bqmodel_is:
277  Predicate2AllowedLocationsRelative[bqmodel_is] = AboutUnboundedResource;
278 
279  // bqmodel_isDescribedBy:
281 
282  // dc_creator:
283  Predicate2AllowedLocationsRelative[dc_creator] = AboutUnboundedResource;
285 
286  // change back to writable
287  AboutUnboundedResource[0].ReadOnly = false;
288 
289  // dcterms_creator:
290  Predicate2AllowedLocationsRelative[dcterms_creator] = AboutUnboundedResource;
292 
293  // dcterms_bibliographicCitation:
295  // about, *
301  // *.copasi_modification, *
302  // Predicate2AllowedLocationsRelative[dcterms_bibliographicCitation][1].MaxOccurance = C_INVALID_INDEX;
303  // Predicate2AllowedLocationsRelative[dcterms_bibliographicCitation][1].ReadOnly = false;
304  // Predicate2AllowedLocationsRelative[dcterms_bibliographicCitation][1].Type = CRDFObject::BLANK_NODE;
305  // Predicate2AllowedLocationsRelative[dcterms_bibliographicCitation][1].Location.resize(2);
306  // Predicate2AllowedLocationsRelative[dcterms_bibliographicCitation][1].Location[0] = any;
307  // Predicate2AllowedLocationsRelative[dcterms_bibliographicCitation][1].Location[1] = copasi_modification;
308 
309  // dcterms_contributor:
310  // Predicate2AllowedLocationsRelative[dcterms_modified].resize(1);
311  // *.copasi_modification, *
312  // Predicate2AllowedLocationsRelative[dcterms_modified][0].MaxOccurance = C_INVALID_INDEX;
313  // Predicate2AllowedLocationsRelative[dcterms_modified][0].ReadOnly = false;
314  // Predicate2AllowedLocationsRelative[dcterms_modified][0].Type = CRDFObject::BLANK_NODE;
315  // Predicate2AllowedLocationsRelative[dcterms_modified][0].Location.resize(2);
316  // Predicate2AllowedLocationsRelative[dcterms_modified][0].Location[0] = any;
317  // Predicate2AllowedLocationsRelative[dcterms_modified][0].Location[1] = copasi_modification;
318 
319  // dcterms_created:
321  // about, 1
327 
328  // dcterms_description
330  // bibliographicCitation, 1
337 
338  // dcterms_license:
339  // Predicate2AllowedLocationsRelative[dcterms_license] = AboutOneLiteral;
340 
341  // dcterms_modified:
343  // about, *
349 
350  // *.copasi_modification, *
351  // Predicate2AllowedLocationsRelative[dcterms_modified][1].MaxOccurance = C_INVALID_INDEX;
352  // Predicate2AllowedLocationsRelative[dcterms_modified][1].ReadOnly = false;
353  // Predicate2AllowedLocationsRelative[dcterms_modified][1].Type = CRDFObject::BLANK_NODE;
354  // Predicate2AllowedLocationsRelative[dcterms_modified][1].Location.resize(2);
355  // Predicate2AllowedLocationsRelative[dcterms_modified][1].Location[0] = any;
356  // Predicate2AllowedLocationsRelative[dcterms_modified][1].Location[1] = copasi_modification;
357 
358  // dcterms_rights:
359  // Predicate2AllowedLocationsRelative[dcterms_rights] = AboutOneLiteral;
360 
361  // dcterms_rightsHolder:
362  // Predicate2AllowedLocationsRelative[dcterms_rights] = AboutOneLiteral;
363 
364  // dcterms_W3CDTF:
366  // *.dcterms_created, 1
370  Predicate2AllowedLocationsRelative[dcterms_W3CDTF][0].Location.resize(2);
373  // *.dcterms_modified, 1
377  Predicate2AllowedLocationsRelative[dcterms_W3CDTF][1].Location.resize(2);
380 
381  AllowedLocationList VCardOneBlankNode;
382  VCardOneBlankNode.resize(2);
383  // *.dcterms_creator, 1
384  VCardOneBlankNode[0].MaxOccurance = 1;
385  VCardOneBlankNode[0].ReadOnly = false;
386  VCardOneBlankNode[0].Type = CRDFObject::BLANK_NODE;
387  VCardOneBlankNode[0].Location.resize(2);
388  VCardOneBlankNode[0].Location[0] = any;
389  VCardOneBlankNode[0].Location[1] = dcterms_creator;
390  // *.dc_creator, 1
391  VCardOneBlankNode[1].MaxOccurance = 1;
392  VCardOneBlankNode[1].ReadOnly = true;
393  VCardOneBlankNode[1].Type = CRDFObject::BLANK_NODE;
394  VCardOneBlankNode[1].Location.resize(2);
395  VCardOneBlankNode[1].Location[0] = any;
396  VCardOneBlankNode[1].Location[1] = dc_creator;
397  // *.dcterms_contributor, 1
398  // VCardOneBlankNode[1].MaxOccurance = 1;
399  // VCardOneBlankNode[1].ReadOnly = false;
400  // VCardOneBlankNode[1].Type = CRDFObject::BLANK_NODE;
401  // VCardOneBlankNode[1].Location.resize(2);
402  // VCardOneBlankNode[1].Location[0] = any;
403  // VCardOneBlankNode[1].Location[1] = dcterms_contributor;
404 
405  // vcard_EMAIL:
406  Predicate2AllowedLocationsRelative[vcard_EMAIL] = VCardOneBlankNode;
407  // Override the default for vcard which is literal = true;
410 
411  // vcard_Family:
413  // *.vcard_N, 1
417  Predicate2AllowedLocationsRelative[vcard_Family][0].Location.resize(2);
420 
421  // vcard_Given:
423  // *.vcard_N, 1
424  Predicate2AllowedLocationsRelative[vcard_Given][0].MaxOccurance = 1;
425  Predicate2AllowedLocationsRelative[vcard_Given][0].ReadOnly = false;
427  Predicate2AllowedLocationsRelative[vcard_Given][0].Location.resize(2);
430 
431  // vcard_N:
432  Predicate2AllowedLocationsRelative[vcard_N] = VCardOneBlankNode;
433 
434  // vcard_ORG:
435  Predicate2AllowedLocationsRelative[vcard_ORG] = VCardOneBlankNode;
436 
437  // vcard_Orgname:
439  // *.vcard_ORG, 1
443  Predicate2AllowedLocationsRelative[vcard_Orgname][0].Location.resize(2);
446 }
447 
448 // static
449 std::vector< CRDFPredicate::AllowedLocationList > CRDFPredicate::Predicate2AllowedLocationsAbsolute;
450 
451 // static
453 {
454  size_t Predicate, PredicateMax = Predicate2AllowedLocationsRelative.size();
455 
456  for (Predicate = 0; Predicate < PredicateMax; Predicate++)
458 }
459 
460 // static
462 {
463  AllowedLocationList & RelativeList = Predicate2AllowedLocationsRelative[predicate];
464  AllowedLocationList & AbsoluteList = Predicate2AllowedLocationsAbsolute[predicate];
465 
466  // Since we are called recursively the absolute locations might already have been build.
467  if (AbsoluteList.size() > 0) return;
468 
469  sAllowedLocation Relative;
470 
471  size_t i, imax = RelativeList.size();
472 
473  for (i = 0; i < imax; i++)
474  {
475  sAllowedLocation & Relative = RelativeList[i];
476 
477  sAllowedLocation Absolute;
478  Absolute.MaxOccurance = Relative.MaxOccurance;
479  Absolute.Type = Relative.Type;
480 
481  // Debugging
482  assert(Relative.Location.size() > 0);
483 
484  ePredicateType Parent = Relative.Location[0];
485  size_t StartIndex = 0;
486 
487  // about is the root, i.e., the path is absolute
488  if (Parent == about)
489  {
490  Absolute.ReadOnly = Relative.ReadOnly;
491  Absolute.Location = Relative.Location;
492 
493  // Add the predicate itself.
494  Absolute.Location.push_back(predicate);
495  AbsoluteList.push_back(Absolute);
496 
497  continue;
498  }
499 
500  if (Parent == any)
501  {
502  // Debugging
503  assert(Relative.Location.size() > 1);
504  Parent = Relative.Location[1];
505  StartIndex = 1;
506  }
507 
508  // Make sure that the absolute path of the parent is known
511 
512  // For each parent path append the relative path
513  size_t j, jmax = ParentList.size();
514 
515  for (j = 0; j < jmax; j++)
516  {
517  Absolute.ReadOnly = ParentList[j].ReadOnly || Relative.ReadOnly;
518  Absolute.Location = ParentList[j].Location;
519 
520  size_t k, kmax = Relative.Location.size();
521 
522  for (k = StartIndex + 1; k < kmax; k++)
523  Absolute.Location.push_back(Relative.Location[k]);
524 
525  // Add the predicate itself.
526  Absolute.Location.push_back(predicate);
527  AbsoluteList.push_back(Absolute);
528  }
529  }
530 }
531 
533 {
534  static bool Initialized = false;
535 
536  if (Initialized)
537  return;
538 
539  Initialized = true;
540 
541  // Fill URI2Predicate
543 
544  // Fill DisplayName2Predicate
546 
547  // Fill relative allowed locations
549 
550  // Fill relative allowed locations
552 }
553 
554 // Methods
556  mType(type),
557  mURI()
558 {
559  initialize();
561 }
562 
563 CRDFPredicate::CRDFPredicate(const std::string & uri):
564  mType(),
565  mURI(uri)
566 {
567  initialize();
569 
570  if (mType == rdf_li)
572 }
573 
575  mType(src.mType),
576  mURI(src.mURI)
577 {}
578 
580 {}
581 
583 {return CRDFPredicate(type);}
584 
586 {return mType;}
587 
588 void CRDFPredicate::setURI(const std::string & uri)
589 {
590  mType = getPredicateFromURI(uri);
591 
592  if (mType == rdf_li)
594  else
595  mURI = uri;
596 }
597 
598 const std::string & CRDFPredicate::getURI() const
599 {return mURI;}
600 
602 {return mURI == rhs.mURI;}
603 
605 {return mURI != rhs.mURI;}
606 
608 {return mURI < rhs.mURI;}
609 
610 // friend
611 std::ostream & operator << (std::ostream & os, const CRDFPredicate & p)
612 {
613  os << p.mType;
614  return os;
615 }
616 
617 // static
619 {
620  return Predicate2AllowedLocationsAbsolute[predicate];
621 }
622 
623 // static
624 const std::string & CRDFPredicate::getURI(const CRDFPredicate & predicate)
625 {
626  return PredicateURI[predicate.mType];
627 }
628 
629 // static
631 {
632  std::map< std::string, ePredicateType >::iterator it = URI2Predicate.find(URI);
633 
634  if (it != URI2Predicate.end())
635  return it->second;
636  // Handle rdf:_n and map it to rdf:li
637  else if (URI.compare(0, PredicateURI[rdf__n].length(), PredicateURI[rdf__n]) == 0)
638  return rdf_li;
639  else
640  return unknown;
641 }
642 
643 // static
644 const std::string & CRDFPredicate::getDisplayName(const CRDFPredicate & predicate)
645 {
646  return PredicateDisplayName[predicate.mType];
647 }
648 
649 // static
651 {
652  std::map< std::string, ePredicateType >::iterator it = DisplayName2Predicate.find(displayName);
653 
654  if (it != DisplayName2Predicate.end())
655  return it->second;
656  else
657  return unknown;
658 }
659 
660 // static
662  const CRDFPredicate::Path & currentPath)
663 {
664  // If the current path is longer than the full path we fail
665  if (currentPath.size() > fullPath.size())
666  return C_INVALID_INDEX;
667 
668  // Check whether the current path is part of the full path;
669  Path::const_iterator itCurrent = currentPath.begin();
670  Path::const_iterator endCurrent = currentPath.end();
671  Path::const_iterator itFull = fullPath.begin();
672 
673  for (; itCurrent != endCurrent; ++itCurrent, ++itFull)
674  if (*itCurrent != *itFull)
675  return C_INVALID_INDEX;
676 
677  return currentPath.size();
678 }
679 
680 // static
681 bool CRDFPredicate::isReadOnly(const Path & currentPath)
682 {
683  // Iterate over each predicate
684  std::vector< AllowedLocationList >::const_iterator itPredicate = Predicate2AllowedLocationsAbsolute.begin();
685  std::vector< AllowedLocationList >::const_iterator endPredicate = Predicate2AllowedLocationsAbsolute.end();
686 
687  for (; itPredicate != endPredicate; ++itPredicate)
688  {
689  // Iterate over each location
690  AllowedLocationList::const_iterator itLocation = itPredicate->begin();
691  AllowedLocationList::const_iterator endLocation = itPredicate->end();
692 
693  for (; itLocation != endLocation; ++itLocation)
694  if (itLocation->ReadOnly &&
695  currentPath.size() == itLocation->Location.size())
696  {
697  // Compare the path.
698  Path::const_iterator itCurrent = currentPath.begin();
699  Path::const_iterator endCurrent = currentPath.end();
700  Path::const_iterator itAbsolute = itLocation->Location.begin();
701 
702  for (; itCurrent != endCurrent; ++itCurrent, ++itAbsolute)
703  if (*itCurrent != *itAbsolute)
704  break;
705 
706  if (itCurrent == endCurrent)
707  return true;
708  }
709  }
710 
711  return false;
712 }
713 
714 std::ostream & operator << (std::ostream & os, const CRDFPredicate::Path & path)
715 {
716  os << "Path: ";
717  std::vector< CRDFPredicate::ePredicateType >::const_iterator it = path.begin();
718  std::vector< CRDFPredicate::ePredicateType >::const_iterator end = path.end();
719 
720  for (; it != end; ++it)
721  os << *it << " ";
722 
723  return os << std::endl;
724 }
725 
726 std::ostream & operator << (std::ostream & os, const CRDFPredicate::sAllowedLocation & location)
727 {
728  os << "MaxOccurance: " << location.MaxOccurance << std::endl;
729  os << "ReadOnly: " << location.ReadOnly << std::endl;
730  os << "Type: " << location.Type << std::endl;
731  os << location.Location << std::endl;
732 
733  return os;
734 }
std::string mURI
static bool isReadOnly(const Path &currentPath)
bool operator!=(const CRDFPredicate &rhs) const
std::ostream & operator<<(std::ostream &os, const CRDFPredicate &p)
static ePredicateType getPredicateFromDisplayName(const std::string &displayName)
bool operator==(const CRDFPredicate &rhs) const
std::vector< sAllowedLocation > AllowedLocationList
static std::map< std::string, ePredicateType > DisplayName2Predicate
#define C_INVALID_INDEX
Definition: copasi.h:222
static ePredicateType getPredicateFromURI(const std::string &URI)
ePredicateType mType
static const std::string PredicateURI[]
static void createURI2Predicate()
CRDFObject::eObjectType Type
Definition: CRDFPredicate.h:98
static void createAllowedLocationsRelative()
static void createAllowedLocationsAbsolute()
CRDFPredicate operator=(const ePredicateType &type)
static const std::string & getDisplayName(const CRDFPredicate &predicate)
static size_t getSubPathIndex(const Path &fullPath, const Path &currentPath)
static std::vector< AllowedLocationList > Predicate2AllowedLocationsRelative
static const AllowedLocationList & getAllowedLocationList(const ePredicateType &predicate)
bool operator<(const CRDFPredicate &rhs) const
static std::map< std::string, ePredicateType > URI2Predicate
const std::string & getURI() const
void setURI(const std::string &uri)
static std::vector< AllowedLocationList > Predicate2AllowedLocationsAbsolute
if(!yymsg) yymsg
static void createDisplayName2Predicate()
std::vector< ePredicateType > Path
Definition: CRDFPredicate.h:91
static void initialize()
CRDFPredicate(const ePredicateType &type=end)
static const std::string PredicateDisplayName[]
const ePredicateType & getType() const