/[ascend]/trunk/base/generic/compiler/atomvalue.h
ViewVC logotype

Contents of /trunk/base/generic/compiler/atomvalue.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 707 - (show annotations) (download) (as text)
Tue Jun 27 05:49:11 2006 UTC (17 years, 11 months ago) by johnpye
File MIME type: text/x-chdr
File size: 7073 byte(s)
Lots of tidying up in instantiate.c.
Fixed up some GPL headers.
Changed from 'solver_var' to 'factor' in extfntest.a4c.
Added test for AtomAssigned in extfunc.c.
1 /* ASCEND modelling environment
2 Copyright (C) 1990, 1993, 1994 Thomas Guthrie Epperly
3 Copyright (C) 1996 Ben Allan
4 Copyright (C) 2006 Carnegie Mellon University
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA.
20 *//**
21 @file
22 Atom value querying and assignment routines.
23
24 These routines provide access to atom values and related attributes.
25 All of the following routines may only be called on atomic instances.
26
27 Atoms are instances that ASCEND can deal with as a 'value'.They include
28 real numbers, integrers, boolean values and sets of integers and sets of
29 symbols.
30
31 Requires:
32 #include "utilities/ascConfig.h"
33 #include "instance_enum.h"
34 #include "fractions.h"
35 #include "compiler.h"
36 #include "dimen.h"
37 #include "sets.h"
38 *//*
39 based on instance.c
40 by Tom Epperly & Ben Allan
41 8/16/89
42 Last in CVS: $Revision: 1.10 $ $Date: 1998/02/05 16:35:24 $ $Author: ballan $
43 */
44
45 #ifndef ASC_ATOMVALUE_H
46 #define ASC_ATOMVALUE_H
47
48 #include <utilities/ascConfig.h>
49
50 ASC_DLLSPEC(unsigned) AtomAssigned(CONST struct Instance *i);
51 /**<
52 * Return a nonzero value if the atom instance has been assigned; otherwise,
53 * return false. It will actually return the number of times that the
54 * atom has been assigned.
55 * Valid for *_INST, *_ATOM_INSTANCE, *_CONSTANT_INSTANCE.
56 */
57
58 ASC_DLLSPEC(unsigned) AtomMutable(CONST struct Instance *i);
59 /**<
60 * Return a true value if the atom instance is mutable; otherwise, return
61 * false.
62 * Valid for *_INST, *_ATOM_INSTANCE, *_CONSTANT_INSTANCE.
63 * Often rather a redundant operator, since *_INST and *_ATOM_INSTANCE are
64 * permanently mutable.
65 */
66
67 extern unsigned DepthAssigned(CONST struct Instance *i);
68 /**<
69 * Return the depth of the assignment. This only works on real and
70 * boolean instances.
71 */
72
73 /*
74 * The following Get/Set*AtomValue functions apply to all the scalar
75 * kinds integer, symbol, boolean, and real. This includes
76 * fundamentals (atom children), atoms, and constants. We would take
77 * the word Atom out of the function names except that, e.g.,
78 * RealValue is a name used in value_type.h.
79 */
80
81 ASC_DLLSPEC(double) RealAtomValue(CONST struct Instance *i);
82 /**<
83 * Return the real value of real instance i. This works only on
84 * REAL_INST or REAL_ATOM_INST or REAL_CONSTANT_INSTANCE.
85 */
86
87 ASC_DLLSPEC(void) SetRealAtomValue(struct Instance *i, double d, unsigned depth);
88 /**<
89 * Assign the value d(in system units) to instance i. This works only on
90 * REAL_INST or REAL_ATOM_INST or REAL_CONSTANT_INSTANCEs not assigned.
91 * This will set the assigned attribute also.
92 * This will set the depth too. <br><br>
93 *
94 * It is recommended that the interface use depth = 0 which will take
95 * precidence over every other assignment.
96 */
97
98 ASC_DLLSPEC(CONST dim_type*) RealAtomDims(CONST struct Instance *i);
99 /**<
100 * Return the dimensions attribute of instance i. This works only on
101 * REAL_INST or REAL_ATOM_INST or REAL_CONSTANT_INSTANCE.
102 * This should never return a NULL pointer.
103 */
104
105 ASC_DLLSPEC(void) SetRealAtomDims(struct Instance *i, CONST dim_type *dim);
106 /**<
107 * Set i's dimensions to dim.
108 * dim should already be in the dimensions list.
109 * This works only on
110 * REAL_INST or REAL_ATOM_INST or REAL_CONSTANT_INSTANCEs not dimensioned.
111 */
112
113 ASC_DLLSPEC(long) GetIntegerAtomValue(CONST struct Instance *i);
114 /**<
115 * Return the value of the integer instance i. This only works on
116 * INTEGER_INST or INTEGER_ATOM_INST or INTEGER_CONSTANT_INST type instances.
117 */
118
119 ASC_DLLSPEC(void ) SetIntegerAtomValue(struct Instance *i, long v, unsigned depth);
120 /**<
121 * Set the value of instance i to v. This only works on INTEGER_INST or
122 * INTEGER_ATOM_INST or unassigned INTEGER_CONSTANT_INST type instances.
123 *
124 * This also sets the assigned as needed.
125 * Calling on an improper integer will cause a crash.
126 */
127
128 ASC_DLLSPEC(int) GetBooleanAtomValue(CONST struct Instance *i);
129 /**<
130 * Return a true value if i is TRUE; otherwise return a false value.
131 * This only works on BOOLEAN_INST or BOOLEAN_ATOM_INST
132 * or BOOLEAN_CONSTANT_INST type instances.
133 */
134
135 ASC_DLLSPEC(void) SetBooleanAtomValue(struct Instance *i, int truth, unsigned depth);
136 /**<
137 * If truth is a true value, i will be set to TRUE; otherwise, i will be
138 * set to FALSE. This only works on BOOLEAN_INST or BOOLEAN_ATOM_INST
139 * or unassigned BOOLEAN_CONSTANT_INST type instances.
140 * This will set the assigned attribute of i.<br><br>
141 *
142 * It is recommended that the interface use depth = 0 because it will
143 * override every other assignment.
144 */
145
146 ASC_DLLSPEC(CONST struct set_t*) SetAtomList(CONST struct Instance *i);
147 /**<
148 * Return the list from the set instance i. This only works on SET_INST
149 * and SET_ATOM_INST type instances. This returns NULL when i has not
150 * been assigned.
151 */
152
153 extern int AssignSetAtomList(struct Instance *i, struct set_t *list);
154 /**<
155 * Set i's list to list. This will set the assigned attribute unless
156 * list is NULL. A set's value cannot be changed after it has been assigned.
157 * Returns 1 if successful. Returns 0 if not successful.
158 * If the return is 0, the user is responsible for list since it did not
159 * become part of i.
160 */
161
162 extern int GetSetAtomKind(CONST struct Instance *i);
163 /**<
164 * Return the kind of the set. 1 ==> integer set; 0 ==> string set.
165 */
166
167 ASC_DLLSPEC(symchar*) GetSymbolAtomValue(CONST struct Instance *i);
168 /**<
169 * This returns the symbol that instance i is assigned to.
170 * If i is unassigned, it will return NULL. This only works on
171 * SYMBOL_INST and SYMBOL_ATOM_INST or SYMBOL_CONSTANT_INST type instances.
172 * The character string does not contain the single quote delimeters.
173 * The symchar can be converted to a string with macro SCP from compiler.h.
174 */
175
176 ASC_DLLSPEC(void ) SetSymbolAtomValue(struct Instance *i, symchar *s);
177 /**<
178 * This makes an assignment to i. Instance i should be of type
179 * SYMBOL_INST or SYMBOL_ATOM_INST or unassigned SYMBOL_CONSTANT_INST.
180 * Character strings should not contain the single quote delimiters.
181 * Buggy at present, since symbolatominst are supposed to be mutable.
182 */
183
184 extern int CmpAtomValues(CONST struct Instance *i1, CONST struct Instance *i2);
185 /**<
186 * Return -1,0,1 as i2 < == or > i1. i1 and i2 should be of the same base
187 * type. The following types are allowed:
188 * REAL_*INST, BOOLEAN_*INST, SYMBOL_*INST, INTEGER_*INST SET_*INST.
189 * Calls with other types will not return, nor will calls with mismatched
190 * types.
191 */
192
193 #endif /* ASC_ATOMVALUE_H */
194

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22