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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 707 - (hide annotations) (download) (as text)
Tue Jun 27 05:49:11 2006 UTC (18 years 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 johnpye 485 /* 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 aw0a 1
6 johnpye 485 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 aw0a 1
11 johnpye 485 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 johnpye 700 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 johnpye 485 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 johnpye 700 based on instance.c
40 johnpye 485 by Tom Epperly & Ben Allan
41     8/16/89
42 johnpye 700 Last in CVS: $Revision: 1.10 $ $Date: 1998/02/05 16:35:24 $ $Author: ballan $
43 johnpye 485 */
44    
45 johnpye 700 #ifndef ASC_ATOMVALUE_H
46     #define ASC_ATOMVALUE_H
47 aw0a 1
48 johnpye 485 #include <utilities/ascConfig.h>
49    
50 johnpye 490 ASC_DLLSPEC(unsigned) AtomAssigned(CONST struct Instance *i);
51 jds 54 /**<
52 aw0a 1 * 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 johnpye 707 ASC_DLLSPEC(unsigned) AtomMutable(CONST struct Instance *i);
59 jds 54 /**<
60 aw0a 1 * 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 jds 54 extern unsigned DepthAssigned(CONST struct Instance *i);
68     /**<
69 aw0a 1 * Return the depth of the assignment. This only works on real and
70     * boolean instances.
71     */
72    
73 jds 54 /*
74 aw0a 1 * 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 johnpye 490 ASC_DLLSPEC(double) RealAtomValue(CONST struct Instance *i);
82 jds 54 /**<
83 aw0a 1 * 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 johnpye 490 ASC_DLLSPEC(void) SetRealAtomValue(struct Instance *i, double d, unsigned depth);
88 jds 54 /**<
89 aw0a 1 * 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 jds 54 * This will set the depth too. <br><br>
93 aw0a 1 *
94     * It is recommended that the interface use depth = 0 which will take
95     * precidence over every other assignment.
96     */
97    
98 johnpye 490 ASC_DLLSPEC(CONST dim_type*) RealAtomDims(CONST struct Instance *i);
99 jds 54 /**<
100 aw0a 1 * 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 johnpye 490 ASC_DLLSPEC(void) SetRealAtomDims(struct Instance *i, CONST dim_type *dim);
106 jds 54 /**<
107 aw0a 1 * 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 johnpye 490 ASC_DLLSPEC(long) GetIntegerAtomValue(CONST struct Instance *i);
114 jds 54 /**<
115 aw0a 1 * 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 johnpye 522 ASC_DLLSPEC(void ) SetIntegerAtomValue(struct Instance *i, long v, unsigned depth);
120 jds 54 /**<
121 aw0a 1 * 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 johnpye 490 ASC_DLLSPEC(int) GetBooleanAtomValue(CONST struct Instance *i);
129 jds 54 /**<
130 aw0a 1 * 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 johnpye 490 ASC_DLLSPEC(void) SetBooleanAtomValue(struct Instance *i, int truth, unsigned depth);
136 jds 54 /**<
137 aw0a 1 * 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 jds 54 * This will set the assigned attribute of i.<br><br>
141 aw0a 1 *
142     * It is recommended that the interface use depth = 0 because it will
143     * override every other assignment.
144     */
145    
146 johnpye 490 ASC_DLLSPEC(CONST struct set_t*) SetAtomList(CONST struct Instance *i);
147 jds 54 /**<
148 aw0a 1 * 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 jds 54 extern int AssignSetAtomList(struct Instance *i, struct set_t *list);
154     /**<
155 aw0a 1 * 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 jds 54 extern int GetSetAtomKind(CONST struct Instance *i);
163     /**<
164 aw0a 1 * Return the kind of the set. 1 ==> integer set; 0 ==> string set.
165     */
166    
167 johnpye 490 ASC_DLLSPEC(symchar*) GetSymbolAtomValue(CONST struct Instance *i);
168 jds 54 /**<
169 aw0a 1 * 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 johnpye 522 ASC_DLLSPEC(void ) SetSymbolAtomValue(struct Instance *i, symchar *s);
177 jds 54 /**<
178 aw0a 1 * 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 jds 54 extern int CmpAtomValues(CONST struct Instance *i1, CONST struct Instance *i2);
185     /**<
186 aw0a 1 * 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 johnpye 700 #endif /* ASC_ATOMVALUE_H */
194 jds 54

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