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
|
#include "UmlCom.h"
#include "UmlBaseClassInstance.h"
#include "UmlClassInstance.h"
#include "UmlClass.h"
#include "UmlAttribute.h"
#include "UmlRelation.h"
#include "UmlObjectDiagram.h"
anItemKind UmlBaseClassInstance::kind() {
return aClassInstance;
}
UmlClassInstance * UmlBaseClassInstance::create(UmlItem * parent, const char * name, UmlClass * type)
{
UmlCom::send_cmd(parent->_identifier, createCmd, aClassInstance,
type->_identifier);
UmlClassInstance * result = (UmlClassInstance *) UmlBaseItem::read_();
if (result != 0) {
parent->reread_children_if_needed_();
if (name != 0) result->set_Name(name);
}
return result;
}
UmlClass * UmlBaseClassInstance::type() {
read_if_needed_();
return _type;
}
bool UmlBaseClassInstance::set_Type(UmlClass * v) {
UmlCom::send_cmd(_identifier, setTypeCmd, (v == 0) ? (void *) v : ((UmlBaseItem *) v)->_identifier);
if (UmlCom::read_bool()) {
_type = v;
return TRUE;
}
else
return FALSE;
}
void UmlBaseClassInstance::attributesValue(QValueList<SlotAttribute> & result) {
UmlCom::send_cmd(_identifier, attributesCmd, (char) 0);
unsigned n = UmlCom::read_unsigned();
result.clear();
while (n--) {
UmlAttribute * at = (UmlAttribute *) UmlBaseItem::read_();
result.append(SlotAttribute(at, UmlCom::read_string()));
}
}
void UmlBaseClassInstance::relationsValue(QValueList<SlotRelation> & result) {
UmlCom::send_cmd(_identifier, relationsCmd, (void *) 0);
unsigned n = UmlCom::read_unsigned();
result.clear();
while (n--) {
UmlRelation * r = (UmlRelation *) UmlBaseItem::read_();
result.append(SlotRelation(r, (UmlClassInstance *) UmlBaseItem::read_()));
}
}
void UmlBaseClassInstance::availableAttributes(QVector<UmlAttribute> & result) {
UmlCom::send_cmd(_identifier, attributesCmd, (char) 1);
UmlCom::read_item_list((QVector<UmlItem> &) result);
}
void UmlBaseClassInstance::availableRelations(UmlClassInstance * other, QVector<UmlRelation> & result) {
UmlCom::send_cmd(_identifier, relationsCmd, other->_identifier);
UmlCom::read_item_list((QVector<UmlItem> &) result);
}
bool UmlBaseClassInstance::set_AttributeValue(UmlAttribute * attribute, const char * value) {
UmlCom::send_cmd(_identifier, setAttributeCmd, attribute->_identifier, value);
return UmlCom::read_bool();
}
bool UmlBaseClassInstance::add_Relation(UmlRelation * relation, UmlClassInstance * other) {
QVector<UmlItem> v(2);
v.insert(0, relation);
v.insert(1, other);
UmlCom::send_cmd(_identifier, addRelationCmd, v);
return UmlCom::read_bool();
}
bool UmlBaseClassInstance::remove_Relation(UmlRelation * relation, UmlClassInstance * other) {
QVector<UmlItem> v(2);
v.insert(0, relation);
v.insert(1, other);
UmlCom::send_cmd(_identifier, removeRelationCmd, v);
return UmlCom::read_bool();
}
UmlObjectDiagram * UmlBaseClassInstance::associatedDiagram() {
read_if_needed_();
return _assoc_diagram;
}
bool UmlBaseClassInstance::set_AssociatedDiagram(UmlObjectDiagram * d) {
UmlCom::send_cmd(_identifier, setAssocDiagramCmd, (d == 0) ? (void *) 0 : ((UmlBaseItem *) d)->_identifier);
if (UmlCom::read_bool()) {
_assoc_diagram = d;
return TRUE;
}
else
return FALSE;
}
void UmlBaseClassInstance::read_uml_() {
_assoc_diagram = (UmlObjectDiagram *) UmlBaseItem::read_();
UmlBaseItem::read_uml_();
_type = (UmlClass *) UmlBaseItem::read_();
}
|