File: UmlBaseComponent.cpp

package info (click to toggle)
bouml 4.21-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 73,336 kB
  • ctags: 55,459
  • sloc: cpp: 290,644; makefile: 228; sh: 13
file content (101 lines) | stat: -rw-r--r-- 2,491 bytes parent folder | download | duplicates (3)
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

#include "UmlBaseComponent.h"
#include "UmlComponent.h"
#include "UmlComponentView.h"
#include "UmlComponentDiagram.h"
#include "UmlClass.h"

#include "UmlCom.h"
UmlComponent * UmlBaseComponent::create(UmlComponentView * parent, const char * s)
{
  return (UmlComponent *) parent->create_(aComponent, s);
}

anItemKind UmlBaseComponent::kind() {
  return aComponent;
}

UmlComponentDiagram * UmlBaseComponent::associatedDiagram() {
  read_if_needed_();
  
  return _assoc_diagram;
}

bool UmlBaseComponent::set_AssociatedDiagram(UmlComponentDiagram * 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;
}

const QVector<UmlClass> & UmlBaseComponent::realizingClasses() {
  read_if_needed_();
  
  return _realizing;
}

const QVector<UmlClass> & UmlBaseComponent::providedClasses() {
  read_if_needed_();
  
  return _provided;
}

const QVector<UmlClass> & UmlBaseComponent::requiredClasses() {
  read_if_needed_();
  
  return _required;
}

bool UmlBaseComponent::set_AssociatedClasses(const QVector<UmlClass> & realizing, const QVector<UmlClass> & provided, const QVector<UmlClass> & required) {
  UmlCom::send_cmd(_identifier, setAssocClassesCmd,
		   realizing, provided, required);
  if (UmlCom::read_bool()) {
    if (_defined) {
      // tests != to bypass Qt 2.3 bug
      if (&_realizing != &realizing) _realizing = realizing;
      if (&_provided != &provided) _provided = provided;
      if (&_required != &required) _required = required;
    }
    return TRUE;
  }
  else
    return FALSE;
}

void UmlBaseComponent::unload(bool rec, bool del) {
  _realizing.clear();
  _provided.clear();
  _required.clear();

  UmlBaseItem::unload(rec, del);
}

void UmlBaseComponent::read_uml_() {
  _assoc_diagram = (UmlComponentDiagram *) UmlBaseItem::read_();
  UmlBaseItem::read_uml_();
  
  unsigned n;
  unsigned index;
  
  n = UmlCom::read_unsigned();
  _realizing.resize(n);
    
  for (index = 0; index != n; index += 1)
    _realizing.insert(index, (UmlClass *) UmlBaseItem::read_());

  n = UmlCom::read_unsigned();
  _provided.resize(n);
    
  for (index = 0; index != n; index += 1)
    _provided.insert(index, (UmlClass *) UmlBaseItem::read_());

  n = UmlCom::read_unsigned();
  _required.resize(n);
    
  for (index = 0; index != n; index += 1)
    _required.insert(index, (UmlClass *) UmlBaseItem::read_());
}