/[ascend]/trunk/pygtk/annotation.cpp
ViewVC logotype

Contents of /trunk/pygtk/annotation.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 898 - (show annotations) (download) (as text)
Tue Oct 24 13:34:13 2006 UTC (15 years, 8 months ago) by johnpye
File MIME type: text/x-c++src
File size: 2964 byte(s)
Added 'solver notes' to thermalequilibrium.a4c.
Added 'setup_solver' method in listnotes.py
Added 'getLanguage' to Annotation class
Added 'paramname' to SolverParameters popup in PyGTK
Fixed up some commenting in notate.c
Turned on warning about ignored notes in ascParse.y
1 #include "annotation.h"
2
3 extern "C"{
4 #include <compiler/notate.h>
5 #include <utilities/error.h>
6 #include <utilities/ascPanic.h>
7 }
8
9 #include <stdexcept>
10 #include <iostream>
11
12 using namespace std;
13
14 AnnotationDatabase::AnnotationDatabase(const SymChar &dbid){
15 this->dbid = dbid.getInternalType();
16 }
17
18 vector<Annotation>
19 AnnotationDatabase::getNotes(const Type &type, const SymChar *lang
20 , const SymChar *id, const SymChar *method, const int datatypeint
21 ){
22 struct gl_list_t *res;
23 if(datatypeint < (int)nd_wild && datatypeint > (int)nd_anonymous){
24 throw runtime_error("Invalid datatype flag");
25 }
26
27 symchar *lang1, *id1, *method1;
28
29 if(lang==NULL)lang1 = NOTESWILD;
30 else lang1 = lang->getInternalType();
31
32 if(id==NULL)id1 = NOTESWILD;
33 else id1 = id->getInternalType();
34
35 if(method==NULL)method1 = NOTESWILD;
36 else method1 = method->getInternalType();
37
38 res = GetNotes(dbid, type.getName().getInternalType(), lang1, id1, method1, (enum NoteData)datatypeint);
39
40 if(res==NULL){
41 throw runtime_error("NULL from GetNotes");
42 }
43
44 vector<Annotation> v;
45 for(unsigned i=1; i<=gl_length(res); ++i){
46 v.push_back(Annotation((struct Note *)gl_fetch(res,i)));
47 }
48
49 return v;
50 }
51
52 Annotation::Annotation(){
53 n = NULL;
54 cerr << "Created Annotation with NULL Note" << endl;
55 }
56
57 Annotation::~Annotation(){
58 // do nothing
59 }
60
61 Annotation::Annotation(struct Note *n){
62 this->n = n;
63 }
64
65 const char *
66 Annotation::getId() const{
67 symchar *m = GetNoteId(n);
68 if(m==NULL){
69 return NULL;
70 }
71 return SCP(m);
72 }
73
74 /**
75 @return the name of the method to which this note was assigned, or NULL if the note was not assigned to a method.
76 */
77 const char *
78 Annotation::getMethod() const{
79 symchar *m = GetNoteMethod(n);
80 if(m==NULL){
81 return NULL;
82 }
83 return SCP(m);
84 }
85
86 /**
87 @return the name of the type to which this note is assigned
88 */
89 const SymChar
90 Annotation::getType() const{
91 asc_assert(GetNoteType(n)!=NULL);
92 return SymChar(SCP(GetNoteType(n)));
93 }
94
95 /**
96 Get the 'language' of a note. This roughly corresponds to the *purpose*
97 that the note exists for: informing the end-user, providing parameters to
98 the solver, giving additional data such as icons for a dreamt-of flowsheet
99 GUI, etc.
100
101 @return the 'language' of the note
102 */
103 const SymChar
104 Annotation::getLanguage() const{
105 asc_assert(GetNoteLanguage(n)!=NULL);
106 return SymChar(SCP(GetNoteLanguage(n)));
107 }
108
109 /**
110 @return the filename to which this note is assigned (where it was declared)
111 */
112 const char *
113 Annotation::getFilename() const{
114 return GetNoteFilename(n);
115 }
116
117 /**
118 @return the line number where this note was assigned
119 */
120 const int
121 Annotation::getLineNumber() const{
122 return GetNoteLineNum(n);
123 }
124
125 /**
126 @return the text content of this note (might be quite big, possibly)
127 */
128 const char *
129 Annotation::getText() const{
130 return BraceCharString(GetNoteText(n));
131 }
132
133 /**
134 @return the data type code for this note. Note sure what can be done with
135 this just yet.
136 */
137 const int
138 Annotation::getDataType() const{
139 return (int)GetNoteEnum(n);
140 }

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