1
////////////////////////////////////////////////////////////////////////////////
3
// This file is part of Toolkit for Conceptual Modeling (TCM).
4
// (c) copyright 1996, Vrije Universiteit Amsterdam.
5
// Author: Frank Dehne (frank@cs.vu.nl).
7
// TCM is free software; you can redistribute it and/or modify
8
// it under the terms of the GNU General Public License as published by
9
// the Free Software Foundation; either version 2 of the License, or
10
// (at your option) any later version.
12
// TCM is distributed in the hope that it will be useful,
13
// but WITHOUT ANY WARRANTY; without even the implied warranty of
14
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
// GNU General Public License for more details.
17
// You should have received a copy of the GNU General Public License
18
// along with TCM; if not, write to the Free Software
19
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
21
////////////////////////////////////////////////////////////////////////////////
22
#include "dataprocess.h"
23
#include "inputfile.h"
24
#include "outputfile.h"
28
DataProcess::DataProcess(DFGraph *g): DFProcess(g) {
31
activationMechanism = UNSPECIFIED;
37
bool DataProcess::SetReferences(AssocList *al) {
38
return DFNode::SetReferences(al);
41
void DataProcess::SetProcessGroup(bool b) {
46
activationMechanism = UNSPECIFIED;
52
void DataProcess::SetInstantaneous(bool b) {
53
if (check(!processGroup))
56
activationMechanism = UNSPECIFIED;
62
void DataProcess::SetMinispec(const string *s) {
63
if (check(!processGroup))
69
void DataProcess::SetActivationMechanism(ActivationType a) {
70
if (check(!processGroup && instantaneous))
71
activationMechanism = a;
73
activationMechanism = UNSPECIFIED;
74
if (activationMechanism != TIME)
76
if (activationMechanism != STIMULUS)
80
void DataProcess::SetStimulus(const string *s) {
81
if (check(activationMechanism == STIMULUS))
87
void DataProcess::SetTimeExpression(const string *s) {
88
if (check(activationMechanism == TIME))
94
void DataProcess::WriteMembers(OutputFile *ofile) {
95
DFProcess::WriteMembers(ofile);
96
(*ofile) << "\t{ ProcessGroup " << (processGroup?"True":"False") << " }\n";
98
(*ofile) << "\t{ Persistence " <<
99
(instantaneous?"Instantaneous":"Continuing") << " }\n";
100
(*ofile) << "\t{ Minispec " << '"' << minispec << '"' << " }\n";
103
ActivationType2String(activationMechanism, &nm);
104
(*ofile) << "\t{ ActivationMechanism " << nm << " }\n";
105
if (activationMechanism == STIMULUS) {
106
(*ofile) << "\t{ Stimulus " << '"' <<
107
stimulus << '"' << " }\n";
109
else if (activationMechanism == TIME) {
110
(*ofile) << "\t{ TimeExpression " << '"' << timeExpression
117
bool DataProcess::ReadMembers(InputFile *ifile, double format) {
118
if (!DFProcess::ReadMembers(ifile, format))
120
if (format >= 1.13) {
122
if (!ifile->ReadAttribute("ProcessGroup", &val))
124
processGroup = (val %= "True");
126
// it's a data process.
127
if (!ifile->ReadAttribute("Persistence", &val))
129
instantaneous = (val %= "Instantaneous");
130
if (!ifile->ReadStringAttribute("Minispec", &minispec))
133
if (!ifile->ReadAttribute("ActivationMechanism", &val))
135
activationMechanism = String2ActivationType(&val);
136
if (activationMechanism == STIMULUS) {
137
if (!ifile->ReadStringAttribute("Stimulus", &stimulus))
140
else if (activationMechanism == TIME) {
141
if (!ifile->ReadStringAttribute("TimeExpression",
151
void DataProcess::ActivationType2String(DataProcess::ActivationType tp, string *nm) {
152
if (tp == UNSPECIFIED)
154
else if (tp == TRIGGER)
156
else if (tp == STIMULUS)
161
error("%s, line %d: unknown activation mechanism\n",
167
DataProcess::ActivationType DataProcess::String2ActivationType(const string *nm) {
168
if (*nm == "Unspecified")
170
else if (*nm == "Trigger")
172
else if (*nm == "Stimulus")
174
else if (*nm == "Time")
177
error("%s, line %d: unknown activation mechanism\n", __FILE__, __LINE__);