本文整理汇总了C++中UMLClassifier类的典型用法代码示例。如果您正苦于以下问题:C++ UMLClassifier类的具体用法?C++ UMLClassifier怎么用?C++ UMLClassifier使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UMLClassifier类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: writeRealizationsRecursive
void CSharpWriter::writeRealizationsRecursive(UMLClassifier *currentClass, UMLAssociationList *realizations, QTextStream &cs) {
UMLAssociation *a;
for (a = realizations->first(); a; a = realizations->next()) {
// we know its a classifier if its in the list
UMLClassifier *real = (UMLClassifier*)a->getObject(Uml::B);
//FIXME: Interfaces realize themselves without this condition!?
if (real == currentClass)
continue;
// collect operations of one realization
UMLOperationList opreal = real->getOpList();
// write realizations
cs << m_endl << m_container_indent << m_indentation << "#region " << real->getName() << " members" << m_endl << m_endl;
writeOperations(opreal,cs,false,false,true);
cs << m_container_indent << m_indentation << "#endregion" << m_endl << m_endl;
// Recurse to parent realizations
UMLAssociationList parentReal = real->getRealizations();
if (!parentReal.isEmpty()) {
writeRealizationsRecursive(real, &parentReal, cs);
}
}
}
示例2: getUniqueID
/**
* Get a unique id for this codedocument.
* @return id for the codedocument
*/
QString CodeGenerator::getUniqueID(CodeDocument * codeDoc)
{
QString id = codeDoc->getID();
// does this document already exist? then just return its present id
if (!id.isEmpty() && findCodeDocumentByID(id)) {
return id;
}
// approach now differs by whether or not it is a classifier code document
ClassifierCodeDocument * classDoc = dynamic_cast<ClassifierCodeDocument*>(codeDoc);
if (classDoc) {
UMLClassifier *c = classDoc->getParentClassifier();
id = ID2STR(c->id()); // this is supposed to be unique already..
}
else {
QString prefix = "doc";
QString id = prefix + "_0";
int number = lastIDIndex;
for ( ; findCodeDocumentByID(id); ++number) {
id = prefix + '_' + QString::number(number);
}
lastIDIndex = number;
}
return id;
}
示例3: classifier
/**
* Reimplemented from UMLWidget::saveToXMI to save
* classifierwidget data either to 'interfacewidget' or 'classwidget'
* XMI element.
*/
void ClassifierWidget::saveToXMI(QDomDocument & qDoc, QDomElement & qElement)
{
QDomElement conceptElement;
UMLClassifier *umlc = classifier();
QString tagName = umlc->isInterface() ?
"interfacewidget" : "classwidget";
conceptElement = qDoc.createElement(tagName);
UMLWidget::saveToXMI( qDoc, conceptElement );
conceptElement.setAttribute("showoperations", visualProperty(ShowOperations));
conceptElement.setAttribute("showpubliconly", visualProperty(ShowPublicOnly));
conceptElement.setAttribute("showopsigs", m_operationSignature);
conceptElement.setAttribute("showpackage", visualProperty(ShowPackage));
conceptElement.setAttribute("showscope", visualProperty(ShowVisibility));
if (! umlc->isInterface()) {
conceptElement.setAttribute("showattributes", visualProperty(ShowAttributes));
conceptElement.setAttribute("showattsigs", m_attributeSignature);
}
if (umlc->isInterface() || umlc->isAbstract()) {
conceptElement.setAttribute("drawascircle", visualProperty(DrawAsCircle));
}
qElement.appendChild(conceptElement);
}
示例4: i18n
/**
* Checks if changes are valid and applies them if they are,
* else returns false
*/
bool UMLTemplateDialog::apply()
{
m_datatypeWidget->apply();
QString name = m_pNameLE->text();
if(name.length() == 0) {
KMessageBox::error(this, i18n("You have entered an invalid template name."),
i18n("Template Name Invalid"), 0);
m_pNameLE->setText(m_pTemplate->name());
return false;
}
UMLClassifier * pClass = dynamic_cast<UMLClassifier *>(m_pTemplate->parent());
if (pClass) {
UMLObject *o = pClass->findChildObject(name);
if (o && o != m_pTemplate) {
KMessageBox::error(this, i18n("The template parameter name you have chosen is already being used in this operation."),
i18n("Template Name Not Unique"), 0);
m_pNameLE->setText(m_pTemplate->name());
return false;
}
}
m_pTemplate->setName(name);
m_stereotypeWidget->apply();
m_docWidget->apply();
return true;
}
示例5: text
bool UMLOperationDialog::apply()
{
QString name = m_pNameLE -> text();
if( name.length() == 0 ) {
KMessageBox::error(this, i18n("You have entered an invalid operation name."),
i18n("Operation Name Invalid"), false);
m_pNameLE -> setText( m_pOperation -> getName() );
return false;
}
UMLClassifier *classifier = dynamic_cast<UMLClassifier*>( m_pOperation->parent() );
if( classifier != 0L &&
classifier->checkOperationSignature(name, m_pOperation->getParmList(), m_pOperation) )
{
QString msg = QString(i18n("An operation with that signature already exists in %1.\n")).arg(classifier->getName())
+
QString(i18n("Choose a different name or parameter list." ));
KMessageBox::error(this, msg, i18n("Operation Name Invalid"), false);
return false;
}
m_pOperation -> setName( name );
if( m_pPublicRB -> isChecked() )
m_pOperation -> setVisibility( Uml::Visibility::Public );
else if( m_pPrivateRB -> isChecked() )
m_pOperation -> setVisibility( Uml::Visibility::Private );
else if (m_pProtectedRB -> isChecked() )
m_pOperation -> setVisibility( Uml::Visibility::Protected );
else if (m_pImplementationRB -> isChecked() )
m_pOperation -> setVisibility( Uml::Visibility::Implementation );
QString typeName = m_pRtypeCB->currentText();
UMLTemplate *tmplParam = classifier->findTemplate(typeName);
if (tmplParam)
m_pOperation->setType(tmplParam);
else
m_pOperation->setTypeName(typeName);
m_pOperation->setStereotype( m_pStereoTypeCB->currentText() );
bool isAbstract = m_pAbstractCB->isChecked();
m_pOperation -> setAbstract( isAbstract );
if (isAbstract) {
/* If any operation is abstract then the owning class needs
to be made abstract.
The inverse is not true: The fact that no operation is
abstract does not mean that the class must be non-abstract.
*/
classifier->setAbstract(true);
}
m_pOperation->setStatic( m_pStaticCB->isChecked() );
m_pOperation->setConst( m_pQueryCB->isChecked() );
return true;
}
示例6: fm
QSize EntityWidget::calculateSize() {
if (!m_pObject) {
return UMLWidget::calculateSize();
}
int width, height;
QFont font = UMLWidget::getFont();
font.setItalic(false);
font.setUnderline(false);
font.setBold(false);
const QFontMetrics fm(font);
const int fontHeight = fm.lineSpacing();
int lines = 1;//always have one line - for name
if ( !m_pObject->getStereotype().isEmpty() ) {
lines++;
}
const int numberOfEntityAttributes = ((UMLEntity*)m_pObject)->entityAttributes();
height = width = 0;
//set the height of the entity
lines += numberOfEntityAttributes;
if (numberOfEntityAttributes == 0) {
height += fontHeight / 2; //no entity literals, so just add a bit of space
}
height += lines * fontHeight;
//now set the width of the concept
//set width to name to start with
// FIXME spaces to get round beastie with font width,
// investigate UMLWidget::getFontMetrics()
width = getFontMetrics(FT_BOLD_ITALIC).boundingRect(' ' + getName() + ' ').width();
const int w = getFontMetrics(FT_BOLD).boundingRect(m_pObject->getStereotype(true)).width();
width = w > width?w:width;
UMLClassifier* classifier = (UMLClassifier*)m_pObject;
UMLClassifierListItemList list = classifier->getFilteredList(Uml::ot_EntityAttribute);
UMLClassifierListItem* listItem = 0;
for (listItem = list.first(); listItem; listItem = list.next()) {
int w = fm.width( listItem->getName() );
width = w > width?w:width;
}
//allow for width margin
width += ENTITY_MARGIN * 2;
return QSize(width, height);
}
示例7: Q_UNUSED
/**
* Event handler for hover leave events.
*/
void ClassifierWidget::hoverLeaveEvent(UMLSceneHoverEvent * event)
{
Q_UNUSED(event);
if (!visualProperty(DrawAsCircle)) {
UMLClassifier* umlC = classifier();
if (umlC && !umlC->isInterface()) {
m_attributeExpanderBox->setVisible(false);
}
m_operationExpanderBox->setVisible(false);
}
}
示例8: getParentDocument
// we basically want to update the doc and start text of this method
void RubyCodeOperation::updateMethodDeclaration()
{
CodeDocument * doc = getParentDocument();
RubyClassifierCodeDocument * rubydoc = dynamic_cast<RubyClassifierCodeDocument*>(doc);
UMLClassifier *c = rubydoc->getParentClassifier();
UMLOperation * o = getParentOperation();
bool isInterface = rubydoc->getParentClassifier()->isInterface();
QString endLine = getNewLineEndingChars();
// now, the starting text.
//:UNUSED: QString strVis = o->visibility().toString();
// no return type for constructors
QString fixedReturn = RubyCodeGenerator::cppToRubyType(o->getTypeName());
QString returnType = o->isConstructorOperation() ? QString("") : (fixedReturn + QString(" "));
QString methodName = o->name();
QString RubyClassName = rubydoc->getRubyClassName(c->name());
// Skip destructors, and operator methods which
// can't be defined in ruby
if ( methodName.startsWith('~')
|| QRegExp("operator\\s*(=|--|\\+\\+|!=)$").exactMatch(methodName) )
{
getComment()->setText("");
return;
}
if (RubyClassName == methodName) {
methodName = "initialize";
}
methodName.remove(QRegExp("operator\\s*"));
methodName = methodName.mid(0, 1).toLower() + methodName.mid(1);
QString paramStr = QString("");
QStringList commentedParams;
// assemble parameters
UMLAttributeList list = getParentOperation()->getParmList();
int nrofParam = list.count();
int paramNum = 0;
foreach (UMLAttribute* parm, list) {
QString paramName = RubyCodeGenerator::cppToRubyName(parm->name());
paramStr += paramName;
if (! parm->getInitialValue().isEmpty()) {
paramStr += QString(" = ") + RubyCodeGenerator::cppToRubyType(parm->getInitialValue());
}
paramNum++;
if (paramNum != nrofParam )
paramStr += ", ";
}
示例9: PythonWriterTest
void TEST_pythonwriter::test_writeClass()
{
PythonWriterTest* py = new PythonWriterTest();
UMLClassifier* c = new UMLClassifier("Customer", "12345678");
UMLAttribute* attr;
attr = c->createAttribute("name_");
attr = c->createAttribute("address_");
py->writeClass(c);
// does the just created file exist?
QFile file(temporaryPath() + py->findFileName(c, QLatin1String(".py")));
QCOMPARE(file.exists(), true);
}
示例10: kDebug
void UMLOperationDialog::slotParameterProperties() {
int result = 0;
UMLAttribute* pAtt = 0, * pOldAtt = 0;
pOldAtt = m_pOperation->findParm( m_pParmsLB->currentText() );
if( !pOldAtt ) {
kDebug() << "THE impossible has occurred for:" << m_pParmsLB->currentText() << endl;
return;
}//should never occur
ParmPropDlg dlg(this, m_doc, pOldAtt);
result = dlg.exec();
QString name = dlg.getName();
pAtt = m_pOperation->findParm( name );
if( result ) {
if( name.length() == 0 ) {
KMessageBox::error(this, i18n("You have entered an invalid parameter name."),
i18n("Parameter Name Invalid"), false);
return;
}
if ( !pAtt || pOldAtt->getTypeName() != dlg.getTypeName() ||
pOldAtt->getDoc() != dlg.getDoc() ||
pOldAtt->getInitialValue() != dlg.getInitialValue() ) {
pOldAtt->setName( name );
QString typeName = dlg.getTypeName();
if (pOldAtt->getTypeName() != typeName) {
UMLClassifierList namesList( m_doc->getConcepts() );
UMLClassifier* obj = NULL;
for (obj=namesList.first(); obj!=0; obj=namesList.next()) {
if (typeName == obj->getFullyQualifiedName()) {
pOldAtt->setType( obj );
break;
}
}
if (obj == NULL) {
// Nothing found: set type name directly. Bad.
kDebug() << "UMLOperationDialog::slotParameterProperties: "
<< typeName << " not found." << endl;
pOldAtt->setTypeName( typeName ); // Bad.
}
}
m_pParmsLB->changeItem( dlg.getName(), m_pParmsLB -> currentItem() );
pOldAtt->setDoc( dlg.getDoc() );
pOldAtt->setInitialValue( dlg.getInitialValue() );
m_doc->setModified( true );
} else if( pAtt != pOldAtt ) {
KMessageBox::error(this, i18n("The parameter name you have chosen is already being used in this operation."),
i18n("Parameter Name Not Unique"), false);
}
}
}
示例11: selectedItem
void RefactoringAssistant::createAttribute()
{
QListViewItem *item = selectedItem();
if(!item)
{
kWarning()<<"RefactoringAssistant::createAttribute() "
<<"called with no item selected"<<endl;
return;
}
UMLClassifier *c = dynamic_cast<UMLClassifier*>(findUMLObject( item ));
if( !c )
return;
c->createAttribute();
}
示例12: currentItem
/**
* Create new attribute.
*/
void RefactoringAssistant::createAttribute()
{
QTreeWidgetItem *item = currentItem();
if (!item) {
uWarning() << "Called with no item selected.";
return;
}
UMLClassifier *c = dynamic_cast<UMLClassifier*>(findUMLObject(item));
if (!c) { // find parent
QTreeWidgetItem *parent = item->parent();
c = dynamic_cast<UMLClassifier*>(findUMLObject(parent));
if (!c) {
uWarning() << "No classifier - cannot create!";
return;
}
}
c->createAttribute();
}
示例13: CppWriterTest
void TEST_cppwriter::test_writeClass()
{
CppWriterTest* cpp = new CppWriterTest();
UMLClassifier* c = new UMLClassifier("Customer", "12345678");
UMLAttribute* attr;
attr = c->createAttribute("name_");
attr = c->createAttribute("address_");
UMLOperation* op;
op = c->createOperation("getName");
op = c->createOperation("getAddress");
cpp->writeClass(c);
// does the just created file exist?
QFile fileHeader(temporaryPath() + cpp->findFileName(c, QLatin1String(".h")));
QFile fileCPP(temporaryPath() + cpp->findFileName(c, QLatin1String(".cpp")));
QCOMPARE(fileHeader.exists(), true);
QCOMPARE(fileCPP.exists(), true);
}
示例14: i18n
/**
* Checks if changes are valid and applies them if they are,
* else returns false
*/
bool UMLEntityAttributeDialog::apply()
{
QString name = m_pNameLE->text();
if (name.isEmpty()) {
KMessageBox::error(this, i18n("You have entered an invalid entity attribute name."),
i18n("Entity Attribute Name Invalid"), 0);
m_pNameLE->setText(m_pEntityAttribute->name());
return false;
}
UMLClassifier * pConcept = m_pEntityAttribute->umlParent()->asUMLClassifier();
UMLObject *o = pConcept ? pConcept->findChildObject(name) : 0;
if (o && o != m_pEntityAttribute) {
KMessageBox::error(this, i18n("The entity attribute name you have chosen is already being used in this operation."),
i18n("Entity Attribute Name Not Unique"), 0);
m_pNameLE->setText(m_pEntityAttribute->name());
return false;
}
m_pEntityAttribute->setName(name);
m_pEntityAttribute->setInitialValue(m_pInitialLE->text());
m_stereotypeWidget->apply();
m_pEntityAttribute->setValues(m_pValuesLE->text());
m_pEntityAttribute->setAttributes(m_pAttributesCB->currentText());
m_pEntityAttribute->setAutoIncrement(m_pAutoIncrementCB->isChecked());
m_pEntityAttribute->setNull(m_pNullCB->isChecked());
/*
if (m_pPublicRB->isChecked()) {
m_pEntityAttribute->setIndexType(UMLEntityAttribute::Primary);
} else if (m_pProtectedRB->isChecked()) {
m_pEntityAttribute->setIndexType(UMLEntityAttribute::Unique);
} else
*/
if (m_pPrivateRB->isChecked()) {
m_pEntityAttribute->setIndexType(UMLEntityAttribute::Index);
} else {
m_pEntityAttribute->setIndexType(UMLEntityAttribute::None);
}
m_datatypeWidget->apply();
return true;
}
示例15: findAttributeGroups
// these exist for abstract classes only (which become xs:group nodes)
QStringList XMLSchemaWriter::findAttributeGroups (UMLClassifier *c)
{
// we need to look for any class we inherit from. IF these
// have attributes, then we need to notice
QStringList list;
UMLClassifierList superclasses = c->findSuperClassConcepts(); // list of what inherits from us
for(UMLClassifier *classifier = superclasses.first(); classifier; classifier = superclasses.next())
{
if(classifier->getAbstract())
{
// only classes have attributes..
if (!classifier->isInterface()) {
UMLAttributeList attribs = c->getAttributeList();
if (attribs.count() > 0)
list.append(getElementName(classifier)+"AttribGroupType");
}
}
}
return list;
}