1 /**
2  * @cond doxygenLibsbmlInternal
3  *
4  * @file    UniqueSymbolsInInitialAssignments.cpp
5  * @brief   Ensures the ids for all UnitDefinitions in a Model are unique
6  * @author  Ben Bornstein
7  *
8  * <!--------------------------------------------------------------------------
9  * This file is part of libSBML.  Please visit http://sbml.org for more
10  * information about SBML, and the latest version of libSBML.
11  *
12  * Copyright (C) 2020 jointly by the following organizations:
13  *     1. California Institute of Technology, Pasadena, CA, USA
14  *     2. University of Heidelberg, Heidelberg, Germany
15  *     3. University College London, London, UK
16  *
17  * Copyright (C) 2019 jointly by the following organizations:
18  *     1. California Institute of Technology, Pasadena, CA, USA
19  *     2. University of Heidelberg, Heidelberg, Germany
20  *
21  * Copyright (C) 2013-2018 jointly by the following organizations:
22  *     1. California Institute of Technology, Pasadena, CA, USA
23  *     2. EMBL European Bioinformatics Institute (EMBL-EBI), Hinxton, UK
24  *     3. University of Heidelberg, Heidelberg, Germany
25  *
26  * Copyright (C) 2009-2013 jointly by the following organizations:
27  *     1. California Institute of Technology, Pasadena, CA, USA
28  *     2. EMBL European Bioinformatics Institute (EMBL-EBI), Hinxton, UK
29  *
30  * Copyright (C) 2006-2008 by the California Institute of Technology,
31  *     Pasadena, CA, USA
32  *
33  * Copyright (C) 2002-2005 jointly by the following organizations:
34  *     1. California Institute of Technology, Pasadena, CA, USA
35  *     2. Japan Science and Technology Agency, Japan
36  *
37  * This library is free software; you can redistribute it and/or modify it
38  * under the terms of the GNU Lesser General Public License as published by
39  * the Free Software Foundation.  A copy of the license agreement is provided
40  * in the file named "LICENSE.txt" included with this software distribution
41  * and also available online as http://sbml.org/software/libsbml/license.html
42  * ---------------------------------------------------------------------- -->*/
43 
44 #include <sbml/Model.h>
45 #include <sbml/UnitDefinition.h>
46 
47 #include "UniqueSymbolsInInitialAssignments.h"
48 
49 /** @cond doxygenIgnored */
50 using namespace std;
51 /** @endcond */
52 
53 LIBSBML_CPP_NAMESPACE_BEGIN
54 
55 static const char* PREAMBLE =
56     "A given identifier cannot appear as the value of more than one 'symbol' "
57     "field across the set of <initialAssignment>s in a model. (References: "
58     "L2V2 Section 4.10.)";
59 
60 
61 /*
62  * Creates a new Constraint with the given constraint id.
63  */
UniqueSymbolsInInitialAssignments(unsigned int id,Validator & v)64 UniqueSymbolsInInitialAssignments::UniqueSymbolsInInitialAssignments ( unsigned int id,
65                                                            Validator& v ) :
66   UniqueIdBase(id, v)
67 {
68 }
69 
70 
71 /*
72  * Destroys this Constraint.
73  */
~UniqueSymbolsInInitialAssignments()74 UniqueSymbolsInInitialAssignments::~UniqueSymbolsInInitialAssignments ()
75 {
76 }
77 
78 
79 /*
80  * @return the preamble to use when logging constraint violations.
81  */
82 const char*
getPreamble()83 UniqueSymbolsInInitialAssignments::getPreamble ()
84 {
85   return PREAMBLE;
86 }
87 
88 
89 /*
90  * Checks that all ids on UnitDefinitions are unique.
91  */
92 void
doCheck(const Model & m)93 UniqueSymbolsInInitialAssignments::doCheck (const Model& m)
94 {
95   unsigned int n, size;
96 
97 
98   size = m.getNumInitialAssignments();
99   for (n = 0; n < size; ++n) checkId( *m.getInitialAssignment(n) );
100 }
101 
102 /*
103  * @return the fieldname to use logging constraint violations.  If not
104  * overridden, "id" is returned.
105  */
106 const char*
getFieldname()107 UniqueSymbolsInInitialAssignments::getFieldname ()
108 {
109   return "symbol";
110 }
111 
112 
113 
114 
115 LIBSBML_CPP_NAMESPACE_END
116 /** @endcond */
117 
118