classifierinfo.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "classifierinfo.h"
00014
00015 #include "../classifier.h"
00016 #include "../operation.h"
00017
00018 ClassifierInfo::ClassifierInfo( UMLClassifier *classifier , UMLDoc *)
00019 {
00020
00021 init(classifier);
00022 }
00023
00024 ClassifierInfo::~ClassifierInfo() { }
00025
00026 void ClassifierInfo::init(UMLClassifier *c) {
00027
00028
00029 atpub.setAutoDelete(false);
00030 atprot.setAutoDelete(false);
00031 atpriv.setAutoDelete(false);
00032
00033 static_atpub.setAutoDelete(false);
00034 static_atprot.setAutoDelete(false);
00035 static_atpriv.setAutoDelete(false);
00036
00037
00038 className = c->getName();
00039 fileName = c->getName().lower();
00040
00041
00042 isInterface = c->isInterface();
00043
00044
00045 m_nID = c->getID();
00046
00047
00048 if(!isInterface) {
00049 UMLAttributeList atl = c->getAttributeList();
00050 for(UMLAttribute *at=atl.first(); at ; at=atl.next()) {
00051 switch(at->getVisibility())
00052 {
00053 case Uml::Visibility::Public:
00054 if(at->getStatic())
00055 static_atpub.append(at);
00056 else
00057 atpub.append(at);
00058 break;
00059 case Uml::Visibility::Protected:
00060 if(at->getStatic())
00061 static_atprot.append(at);
00062 else
00063 atprot.append(at);
00064 break;
00065 case Uml::Visibility::Private:
00066 case Uml::Visibility::Implementation:
00067 if(at->getStatic())
00068 static_atpriv.append(at);
00069 else
00070 atpriv.append(at);
00071 break;
00072 }
00073 m_AttsList.append(at);
00074 }
00075 }
00076
00077
00078 superclasses = c->getSuperClasses();
00079 superclasses.setAutoDelete(false);
00080
00081 subclasses = c->getSubClasses();
00082 subclasses.setAutoDelete(false);
00083
00084
00085 plainAssociations = c->getSpecificAssocs(Uml::at_Association);
00086 plainAssociations.setAutoDelete(false);
00087
00088 uniAssociations = c->getUniAssociationToBeImplemented();
00089 uniAssociations.setAutoDelete(false);
00090
00091 aggregations = c->getAggregations();
00092 aggregations.setAutoDelete(false);
00093
00094 compositions = c->getCompositions();
00095 compositions.setAutoDelete(false);
00096
00097
00098 hasAssociations = plainAssociations.count() > 0 || aggregations.count() > 0 || compositions.count() > 0 || uniAssociations.count() > 0;
00099 hasAttributes = atpub.count() > 0 || atprot.count() > 0 || atpriv.count() > 0
00100 || static_atpub.count() > 0
00101 || static_atprot.count() > 0
00102 || static_atpriv.count() > 0;
00103
00104 hasStaticAttributes = static_atpub.count() > 0
00105 || static_atprot.count() > 0
00106 || static_atpriv.count() > 0;
00107
00108 hasAccessorMethods = hasAttributes || hasAssociations;
00109
00110 hasOperationMethods = c->getOpList().last() ? true : false;
00111
00112 hasMethods = hasOperationMethods || hasAccessorMethods;
00113
00114
00115
00116
00117 hasVectorFields = hasAssociations ? true : false;
00118
00119
00120 }
00121
00122 UMLClassifierList ClassifierInfo::getPlainAssocChildClassifierList() {
00123 return findAssocClassifierObjsInRoles(&plainAssociations);
00124 }
00125
00126 UMLClassifierList ClassifierInfo::getAggregateChildClassifierList() {
00127 return findAssocClassifierObjsInRoles(&aggregations);
00128 }
00129
00130 UMLClassifierList ClassifierInfo::getCompositionChildClassifierList() {
00131 return findAssocClassifierObjsInRoles(&compositions);
00132 }
00133
00134 UMLClassifierList ClassifierInfo::findAssocClassifierObjsInRoles (UMLAssociationList * list)
00135 {
00136
00137
00138 UMLClassifierList classifiers;
00139 classifiers.setAutoDelete(false);
00140
00141 for (UMLAssociation *a = list->first(); a; a = list->next()) {
00142
00143
00144
00145
00146
00147 if (a->getObjectId(Uml::A) == m_nID && !a->getRoleName(Uml::B).isEmpty()) {
00148 UMLClassifier *c = dynamic_cast<UMLClassifier*>(a->getObject(Uml::B));
00149 if(c)
00150 classifiers.append(c);
00151 } else if (a->getObjectId(Uml::B) == m_nID && !a->getRoleName(Uml::A).isEmpty()) {
00152 UMLClassifier *c = dynamic_cast<UMLClassifier*>(a->getObject(Uml::A));
00153 if(c)
00154 classifiers.append(c);
00155 }
00156 }
00157
00158 return classifiers;
00159 }
00160
00161 UMLAttributeList* ClassifierInfo::getAttList() {
00162 return &m_AttsList;
00163 }
00164
This file is part of the documentation for umbrello Version 3.1.0.