-
Notifications
You must be signed in to change notification settings - Fork 0
/
Theorie.cpp
123 lines (98 loc) · 2.62 KB
/
Theorie.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#include "Theorie.h"
#include "App.h"
Theorie::Theorie(BString* name)
:LView(*name),
OCamlModule(new BPath()),
fModified(true),
fSignature(new Signature(new BString(""))),
fAxiome_List(new BList()) {
}
Theorie::Theorie(BMessage* archive)
:LView(archive), OCamlModule(archive)
{
archive->FindBool("fModified", &fModified);
//fSignature
BMessage *signatureArchive = new BMessage();
archive->FindMessage("signature", 0, signatureArchive);
if (signatureArchive)
fSignature = new Signature(signatureArchive);
else
fSignature = NULL;
//fAxiome_List
fAxiome_List = new BList();
BMessage *axiomeArchive = new BMessage();
int i=0;
while(archive->FindMessage("axiome", i++, axiomeArchive) == B_OK) {
Axiome *axiome = new Axiome(axiomeArchive);
fAxiome_List->AddItem(axiome);
}
}
Theorie::Theorie(Theorie* theorie)
: LView(theorie), OCamlModule(theorie),
fModified(theorie->GetModified())
{
fAxiome_List = new BList(*theorie->GetAxiomeList());
fSignature = new Signature(theorie->GetSignature());
}
bool Theorie::GetModified() const
{
return fModified;
}
void Theorie::SetModified(bool modified)
{
fModified = modified;
}
BList* Theorie::GetAxiomeList() const
{
return fAxiome_List;
}
Signature* Theorie::GetSignature() const
{
return fSignature;
}
void Theorie::SetSignature(Signature* signature) {
fSignature = new Signature(signature);
}
void Theorie::PrintToStream()
{
puts(GetLatex()->String());
}
status_t Theorie::Archive(BMessage* archive, bool deep)
{
status_t status;
LView::Archive(archive,deep);
OCamlModule::Archive(archive,deep);
status = archive->AddString("class", "Theorie");
if (status < B_OK) return status;
status = archive->AddBool("fModified",false); //when saved, a theory is considered unmodified
if (status < B_OK) return status;
if(fSignature) {
BMessage *archive_Signature = new BMessage();
status = fSignature->Archive(archive_Signature,deep);
if (status < B_OK) return status;
status = archive->AddMessage("signature", archive_Signature);
} else {
status = archive->AddMessage("signature", NULL);
}
if (status < B_OK) return status;
Axiome* axiome;
int index = 0;
while(index < fAxiome_List->CountItems()) {
axiome = (Axiome*)fAxiome_List->ItemAt(index);
BMessage archive_axiome;
axiome->Archive(&archive_axiome,deep);
if (status < B_OK) return status;
status = archive->AddMessage("axiome", &archive_axiome);
index++;
}
return status;
}
BArchivable *
Theorie::Instantiate(BMessage *archive) {
Theorie *theorie;
if (!validate_instantiation(archive, "Theorie")) {
return NULL;
}
theorie = new Theorie(archive);
return theorie;
}