libNuML 1.1.1
Library for reading / writing NuML documents
NUMLDocument.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 NUMLDocument_h
25#define NUMLDocument_h
26
27
28#include <numl/common/extern.h>
29#include <numl/common/numlfwd.h>
30
31#include <numl/NUMLError.h>
32#include <numl/NUMLErrorLog.h>
33#include <numl/NMBase.h>
34
35#include <numl/OntologyTerm.h>
37
38
39
40
41#include <string>
42#include <algorithm>
43#include <iosfwd>
44#include <time.h>
45
46#ifdef __cplusplus
47
48
49LIBNUML_CPP_NAMESPACE_BEGIN
50
51class OntologyTerm;
52class ResultComponent;
53class NUMLVisitor;
54
55
56/* Internal constants for setting/unsetting particular consistency checks. */
57
58#ifndef IdCheckON
59#define IdCheckON 0x01;
60#endif
61#ifndef IdCheckOFF
62#define IdCheckOFF 0xfe;
63#endif
64#ifndef NUMLCheckON
65#define NUMLCheckON 0x02;
66#endif
67#ifndef NUMLCheckOFF
68#define NUMLCheckOFF 0xfd;
69#endif
70#ifndef SBOCheckON
71#define SBOCheckON 0x04;
72#endif
73#ifndef SBOCheckOFF
74#define SBOCheckOFF 0xfb;
75#endif
76#ifndef MathCheckON
77#define MathCheckON 0x08;
78#endif
79#ifndef MathCheckOFF
80#define MathCheckOFF 0xf7;
81#endif
82#ifndef UnitsCheckON
83#define UnitsCheckON 0x10;
84#endif
85#ifndef UnitsCheckOFF
86#define UnitsCheckOFF 0xef;
87#endif
88#ifndef OverdeterCheckON
89#define OverdeterCheckON 0x20;
90#endif
91#ifndef OverdeterCheckOFF
92#define OverdeterCheckOFF 0xdf;
93#endif
94#ifndef PracticeCheckON
95#define PracticeCheckON 0x40;
96#endif
97#ifndef PracticeCheckOFF
98#define PracticeCheckOFF 0xbf;
99#endif
100#ifndef AllChecksON
101#define AllChecksON 0x7f;
102#endif
103
104
105
107{
108public:
109
123 static unsigned int getDefaultLevel ();
124
125
141 static unsigned int getDefaultVersion ();
142
143
183 NUMLDocument (unsigned int level = 0, unsigned int version = 0);
184
185
189 virtual ~NUMLDocument ();
190
191
195 NUMLDocument (const NUMLDocument& rhs);
196
197
205 virtual bool accept (NUMLVisitor& v) const;
206
207
213 virtual NUMLDocument* clone () const;
214
221 unsigned int getNumOntologyTerms () const;
222
236 OntologyTerms* getOntologyTerms ();
237
238
252 const OntologyTerms* getOntologyTerms () const;
253
268 ResultComponents* getResultComponents ();
269
283 const ResultComponents* getResultComponents () const;
284
291 unsigned int getNumResultComponents() const;
292
296 ResultComponent* getResultComponent (unsigned int index);
297
303 bool setLevelAndVersion (unsigned int level, unsigned int version,
304 bool strict = true);
305
306 OntologyTerm* createOntologyTerm ();
307
308 ResultComponent* createResultComponent ();
309
310 // OntologyTerm* createOntologyTerm (const std::string& sid = ""); // will be removed later
311
312
328 const NUMLError* getError (unsigned int n) const;
329
330
337 unsigned int getNumErrors () const;
338
339
366 void printErrors (std::ostream& stream = std::cerr) const;
367
368
369
370
371
372 /*
373 * Sets the parent NUML object of this NUML object.
374 *
375 * @param sb the NUML object to use
376 */
377 virtual void setParentNUMLObject (NMBase* sb);
378
379
384 virtual void setNUMLDocument (NUMLDocument* d);
385
386
406 virtual NUMLTypeCode_t getTypeCode () const;
407
408
415 virtual const std::string& getElementName () const;
416
417
427
428
435 virtual LIBSBML_CPP_NAMESPACE_QUALIFIER XMLNamespaces* getNamespaces() const;
436
437
438
443 int getElementPosition () const;
444
445
451 virtual void writeElements (LIBSBML_CPP_NAMESPACE_QUALIFIER XMLOutputStream& stream) const;
452
453
454protected:
455
460 virtual NMBase* createObject (LIBSBML_CPP_NAMESPACE_QUALIFIER XMLInputStream& stream);
461
462
468 virtual
469 void readAttributes (const LIBSBML_CPP_NAMESPACE_QUALIFIER XMLAttributes& attributes);
470
471
477 virtual void writeAttributes (LIBSBML_CPP_NAMESPACE_QUALIFIER XMLOutputStream& stream) const;
478
479 /*
480 * Predicate returning true if the errors encountered are not ignorable.
481 */
482 bool conversion_errors(unsigned int errors);
483
484 /*
485 * Predicate returning true if model has strict unit consistency.
486 */
488
489 /*
490 * Predicate returning true if model has strict sbo consistency.
491 */
493
494
497
500
501
503
506
507
508 friend class NMBase;
509 friend class NUMLReader;
510
511};
512
513LIBNUML_CPP_NAMESPACE_END
514
515#endif /* __cplusplus */
516
517
518#ifndef SWIG
519
520#include <stdio.h>
521
522LIBNUML_CPP_NAMESPACE_BEGIN
524
525/*-----------------------------------------------------------------------------
526 * See the .cpp file for the documentation of the following functions.
527 *---------------------------------------------------------------------------*/
528
529
533
534
537NUMLDocument_createWithLevelAndVersion (unsigned int level, unsigned int version);
538
539
541void
543
544
548
549
551unsigned int
553
554
556unsigned int
558
559
561int
563 , unsigned int level
564 , unsigned int version );
565
566
568int
570 , unsigned int level
571 , unsigned int version );
572
574void
575NUMLDocument_setConsistencyChecks(NUMLDocument_t *d,
576 NUMLErrorCategory_t category,
577 int apply);
578
580void
581NUMLDocument_setConsistencyChecksForConversion(NUMLDocument_t *d,
582 NUMLErrorCategory_t category,
583 int apply);
584
586unsigned int
587NUMLDocument_checkConsistency (NUMLDocument_t *d);
588
589
591unsigned int
592NUMLDocument_checkInternalConsistency (NUMLDocument_t *d);
593
594
596unsigned int
597NUMLDocument_checkL1Compatibility (NUMLDocument_t *d);
598
599
601unsigned int
602NUMLDocument_checkL2v1Compatibility (NUMLDocument_t *d);
603
604
606unsigned int
607NUMLDocument_checkL2v2Compatibility (NUMLDocument_t *d);
608
609
611unsigned int
612NUMLDocument_checkL2v3Compatibility (NUMLDocument_t *d);
613
614
616unsigned int
617NUMLDocument_checkL2v4Compatibility (NUMLDocument_t *d);
618
619
621const NUMLError_t *
622NUMLDocument_getError (NUMLDocument_t *d, unsigned int n);
623
624
626unsigned int
628
629
631void
633
634
636unsigned int
638
639
641unsigned int
643
645const LIBSBML_CPP_NAMESPACE_QUALIFIER XMLNamespaces_t *
647
649LIBNUML_CPP_NAMESPACE_END
650
651
652#endif /* !SWIG */
653#endif /* NUMLDocument_h */
LIBNUML_EXTERN int NUMLDocument_setLevelAndVersionStrict(NUMLDocument_t *d, unsigned int level, unsigned int version)
Sets the NUML Level and Version of this NUMLDocument, attempting to convert the model as needed.
Definition: NUMLDocument.cpp:960
LIBNUML_EXTERN NUMLDocument_t * NUMLDocument_clone(const NUMLDocument_t *d)
Creates and returns a deep copy of the given NUMLDocument_t structure.
Definition: NUMLDocument.cpp:848
LIBNUML_EXTERN NUMLDocument_t * NUMLDocument_create()
Creates a new, empty NUMLDocument_t structure.
Definition: NUMLDocument.cpp:799
LIBNUML_EXTERN unsigned int NUMLDocument_getNumErrors(const NUMLDocument_t *d)
Returns the number of errors or warnings encountered during parsing, consistency checking,...
Definition: NUMLDocument.cpp:1008
LIBNUML_EXTERN int NUMLDocument_setLevelAndVersion(NUMLDocument_t *d, unsigned int level, unsigned int version)
Sets the NUML Level and Version of this NUMLDocument, attempting to convert the ResultComponent as ne...
Definition: NUMLDocument.cpp:914
LIBNUML_EXTERN void NUMLDocument_free(NUMLDocument_t *d)
Frees the given NUMLDocument_t structure.
Definition: NUMLDocument.cpp:833
LIBNUML_EXTERN NUMLDocument_t * NUMLDocument_createWithLevelAndVersion(unsigned int level, unsigned int version)
Creates a new, empty NUMLDocument_t structure with given values for the NUML Level and Version.
Definition: NUMLDocument.cpp:820
LIBNUML_EXTERN void NUMLDocument_printErrors(NUMLDocument_t *d, FILE *stream)
Prints to the given output stream all the errors or warnings encountered during parsing,...
Definition: NUMLDocument.cpp:1033
LIBNUML_EXTERN unsigned int NUMLDocument_getVersion(const NUMLDocument_t *d)
Returns the Version within the NUML Level of the given NUMLDocument_t structure.
Definition: NUMLDocument.cpp:879
LIBNUML_EXTERN const LIBSBML_CPP_NAMESPACE_QUALIFIER XMLNamespaces_t * NUMLDocument_getNamespaces(NUMLDocument_t *d)
Returns a list of XMLNamespaces_t associated with the XML content of this NUML document.
Definition: NUMLDocument.cpp:1078
LIBNUML_EXTERN unsigned int NUMLDocument_getLevel(const NUMLDocument_t *d)
Returns the NUML Level of the given NUMLDocument_t structure.
Definition: NUMLDocument.cpp:863
LIBNUML_EXTERN const NUMLError_t * NUMLDocument_getError(NUMLDocument_t *d, unsigned int n)
Returns the nth error or warning encountered during parsing, consistency checking,...
Definition: NUMLDocument.cpp:988
unsigned int NUMLDocument_getDefaultLevel()
Definition: NUMLDocument.cpp:1052
unsigned int NUMLDocument_getDefaultVersion()
Definition: NUMLDocument.cpp:1063
NUMLErrorCategory_t
Category codes for NUMLError diagnostics.
Definition: NUMLError.h:146
NUMLTypeCode_t
An enumeration of NUML types to help identify NUML objects at runtime.
Definition: NUMLTypeCodes.h:34
This is the base class for all numl objects.
Definition: NMBase.h:71
virtual LIBSBML_CPP_NAMESPACE_QUALIFIER XMLNamespaces * getNamespaces() const
Returns the content of the "annotation" subelement of this object as a character string.
Definition: NMBase.cpp:242
NUMLErrorLog * getErrorLog()
Definition: NMBase.cpp:2051
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:1715
virtual NUMLTypeCode_t getTypeCode() const
Returns the libnuml type code for this object.
Definition: NMBase.cpp:624
virtual int getElementPosition() const
The NUML XML Schema is written such that the order of child elements is significant.
Definition: NMBase.cpp:2041
virtual const std::string & getElementName() const =0
Returns the XML element name of this object.
virtual bool accept(NUMLVisitor &v) const =0
Accepts the given NUMLVisitor for this instance of NMBase.
virtual NMBase * clone() const =0
Creates and returns a deep copy of this NMBase object.
virtual void setNUMLDocument(NUMLDocument *d)
Sets the parent NUMLDocument of this NUML object.
Definition: NMBase.cpp:435
virtual void setParentNUMLObject(NMBase *sb)
Sets the parent NUML object of this NUML object.
Definition: NMBase.cpp:486
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:2160
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:2135
virtual void writeElements(LIBSBML_CPP_NAMESPACE_QUALIFIER XMLOutputStream &stream) const
Subclasses should override this method to write out their contained NUML objects as XML elements.
Definition: NMBase.cpp:1694
This represents the numl document that contains all information.
Definition: NUMLDocument.h:107
bool hasStrictSBO()
unsigned char mApplicableValidators
Definition: NUMLDocument.h:504
bool hasStrictUnits()
NUMLErrorLog mErrorLog
Definition: NUMLDocument.h:502
OntologyTerms mOntologyTerms
Definition: NUMLDocument.h:498
int mVersion
Definition: NUMLDocument.h:496
unsigned char mApplicableValidatorsForConversion
Definition: NUMLDocument.h:505
int mLevel
Definition: NUMLDocument.h:495
ResultComponents mResultComponents
Definition: NUMLDocument.h:499
contains all error information collected
Definition: NUMLError.h:235
the error log containing all errors / warnings encountered
Definition: NUMLErrorLog.h:39
The reader class implementing reading NuML documents from file / string.
Definition: NUMLReader.h:45
Implementation of the Visitor design pattern, for operations on NUML objects.
Definition: NUMLVisitor.h:73
ontology terms store information about what individual elements represents
Definition: OntologyTerm.h:44
Definition: OntologyTerm.h:301
stores the result component
Definition: ResultComponent.h:57
Definition: ResultComponent.h:323
#define BEGIN_C_DECLS
Definition: extern.h:112
#define LIBNUML_EXTERN
Begin svn Header.
Definition: extern.h:104
#define END_C_DECLS
Definition: extern.h:113
CLASS_OR_STRUCT NUMLDocument NUMLDocument_t
Definition: numlfwd.h:88
CLASS_OR_STRUCT NUMLError NUMLError_t
Definition: numlfwd.h:190
CLASS_OR_STRUCT XMLNamespaces XMLNamespaces_t
Definition: numlfwd.h:247