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 "classnode.h"
26
ClassNode::ClassNode(CRGraph *g): StringListNode2(g) {
27
SetStringLabel("Attribute");
28
SetStringListLabel("Attributes");
29
SetStringLabel2("Operation");
30
SetStringListLabel2("Operations");
33
ClassNode::TextErrType ClassNode::SetAttribute(
34
const string *s, unsigned n, bool update) {
35
if (*s != "" && s->letters()==0)
36
return ClassNode::IMPOSSIBLE_ATTRIBUTE;
38
return ClassNode::OPERATION_EXISTS;
39
if (HasAttribute(s)) {
40
if (n >= NrAttributes() || *GetAttribute(n) != *s ||
42
return ClassNode::ATTRIBUTE_EXISTS;
44
SetString(s, n, update);
45
return ClassNode::MEMBER_OK;
48
ClassNode::TextErrType ClassNode::SetOperation(
49
const string *s, unsigned n, bool update) {
50
if (*s != "" && s->letters()==0)
51
return ClassNode::IMPOSSIBLE_ATTRIBUTE;
53
return ClassNode::ATTRIBUTE_EXISTS;
54
if (HasOperation(s)) {
55
if (n >= NrOperations() || *GetOperation(n) != *s || !update)
56
return ClassNode::OPERATION_EXISTS;
58
SetString2(s, n, update);
59
return ClassNode::MEMBER_OK;
62
const string *ClassNode::GetAttribute(unsigned n) {
66
unsigned ClassNode::NrAttributes() {
70
const string *ClassNode::GetOperation(unsigned n) {
74
unsigned ClassNode::NrOperations() {
78
bool ClassNode::HasAttribute(const string *s) {
82
bool ClassNode::HasOperation(const string *s) {
86
bool ClassNode::ReadMembers(InputFile *ifile, double format) {
89
s1 = *GetStringListLabel2();
90
s2 = *GetStringLabel2();
91
SetStringListLabel2("Actions");
92
SetStringLabel2("Action");
94
bool b = StringListNode2::ReadMembers(ifile, format);
96
SetStringListLabel2(&s1);