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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 164 - (hide annotations) (download) (as text)
Tue Jan 3 09:54:43 2006 UTC (18 years, 6 months ago) by johnpye
File MIME type: text/x-chdr
File size: 3126 byte(s)
Added wait-cursor during compile/build, started working
on correct destruction of Simulation objects.
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     extern "C"{
13     #include <utilities/ascConfig.h>
14 johnpye 164 #include <utilities/error.h>
15 johnpye 132 #include <compiler/types.h>
16     #include <compiler/instance_enum.h>
17     #include <compiler/atomvalue.h>
18     }
19    
20     /**
21     This class has to be called 'Instanc' in C++ to avoid a name clash
22     with C. Maybe coulda done it with namespaces but didn't know how.
23    
24     This class is renamed back to 'Instance' by SWIG, so use 'Instance'
25     when you're in Python.
26    
27     The Right Way to implement this class would be as a base class
28     with lots of diffent subclasses for the different atom types.
29     Maybe even multiple inheritance.
30    
31     But until the underlying C code is ported to C++ it's not going to be
32     worth the effort.
33     */
34     class Instanc{
35     private:
36     struct Instance *i;
37     SymChar name;
38     std::vector<Instanc> children;
39     void setName(SymChar);
40     static SymChar fixedsym;
41     static SymChar solvervarsym;
42     public:
43     Instanc();
44     Instanc(Instance *i);
45     Instanc(Instance *i, const SymChar &name);
46     Instanc(const Instanc &parent, const unsigned long &childnum);
47     Instanc(const Instanc&);
48     std::vector<Instanc> &getChildren();
49     Instanc getChild(const SymChar &) const;
50     const enum inst_t getKind() const;
51     const std::string getKindStr() const;
52     const Type getType() const;
53     const bool isAtom() const;
54     const bool isFixed() const;
55    
56     const bool isFund() const;
57     const bool isConst() const;
58     const bool isCompound() const;
59     const bool isRelation() const;
60     const bool isWhen() const;
61     const bool isSet() const;
62     const bool isSetInt() const;
63     const bool isSetString() const;
64     const bool isSetEmpty() const; // set of of type 'empty', NB not same as SetInt::length()==0
65     const bool isArray() const;
66     const bool isDefined() const;
67     const bool isChildless() const;
68     const bool isBool() const;
69     const bool isInt() const;
70     const bool isSymbol() const;
71     const bool isReal() const;
72     const bool isAssigned() const;
73     const SymChar &getName() const;
74     const double getRealValue() const;
75     const bool isDimensionless() const;
76     const Dimensions getDimensions() const;
77     const bool getBoolValue() const;
78     const long getIntValue() const;
79     const SymChar getSymbolValue() const;
80    
81     void setFixed(const bool &val=true);
82     void setBoolValue(const bool&, const unsigned &depth=0);
83     void setRealValue(const double&, const unsigned &depth=0);
84     void setRealValueWithUnits(double, const char *, const unsigned &depth=0);
85    
86     template<class T>
87     const ASCXX_Set<T> Instanc::getSetValue() const{
88     if(!isSet()){
89     error_reporter(ASC_USER_ERROR,NULL,0,"Variable '%s' is not set-valued",getName().toString());
90     return ASCXX_Set<T>();
91     }
92     if(!isConst() && !isDefined()){
93     error_reporter(ASC_USER_ERROR,NULL,0,"Variable '%s' is not defined",getName().toString());
94     return ASCXX_Set<T>();
95     }
96     return ASCXX_Set<T>(SetAtomList(i));
97     }
98    
99     const enum set_kind getSetType() const;
100     void write();
101     Instance *getInternalType() const;
102     };
103    
104     extern "C"{
105     boolean plot_allowed(struct Instance *inst);
106     void plot_prepare_file(struct Instance *inst, char *plotfilename);
107     }
108    
109     #endif
110    

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