libNuML  1.1.1
Library for reading / writing NuML documents
OntologyTerm.h
Go to the documentation of this file.
1 /*
2 * ****************************************************************************
3 * This file is part of libNUML. Please visit http://code.google.com/p/numl/for more
4 * information about NUML, and the latest version of libNUML.
5 * Copyright (c) 2013 The University of Manchester.
6 *
7 * This library is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as published
9 * by the Free Software Foundation. A copy of the license agreement is
10 * provided in the file named "LICENSE.txt" included with this software
11 * distribution and also available online as http://www.gnu.org/licenses/lgpl.html
12 *
13 * Contributors:
14 * Joseph O. Dada, The University of Manchester - initial API and implementation
15 * ****************************************************************************
16 **/
17 
24 #ifndef ONTOLOGYTERM_H_
25 #define ONTOLOGYTERM_H_
26 
27 #include <numl/common/extern.h>
28 #include <numl/common/numlfwd.h>
29 
30 
31 
32 //#include <numl/NUMLVisitor.h>
33 #include <numl/NMBase.h>
34 #include <string>
35 
36 #include <numl/NUMLList.h>
37 
38 #ifdef __cplusplus
40 
41 /*
42  *
43  */
45 
46 public:
64  OntologyTerm (unsigned int level, unsigned int version);
65 
66 
95  OntologyTerm (NUMLNamespaces* numlns);
96 
104  virtual bool accept (NUMLVisitor& v) const;
105 
106 
112  virtual OntologyTerm* clone () const;
113 
119  const std::string& getId () const;
120 
121 
127  const std::string& getTerm () const;
128 
134  const std::string& getSourceTermId () const;
135 
141  const std::string& getOntologyURI () const;
142 
143 
144  virtual ~OntologyTerm();
145 
146  /*
147  *
148  * Sets the value of the "id" attribute of this NUML object.
149  *
150  * The string @p id is copied. Note that NUML has strict requirements
151  * for the syntax of identifiers. The following is summary of the
152  * definition of the NUML identifier type @c SId (here expressed in an
153  * extended form of BNF notation):
154  * @code
155  * letter ::= 'a'..'z','A'..'Z'
156  * digit ::= '0'..'9'
157  * idChar ::= letter | digit | '_'
158  * SId ::= ( letter | '_' ) idChar*
159  * @endcode
160  * The equality of NUML identifiers is determined by an exact character
161  * sequence match; i.e., comparisons must be performed in a
162  * case-sensitive manner. In addition, there are a few conditions for
163  * the uniqueness of identifiers in an NUML model. Please consult the
164  * NUML specifications for the exact formulations.
165  *
166  * @param id the string to use as the identifier of this object
167  *
168  * @return integer value indicating success/failure of the
169  * function. @if clike The value is drawn from the
170  * enumeration #OperationReturnValues_t. @endif The possible values
171  * returned by this function are:
172  * @li LIBNUML_OPERATION_SUCCESS
173  * @li LIBNUML_INVALID_ATTRIBUTE_VALUE
174  */
175  int setId (const std::string& sid);
176 
177 
192  int setTerm (const std::string& term);
193 
208  int setSourceTermId(const std::string& sourceTermId);
209 
224  int setOntologyURI(const std::string& ontologyURI);
225 
245  virtual NUMLTypeCode_t getTypeCode() const;
246 
253  virtual const std::string& getElementName() const;
254 
260  virtual void readAttributes(const LIBSBML_CPP_NAMESPACE_QUALIFIER XMLAttributes& attributes);
261 
262 
268  virtual void writeAttributes (LIBSBML_CPP_NAMESPACE_QUALIFIER XMLOutputStream& stream) const;
269 
270 protected:
271 
272 
273  OntologyTerm();
274 
275  std::string mId;
276  std::string mTerm;
277  std::string mSourceTermId;
278  std::string mOntologyURI;
279 
280  //std::vector<ONTOLOGY> mOntologies;
281 
282 
283 
284  /* the validator classes need to be friends to access the
285  * protected constructor that takes no arguments
286  */
287  friend class Validator;
288  friend class ConsistencyValidator;
289  friend class IdentifierConsistencyValidator;
290  friend class InternalConsistencyValidator;
291 
292 };
293 
294 //structure for recognised ontologies
295 struct ONTOLOGY {
296  std::string term;
297  std::string sourceTermId;
298  std::string ontologyURI;
299 };
301 {
302 public:
303 
309  virtual OntologyTerms* clone () const;
310 
311 
331  virtual NUMLTypeCode_t getTypeCode () const { return NUML_NUMLLIST; };
332 
333 
355  virtual NUMLTypeCode_t getItemTypeCode () const;
356 
357 
365  virtual const std::string& getElementName () const;
366 
376  virtual OntologyTerm * get(unsigned int n);
377 
378 
388  virtual const OntologyTerm * get(unsigned int n) const;
389 
390 
405  virtual OntologyTerm* get (const std::string& sid);
406 
407 
422  virtual const OntologyTerm* get (const std::string& sid) const;
423 
424 
435  virtual OntologyTerm* remove (unsigned int n);
436 
437 
450  virtual OntologyTerm* remove (const std::string& sid);
451 
452 
453 
467  virtual int getElementPosition () const;
468 
469 
470 
471 
472 protected:
473 
478  virtual NMBase* createObject (LIBSBML_CPP_NAMESPACE_QUALIFIER XMLInputStream& stream);
479 
480 
481 };
482 
483 
485 
486 #endif /* __cplusplus */
487 
488 #ifndef SWIG
489 
492 
493 //TODO
494 
497 
498 #endif /* !SWIG */
499 
500 #endif /* ONTOLOGYTERM_H_ */
This is the base class for all numl objects.
Definition: NMBase.h:70
Definition: OntologyTerm.h:300
Definition: NUMLTypeCodes.h:52
#define BEGIN_C_DECLS
Definition: extern.h:112
virtual NUMLTypeCode_t getItemTypeCode() const
Get the type code of the objects contained in this NUMLList.
Definition: NUMLList.cpp:361
virtual NMBase * createObject(LIBSBML_CPP_NAMESPACE_QUALIFIER XMLInputStream &stream)
Subclasses should override this method to create, store, and then return an NUML object corresponding...
Definition: NMBase.cpp:1714
virtual const std::string & getElementName() const
Returns the XML element name of this object, which for NUMLList, is always "listOf".
Definition: NUMLList.cpp:372
#define LIBNUML_CPP_NAMESPACE_BEGIN
Definition: libnuml-namespace.h:71
std::string mTerm
Definition: OntologyTerm.h:276
std::string mSourceTermId
Definition: OntologyTerm.h:277
Parent class for the various NUML list classes e.g.
Definition: NUMLList.h:45
std::string mOntologyURI
Definition: OntologyTerm.h:278
Definition: OntologyTerm.h:295
virtual NMBase * clone() const
Creates and returns a deep copy of this NUMLList.
Definition: NUMLList.cpp:122
virtual const std::string & getId() const
Definition: NMBase.cpp:219
NUMLTypeCode_t
An enumeration of NUML types to help identify NUML objects at runtime.
Definition: NUMLTypeCodes.h:33
std::string ontologyURI
Definition: OntologyTerm.h:298
#define LIBNUML_EXTERN
Begin svn Header.
Definition: extern.h:104
virtual const std::string & getElementName() const =0
Returns the XML element name of this object.
Implementation of the Visitor design pattern, for operations on NUML objects.
Definition: NUMLVisitor.h:72
namespace class
Definition: NUMLNamespaces.h:46
std::string term
Definition: OntologyTerm.h:296
std::string mId
Definition: OntologyTerm.h:275
virtual NUMLTypeCode_t getTypeCode() const
Returns the libnuml type code for this object.
Definition: NMBase.cpp:623
ontology terms store information about what individual elements represents
Definition: OntologyTerm.h:44
virtual NUMLTypeCode_t getTypeCode() const
Returns the libNUML type code for this NUML object.
Definition: OntologyTerm.h:331
#define END_C_DECLS
Definition: extern.h:113
virtual void readAttributes(const LIBSBML_CPP_NAMESPACE_QUALIFIER XMLAttributes &attributes)
Subclasses should override this method to read values from the given XMLAttributes set into their spe...
Definition: NMBase.cpp:2134
virtual bool accept(NUMLVisitor &v) const =0
Accepts the given NUMLVisitor for this instance of NMBase.
#define LIBNUML_CPP_NAMESPACE_END
Definition: libnuml-namespace.h:72
virtual int setId(const std::string &sid)
Definition: NMBase.cpp:412
virtual int getElementPosition() const
The NUML XML Schema is written such that the order of child elements is significant.
Definition: NMBase.cpp:2040
virtual void writeAttributes(LIBSBML_CPP_NAMESPACE_QUALIFIER XMLOutputStream &stream) const
Subclasses should override this method to write their XML attributes to the XMLOutputStream.
Definition: NMBase.cpp:2159
std::string sourceTermId
Definition: OntologyTerm.h:297
virtual NMBase * clone() const =0
Creates and returns a deep copy of this NMBase object.