/[ascend]/trunk/pygtk/interface/instance.h
ViewVC logotype

Annotation of /trunk/pygtk/interface/instance.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 258 - (hide annotations) (download) (as text)
Thu Feb 2 14:50:05 2006 UTC (13 years, 11 months ago) by johnpye
File MIME type: text/x-chdr
File size: 3477 byte(s)
Made it so that fixed variables never get an icon.
1 johnpye 132 #ifndef ASCXX_INSTANCE_H
2     #define ASCXX_INSTANCE_H
3    
4     #include <string>
5     #include <vector>
6    
7     #include "symchar.h"
8     #include "type.h"
9     #include "set.h"
10     #include "dimensions.h"
11    
12 johnpye 176 class Plot;
13    
14 johnpye 132 extern "C"{
15     #include <utilities/ascConfig.h>
16 johnpye 164 #include <utilities/error.h>
17 johnpye 132 #include <compiler/types.h>
18     #include <compiler/instance_enum.h>
19     #include <compiler/atomvalue.h>
20 johnpye 172 #include <compiler/plot.h>
21 johnpye 132 }
22    
23 johnpye 255 typedef enum{
24 johnpye 258 ASCXX_VAR_STATUS_UNKNOWN=0, ASCXX_VAR_FIXED, ASCXX_VAR_UNSOLVED, ASCXX_VAR_ACTIVE, ASCXX_VAR_SOLVED
25 johnpye 255 } VarStatus;
26    
27 johnpye 132 /**
28     This class has to be called 'Instanc' in C++ to avoid a name clash
29     with C. Maybe coulda done it with namespaces but didn't know how.
30    
31     This class is renamed back to 'Instance' by SWIG, so use 'Instance'
32     when you're in Python.
33    
34     The Right Way to implement this class would be as a base class
35     with lots of diffent subclasses for the different atom types.
36 johnpye 190 Maybe even multiple inheritance.
37 johnpye 132
38     But until the underlying C code is ported to C++ it's not going to be
39     worth the effort.
40     */
41     class Instanc{
42     private:
43     struct Instance *i;
44     SymChar name;
45     std::vector<Instanc> children;
46     void setName(SymChar);
47     static SymChar fixedsym;
48     static SymChar solvervarsym;
49     public:
50     Instanc();
51     Instanc(Instance *i);
52     Instanc(Instance *i, const SymChar &name);
53     Instanc(const Instanc &parent, const unsigned long &childnum);
54     Instanc(const Instanc&);
55     std::vector<Instanc> &getChildren();
56     Instanc getChild(const SymChar &) const;
57     const enum inst_t getKind() const;
58     const std::string getKindStr() const;
59     const Type getType() const;
60     const bool isAtom() const;
61     const bool isFixed() const;
62    
63     const bool isFund() const;
64     const bool isConst() const;
65     const bool isCompound() const;
66     const bool isRelation() const;
67     const bool isWhen() const;
68     const bool isSet() const;
69     const bool isSetInt() const;
70     const bool isSetString() const;
71     const bool isSetEmpty() const; // set of of type 'empty', NB not same as SetInt::length()==0
72     const bool isArray() const;
73     const bool isDefined() const;
74     const bool isChildless() const;
75     const bool isBool() const;
76     const bool isInt() const;
77     const bool isSymbol() const;
78     const bool isReal() const;
79     const bool isAssigned() const;
80     const SymChar &getName() const;
81     const double getRealValue() const;
82     const bool isDimensionless() const;
83     const Dimensions getDimensions() const;
84     const bool getBoolValue() const;
85     const long getIntValue() const;
86     const SymChar getSymbolValue() const;
87 johnpye 175 const std::string getValueAsString() const;
88 johnpye 215 const std::string getRelationAsString(const Instanc &relative_to) const;
89 johnpye 176 Plot getPlot() const;
90 johnpye 132
91 johnpye 172 const bool isPlottable() const;
92    
93 johnpye 132 void setFixed(const bool &val=true);
94     void setBoolValue(const bool&, const unsigned &depth=0);
95     void setRealValue(const double&, const unsigned &depth=0);
96     void setRealValueWithUnits(double, const char *, const unsigned &depth=0);
97    
98 johnpye 190 template<class T>
99 johnpye 132 const ASCXX_Set<T> Instanc::getSetValue() const{
100     if(!isSet()){
101 johnpye 190 ERROR_REPORTER_NOLINE(ASC_USER_ERROR,"Variable '%s' is not set-valued",getName().toString());
102 johnpye 132 return ASCXX_Set<T>();
103     }
104     if(!isConst() && !isDefined()){
105 johnpye 190 ERROR_REPORTER_NOLINE(ASC_USER_ERROR,"Variable '%s' is not defined",getName().toString());
106 johnpye 132 return ASCXX_Set<T>();
107     }
108     return ASCXX_Set<T>(SetAtomList(i));
109     }
110    
111     const enum set_kind getSetType() const;
112     void write();
113     Instance *getInternalType() const;
114 johnpye 255
115     void setVarStatus(const VarStatus &); ///< make this one private, just for friend Simulation?
116     const VarStatus getVarStatus() const;
117 johnpye 132 };
118    
119     #endif
120    

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