COPASI API  4.16.103
CRDFObject.cpp
Go to the documentation of this file.
1 // Begin CVS Header
2 // $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/MIRIAM/CRDFObject.cpp,v $
3 // $Revision: 1.8 $
4 // $Name: $
5 // $Author: shoops $
6 // $Date: 2008/06/10 20:31:11 $
7 // End CVS Header
8 
9 // Copyright (C) 2008 by Pedro Mendes, Virginia Tech Intellectual
10 // Properties, Inc., EML Research, gGmbH, University of Heidelberg,
11 // and The University of Manchester.
12 // All rights reserved.
13 
14 // Copyright (C) 2001 - 2007 by Pedro Mendes, Virginia Tech Intellectual
15 // Properties, Inc. and EML Research, gGmbH.
16 // All rights reserved.
17 
18 #include "copasi.h"
19 
20 #include "CRDFObject.h"
21 #include "CRDFLiteral.h"
22 
24  mType(RESOURCE),
25  mResource(""),
26  mBlankNodeId(""),
27  mIsLocalResource(false),
28  mpLiteral(NULL)
29 {}
30 
32  mType(src.mType),
33  mResource(src.mResource),
34  mBlankNodeId(src.mBlankNodeId),
35  mIsLocalResource(src.mIsLocalResource),
36  mpLiteral(src.mpLiteral == NULL ? NULL : new CRDFLiteral(*src.mpLiteral))
37 {}
38 
40 {
41  if (this != &rhs)
42  {
43  mType = rhs.mType;
44  mResource = rhs.mResource;
47  mpLiteral = (rhs.mpLiteral == NULL ? NULL : new CRDFLiteral(*rhs.mpLiteral));
48  }
49  return *this;
50 }
51 
54 
55 bool CRDFObject::operator ==(const CRDFObject& rhs) const
56  {
57  if (mType == rhs.mType)
58  {
59  switch (mType)
60  {
62  if (mBlankNodeId == rhs.mBlankNodeId)
63  return true;
64  break;
65 
68  return true;
69  break;
70 
72  if (mpLiteral != NULL && rhs.mpLiteral != NULL)
73  return false; // TODO (*mpLiteral == *rhs.mpLiteral);
74  else if (mpLiteral == NULL && rhs.mpLiteral == NULL)
75  return true;
76  break;
77  }
78  }
79  return false;
80  }
81 
83 {mType = type;}
84 
86  {return mType;}
87 
88 void CRDFObject::setResource(const std::string & resource, const bool & isLocal)
89 {
90  mResource = resource;
92 }
93 
94 const std::string & CRDFObject::getResource() const
95  {return mResource;}
96 
97 const bool & CRDFObject::isLocal() const
98  {return mIsLocalResource;}
99 
100 void CRDFObject::setBlankNodeId(const std::string & blankNodeId)
101 {mBlankNodeId = blankNodeId;}
102 
103 const std::string & CRDFObject::getBlankNodeID() const
104  {return mBlankNodeId;}
105 
106 void CRDFObject::setLiteral(const CRDFLiteral & literal)
107 {
109  mpLiteral = new CRDFLiteral(literal);
110 }
111 
113 {
114  if (mpLiteral == NULL)
115  mpLiteral = new CRDFLiteral;
116 
117  return *mpLiteral;
118 }
119 
121  {
122  if (mpLiteral == NULL)
123  mpLiteral = new CRDFLiteral;
124 
125  return *mpLiteral;
126  }
127 
129 {
130  mType = RESOURCE;
131  mResource = "";
132  mBlankNodeId = "";
133  mIsLocalResource = false;
134  mpLiteral = NULL;
135 }
136 
137 std::ostream & operator << (std::ostream & os, const CRDFObject & object)
138 {
139  switch (object.getType())
140  {
142  os << object.getBlankNodeID();
143  break;
144 
146  os << object.getResource();
147  break;
148 
149  case CRDFObject::LITERAL:
150  os << object.getLiteral();
151  break;
152  }
153 
154  return os;
155 }
#define pdelete(p)
Definition: copasi.h:215
CRDFLiteral * mpLiteral
Definition: CRDFObject.h:149
const eObjectType & getType() const
Definition: CRDFObject.cpp:85
const bool & isLocal() const
Definition: CRDFObject.cpp:97
const std::string & getBlankNodeID() const
Definition: CRDFObject.cpp:103
bool operator==(const CRDFObject &rhs) const
Definition: CRDFObject.cpp:55
void clearData()
Definition: CRDFObject.cpp:128
void setLiteral(const CRDFLiteral &literal)
Definition: CRDFObject.cpp:106
bool mIsLocalResource
Definition: CRDFObject.h:144
CRDFObject & operator=(const CRDFObject &rhs)
Definition: CRDFObject.cpp:39
virtual ~CRDFObject()
Definition: CRDFObject.cpp:52
eObjectType mType
Definition: CRDFObject.h:129
void setType(const eObjectType &type)
Definition: CRDFObject.cpp:82
std::string mBlankNodeId
Definition: CRDFObject.h:139
void setResource(const std::string &resource, const bool &isLocal)
Definition: CRDFObject.cpp:88
void setBlankNodeId(const std::string &blankNodeId)
Definition: CRDFObject.cpp:100
std::ostream & operator<<(std::ostream &os, const CRDFObject &object)
Definition: CRDFObject.cpp:137
std::string mResource
Definition: CRDFObject.h:134
const std::string & getResource() const
Definition: CRDFObject.cpp:94
CRDFLiteral & getLiteral()
Definition: CRDFObject.cpp:112