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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

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