summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRalf Habacker <ralf.habacker@freenet.de>2016-09-02 10:32:25 (GMT)
committerRalf Habacker <ralf.habacker@freenet.de>2016-09-02 10:32:25 (GMT)
commit98966230b2ff8e18f90402decb622ac96549c220 (patch)
tree43ce9d8f22ace298beb7a7ac47c9cca802be4fa5
parentd66dbe58cf315a849181be318a337a8f61f5a989 (diff)
Add uml model type checker and wrapper methods to class UMLObject.
This wrapper reduces the required effort to use the model classes.
-rw-r--r--umbrello/umlmodel/umlobject.cpp54
-rw-r--r--umbrello/umlmodel/umlobject.h80
2 files changed, 134 insertions, 0 deletions
diff --git a/umbrello/umlmodel/umlobject.cpp b/umbrello/umlmodel/umlobject.cpp
index a80d8e9..62e28d7 100644
--- a/umbrello/umlmodel/umlobject.cpp
+++ b/umbrello/umlmodel/umlobject.cpp
@@ -1158,3 +1158,57 @@ QDebug operator<<(QDebug out, const UMLObject& obj)
return out.space();
}
+//only required for getting types
+#include "actor.h"
+#include "artifact.h"
+#include "association.h"
+#include "attribute.h"
+#include "umlcanvasobject.h"
+#include "category.h"
+#include "checkconstraint.h"
+#include "classifier.h"
+#include "component.h"
+#include "entity.h"
+#include "entityattribute.h"
+#include "entityconstraint.h"
+#include "enum.h"
+#include "enumliteral.h"
+#include "folder.h"
+#include "foreignkeyconstraint.h"
+#include "node.h"
+#include "operation.h"
+#include "package.h"
+#include "port.h"
+#include "umlrole.h"
+#include "stereotype.h"
+#include "template.h"
+#include "uniqueconstraint.h"
+#include "usecase.h"
+
+UMLActor* UMLObject::asUMLActor() {return dynamic_cast<UMLActor*>(this); }
+UMLArtifact* UMLObject::asUMLArtifact() { return dynamic_cast<UMLArtifact*>(this); }
+UMLAssociation* UMLObject::asUMLAssociation() { return dynamic_cast<UMLAssociation*>(this); }
+UMLAttribute* UMLObject::asUMLAttribute() { return dynamic_cast<UMLAttribute*>(this); }
+UMLCanvasObject* UMLObject::asUMLCanvasObject() { return dynamic_cast<UMLCanvasObject*>(this); }
+UMLCategory* UMLObject::asUMLCategory() { return dynamic_cast<UMLCategory*>(this); }
+UMLCheckConstraint* UMLObject::asUMLCheckConstraint() { return dynamic_cast<UMLCheckConstraint*>(this); }
+UMLClassifier* UMLObject::asUMLClassifier() { return dynamic_cast<UMLClassifier*>(this); }
+UMLComponent* UMLObject::asUMLComponent() { return dynamic_cast<UMLComponent*>(this); }
+UMLEntity* UMLObject::asUMLEntity() { return dynamic_cast<UMLEntity*>(this); }
+UMLEntityAttribute* UMLObject::asUMLEntityAttribute() { return dynamic_cast<UMLEntityAttribute*>(this); }
+UMLEntityConstraint* UMLObject::asUMLEntityConstraint() { return dynamic_cast<UMLEntityConstraint*>(this); }
+UMLEnum* UMLObject::asUMLEnum() { return dynamic_cast<UMLEnum*>(this); }
+UMLEnumLiteral* UMLObject::asUMLEnumLiteral() { return dynamic_cast<UMLEnumLiteral*>(this); }
+UMLFolder* UMLObject::asUMLFolder() { return dynamic_cast<UMLFolder*>(this); }
+UMLForeignKeyConstraint* UMLObject::asUMLForeignKeyConstraint() { return dynamic_cast<UMLForeignKeyConstraint*>(this); }
+UMLNode* UMLObject::asUMLNode() { return dynamic_cast<UMLNode*>(this); }
+UMLObject* UMLObject::asUMLObject() { return dynamic_cast<UMLObject*>(this); }
+UMLOperation* UMLObject::asUMLOperation() { return dynamic_cast<UMLOperation*>(this); }
+UMLPackage* UMLObject::asUMLPackage() { return dynamic_cast<UMLPackage*>(this); }
+UMLPort* UMLObject::asUMLPort() { return dynamic_cast<UMLPort*>(this); }
+UMLRole* UMLObject::asUMLRole() { return dynamic_cast<UMLRole*>(this); }
+UMLStereotype* UMLObject::asUMLStereotype() { return dynamic_cast<UMLStereotype*>(this); }
+UMLTemplate* UMLObject::asUMLTemplate() { return dynamic_cast<UMLTemplate*>(this); }
+UMLUniqueConstraint* UMLObject::asUMLUniqueConstraint() { return dynamic_cast<UMLUniqueConstraint*>(this); }
+UMLUseCase* UMLObject::asUMLUseCase() { return dynamic_cast<UMLUseCase*>(this); }
+
diff --git a/umbrello/umlmodel/umlobject.h b/umbrello/umlmodel/umlobject.h
index 66282b0..0830aba 100644
--- a/umbrello/umlmodel/umlobject.h
+++ b/umbrello/umlmodel/umlobject.h
@@ -21,7 +21,32 @@
#include <QPointer>
#include <QString>
+class UMLActor;
+class UMLArtifact;
+class UMLAssociation;
+class UMLAttribute;
+class UMLCanvasObject;
+class UMLCategory;
+class UMLCheckConstraint;
+class UMLClassifier;
+class UMLClassifierSet;
+class UMLComponent;
+class UMLEntity;
+class UMLEntityAttribute;
+class UMLEntityConstraint;
+class UMLEnum;
+class UMLEnumLiteral;
+class UMLFolder;
+class UMLForeignKeyConstraint;
+class UMLNode;
+class UMLOperation;
+class UMLPackage;
+class UMLPort;
+class UMLRole;
class UMLStereotype;
+class UMLTemplate;
+class UMLUniqueConstraint;
+class UMLUseCase;
/**
* This class is the non-graphical version of @ref UMLWidget. These are
@@ -156,6 +181,61 @@ public:
friend QDebug operator<< (QDebug out, const UMLObject& obj);
+ bool isUMLActor() { return baseType() == ot_Actor; }
+ bool isUMLArtifact() { return baseType() == ot_Artifact; }
+ bool isUMLAssociation() { return baseType() == ot_Association; }
+ bool isUMLAttribute() { return baseType() == ot_Attribute; }
+ //bool isUMLCanvasObject() { return baseType() == ot_CanvasObject; }
+ bool isUMLCategory() { return baseType() == ot_Category; }
+ bool isUMLCheckConstraint() { return baseType() == ot_CheckConstraint; }
+ bool isUMLClassifier() { return baseType() == ot_Class; }
+ bool isUMLComponent() { return baseType() == ot_Component; }
+ bool isUMLEntity() { return baseType() == ot_Entity; }
+ bool isUMLEntityAttribute() { return baseType() == ot_EntityAttribute; }
+ bool isUMLEntityConstraint() { return baseType() == ot_EntityConstraint; }
+ bool isUMLEnum() { return baseType() == ot_Enum; }
+ bool isUMLEnumLiteral() { return baseType() == ot_EnumLiteral; }
+ bool isUMLFolder() { return baseType() == ot_Folder; }
+ bool isUMLForeignKeyConstraint() { return baseType() == ot_ForeignKeyConstraint; }
+ bool isUMLNode() { return baseType() == ot_Node; }
+ bool isUMLObject() { return baseType() == ot_UMLObject; }
+ bool isUMLOperation() { return baseType() == ot_Operation; }
+ bool isUMLPackage() { return baseType() == ot_Package; }
+ bool isUMLPort() { return baseType() == ot_Port; }
+ bool isUMLRole() { return baseType() == ot_Role; }
+ bool isUMLStereotype() { return baseType() == ot_Stereotype; }
+ bool isUMLTemplate() { return baseType() == ot_Template; }
+ bool isUMLUniqueConstraint() { return baseType() == ot_UniqueConstraint; }
+ bool isUMLUseCase() { return baseType() == ot_UseCase; }
+
+ UMLActor* asUMLActor();
+ UMLArtifact* asUMLArtifact();
+ UMLAssociation* asUMLAssociation();
+ UMLAttribute* asUMLAttribute();
+ UMLCanvasObject* asUMLCanvasObject();
+ UMLCategory* asUMLCategory();
+ UMLCheckConstraint* asUMLCheckConstraint();
+ UMLClassifier* asUMLClassifier();
+ UMLClassifierSet* asUMLClassifierSet();
+ UMLComponent* asUMLComponent();
+ UMLEntity* asUMLEntity();
+ UMLEntityAttribute* asUMLEntityAttribute();
+ UMLEntityConstraint* asUMLEntityConstraint();
+ UMLEnum* asUMLEnum();
+ UMLEnumLiteral* asUMLEnumLiteral();
+ UMLFolder* asUMLFolder();
+ UMLForeignKeyConstraint* asUMLForeignKeyConstraint();
+ UMLNode* asUMLNode();
+ UMLObject* asUMLObject();
+ UMLOperation* asUMLOperation();
+ UMLPackage* asUMLPackage();
+ UMLPort* asUMLPort();
+ UMLRole* asUMLRole();
+ UMLStereotype* asUMLStereotype();
+ UMLTemplate* asUMLTemplate();
+ UMLUniqueConstraint* asUMLUniqueConstraint();
+ UMLUseCase* asUMLUseCase();
+
public slots:
void emitModified();