cppcodeclassfield.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "cppcodeclassfield.h"
00019
00020
00021 #include <kdebug.h>
00022
00023
00024 #include "../codegenerator.h"
00025 #include "../classifiercodedocument.h"
00026 #include "../attribute.h"
00027 #include "../umlobject.h"
00028 #include "../umlrole.h"
00029 #include "../uml.h"
00030 #include "cppcodegenerationpolicy.h"
00031
00032
00033
00034
00035
00036 CPPCodeClassField::CPPCodeClassField (ClassifierCodeDocument * parentDoc, UMLRole * role)
00037 : CodeClassField(parentDoc, role)
00038 {
00039
00040 }
00041
00042 CPPCodeClassField::CPPCodeClassField (ClassifierCodeDocument * parentDoc, UMLAttribute * attrib)
00043 : CodeClassField(parentDoc, attrib)
00044 {
00045
00046 }
00047
00048 CPPCodeClassField::~CPPCodeClassField ( ) { }
00049
00050
00051
00052
00053
00054
00055
00056
00057 QString CPPCodeClassField::getFieldName() {
00058 if (parentIsAttribute())
00059 {
00060 UMLAttribute * at = (UMLAttribute*) getParentObject();
00061 return cleanName(at->getName());
00062 }
00063 else
00064 {
00065 UMLRole * role = (UMLRole*) getParentObject();
00066 QString roleName = role->getName();
00067 if(fieldIsSingleValue()) {
00068 return roleName.replace(0, 1, roleName.left(1).lower());
00069 } else {
00070 return roleName.lower() + "Vector";
00071 }
00072 }
00073 }
00074
00075 QString CPPCodeClassField::getListFieldClassName () {
00076 CodeGenPolicyExt * p = UMLApp::app()->getPolicyExt();
00077 CPPCodeGenerationPolicy *policy = dynamic_cast<CPPCodeGenerationPolicy*>(p);
00078 return policy->getVectorClassName();
00079 }
00080
00081 QString CPPCodeClassField::getInitialValue() {
00082
00083 if (parentIsAttribute())
00084 {
00085 UMLAttribute * at = dynamic_cast<UMLAttribute*>( getParentObject() );
00086 if (at) {
00087 return fixInitialStringDeclValue(at->getInitialValue(), getTypeName());
00088 } else {
00089 kError() << "CPPCodeClassField::getInitialValue: parent object is not a UMLAttribute"
00090 << endl;
00091 return "";
00092 }
00093 }
00094 else
00095 {
00096 if(fieldIsSingleValue()) {
00097
00098
00099 return "";
00100 } else {
00101 return " new "+getListFieldClassName()+"( )";
00102 }
00103 }
00104
00105 }
00106
00107
00108 #include "cppcodeclassfield.moc"
This file is part of the documentation for umbrello Version 3.1.0.