本文整理汇总了C++中UMLAttribute类的典型用法代码示例。如果您正苦于以下问题:C++ UMLAttribute类的具体用法?C++ UMLAttribute怎么用?C++ UMLAttribute使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UMLAttribute类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: attributeAdded
void RefactoringAssistant::attributeAdded( UMLClassifierListItem *a )
{
UMLAttribute *att = static_cast<UMLAttribute*>(a);
UMLClassifier *c = dynamic_cast<UMLClassifier*>(att->parent());
if(!c)
{
kWarning() << "RefactoringAssistant::attributeAdded(" << att->getName()
<< ") - Parent is not a class!" << endl;
return;
}
QListViewItem *item = findListViewItem( c );
if( !item )
{
return;
}
for( QListViewItem *folder = item->firstChild(); folder; folder = folder->nextSibling() )
{
if( folder->text(1) == "attributes" )
{
item = new KListViewItem( folder, att->getName() );
m_umlObjectMap[item] = att;
connect( att, SIGNAL( modified() ), this, SLOT( umlObjectModified() ) );
setVisibilityIcon( item, att );
break;
}
}
}
示例2: getParentObject
QString CPPCodeClassField::getInitialValue() {
if (parentIsAttribute())
{
UMLAttribute * at = dynamic_cast<UMLAttribute*>( getParentObject() );
if (at) {
return fixInitialStringDeclValue(at->getInitialValue(), getTypeName());
} else {
kError() << "CPPCodeClassField::getInitialValue: parent object is not a UMLAttribute"
<< endl;
return "";
}
}
else
{
if(fieldIsSingleValue()) {
// FIX : IF the multiplicity is "1" then we should init a new object here, if its 0 or 1,
// then we can just return 'empty' string (minor problem).
return "";
} else {
return " new "+getListFieldClassName()+"( )";
}
}
}
示例3: umlObject
/**
* Returns the signature of items that are operations.
* @return signature of an operation item, else an empty string
*/
QString UMLListViewItem::toolTip()
{
UMLObject *obj = umlObject();
if (obj) {
switch (obj->baseType()) {
case UMLObject::ot_Class:
return obj->doc();
case UMLObject::ot_Operation:
{
UMLOperation *op = static_cast<UMLOperation*>(obj);
return op->toString(Uml::SignatureType::ShowSig);
}
case UMLObject::ot_Attribute:
{
UMLAttribute *at = static_cast<UMLAttribute*>(obj);
return at->toString(Uml::SignatureType::ShowSig);
}
default:
return QString();
}
}
else {
return QString();
}
}
示例4: advance
/**
* Parse assignments in the form <identifier> '=' <value>
* Instance variables are identified by a prefixed 'self.'.
* @return success status of parsing
*/
bool PythonImport::parseAssignmentStmt(const QString keyword)
{
QString variable = keyword;
advance();
QString value = advance();
if (value == QLatin1String("-"))
value.append(advance());
bool isStatic = true;
if (variable.startsWith(QLatin1String("self."))) {
variable.remove(0,5);
isStatic = false;
}
Uml::Visibility::Enum visibility = Uml::Visibility::Public;
if (variable.startsWith(QLatin1String("__"))) {
visibility = Uml::Visibility::Private;
variable.remove(0, 2);
} else if (variable.startsWith(QLatin1String("_"))) {
visibility = Uml::Visibility::Protected;
variable.remove(0, 1);
}
QString type;
if (value == QLatin1String("[")) {
if (lookAhead() == QLatin1String("]")) {
advance();
type = QLatin1String("list");
value = QLatin1String("");
}
} else if (value == QLatin1String("{")) {
if (lookAhead() == QLatin1String("}")) {
advance();
type = QLatin1String("dict");
value = QLatin1String("");
}
} else if (value.startsWith(QLatin1String("\""))) {
type = QLatin1String("string");
} else if (value == QLatin1String("True") || value == QLatin1String("False")) {
type = QLatin1String("bool");
} else if (value.contains(QRegExp(QLatin1String("-?\\d+\\.\\d*")))) {
type = QLatin1String("float");
} else if (value.contains(QRegExp(QLatin1String("-?\\d+")))) {
type = QLatin1String("int");
} else if (!value.isEmpty()) {
type = QLatin1String("object");
}
UMLObject* o = Import_Utils::insertAttribute(m_klass, visibility, variable,
type, m_comment, false);
UMLAttribute* a = o->asUMLAttribute();
a->setInitialValue(value);
a->setStatic(isStatic);
return true;
}
示例5: writeAttributes
void CSharpWriter::writeAttributes(UMLClassifier *c, QTextStream &cs) {
UMLAttributeList atpub, atprot, atpriv, atdefval;
atpub.setAutoDelete(false);
atprot.setAutoDelete(false);
atpriv.setAutoDelete(false);
atdefval.setAutoDelete(false);
//sort attributes by scope and see if they have a default value
UMLAttributeList atl = c->getAttributeList();
UMLAttribute *at;
for (at = atl.first(); at ; at = atl.next()) {
if (!at->getInitialValue().isEmpty())
atdefval.append(at);
switch (at->getVisibility()) {
case Uml::Visibility::Public:
atpub.append(at);
break;
case Uml::Visibility::Protected:
atprot.append(at);
break;
case Uml::Visibility::Private:
atpriv.append(at);
break;
default:
break;
}
}
if (forceSections() || atl.count())
cs << m_endl << m_container_indent << m_indentation << "#region Attributes" << m_endl << m_endl;
// write public attributes
if (forceSections() || atpub.count()) {
writeAttributes(atpub,cs);
}
// write protected attributes
if (forceSections() || atprot.count()) {
writeAttributes(atprot,cs);
}
// write private attributes
if (forceSections() || atpriv.count()) {
writeAttributes(atpriv,cs);
}
if (forceSections() || atl.count())
cs << m_endl << m_container_indent << m_indentation << "#endregion" << m_endl << m_endl;
}
示例6: attributeRemoved
/**
* Slot for removing an attribute from the tree.
* @param listItem the attribute to be removed
*/
void RefactoringAssistant::attributeRemoved(UMLClassifierListItem *listItem)
{
UMLAttribute *att = static_cast<UMLAttribute*>(listItem);
DEBUG(DBG_SRC) << "attribute = " << att->name(); //:TODO:
QTreeWidgetItem *item = findListViewItem(att);
if (!item) {
uWarning() << "Attribute is not in tree!";
return;
}
disconnect(att, SIGNAL(modified()), this, SLOT(objectModified()));
m_umlObjectMap.remove(item);
delete item;
DEBUG(DBG_SRC) << "attribute = " << att->name() << " deleted!"; //:TODO:
}
示例7: UMLAttributeList
void UMLAttributeList::copyInto(UMLAttributeList *rhs) const {
// Don't copy yourself.
if (rhs == this) return;
rhs->clear();
// Suffering from const; we shall not modify our object.
UMLAttributeList *tmp = new UMLAttributeList(*this);
UMLAttribute *item;
for (item = tmp->first(); item; item = tmp->next() )
{
rhs->append((UMLAttribute*)item->clone());
}
delete tmp;
}
示例8: getParentObject
QString RubyCodeClassField::getFieldName()
{
if (parentIsAttribute())
{
UMLAttribute * at = (UMLAttribute*) getParentObject();
return cleanName(at->name());
}
else
{
UMLRole * role = (UMLRole*) getParentObject();
QString roleName = role->name();
if(fieldIsSingleValue()) {
return roleName.replace(0, 1, roleName.left(1).toLower());
} else {
return roleName.toLower() + QLatin1String("Array");
}
}
}
示例9: attributeAdded
/**
* Slot for adding an attribute to the tree.
* @param listItem the new attribute to add
*/
void RefactoringAssistant::attributeAdded(UMLClassifierListItem *listItem)
{
UMLAttribute *att = static_cast<UMLAttribute*>(listItem);
DEBUG(DBG_SRC) << "attribute = " << att->name(); //:TODO:
UMLClassifier *parent = dynamic_cast<UMLClassifier*>(att->parent());
if (!parent) {
uWarning() << att->name() << " - Parent of attribute is not a classifier!";
return;
}
QTreeWidgetItem *item = findListViewItem(parent);
if (!item) {
uWarning() << "Parent is not in tree!";
return;
}
for (int i = 0; i < item->childCount(); ++i) {
QTreeWidgetItem *folder = item->child(i);
if (folder->text(1) == QLatin1String("attributes")) {
item = new QTreeWidgetItem(folder, QStringList(att->name()));
m_umlObjectMap[item] = att;
connect(att, SIGNAL(modified()), this, SLOT(objectModified()));
setVisibilityIcon(item, att);
DEBUG(DBG_SRC) << "attribute = " << att->name() << " added!"; //:TODO:
break;
}
}
}
示例10: fixInitialStringDeclValue
QString JavaCodeClassField::getInitialValue()
{
if (parentIsAttribute())
{
UMLAttribute * at = dynamic_cast<UMLAttribute*>(getParentObject());
if (at) {
return fixInitialStringDeclValue(at->getInitialValue(), getTypeName());
} else {
uError() << "parent object is not a UMLAttribute";
return QString();
}
}
else
{
if(fieldIsSingleValue()) {
// FIX : IF the multiplicity is "1" then we should init a new object here, if its 0 or 1,
// then we can just return 'empty' string (minor problem).
return QString();
} else {
return QLatin1String(" new ") + JavaCodeGenerator::getListFieldClassName() + QLatin1String("()");
}
}
}
示例11: getNewLineEndingChars
/**
* update the start and end text for this ownedhierarchicalcodeblock.
*/
void XMLElementCodeBlock::updateContent ( )
{
QString endLine = getNewLineEndingChars();
QString nodeName = getNodeName();
// Now update START/ENDING Text
QString startText = '<' + nodeName;
QString endText = "";
UMLAttributeList * alist = getAttributeList();
for (UMLAttribute *at = alist->first(); at; at=alist->next())
{
if(at->getInitialValue().isEmpty())
kWarning()<<" XMLElementCodeBlock : cant print out attribute that lacks an initial value"<<endl;
else {
startText.append(" " +at->getName()+"=\"");
startText.append(at->getInitialValue()+"\"");
}
}
// now set close of starting/ending node, the style depending on whether we have child text or not
if(getTextBlockList()->count())
{
startText.append(">");
endText = "</" + nodeName + '>';
} else {
startText.append("/>");
endText = "";
}
setStartText(startText);
setEndText(endText);
}
示例12: writeOperations
void JSWriter::writeOperations(QString classname, UMLOperationList *opList, QTextStream &js)
{
UMLOperation *op;
UMLAttribute *at;
for(op = opList->first(); op; op = opList->next())
{
UMLAttributeList atl = op->getParmList();
//write method doc if we have doc || if at least one of the params has doc
bool writeDoc = forceDoc() || !op->getDoc().isEmpty();
for (at = atl.first(); at; at = atl.next())
writeDoc |= !at->getDoc().isEmpty();
if( writeDoc ) //write method documentation
{
js << "/**" << m_endl << formatDoc(op->getDoc()," * ");
for (at = atl.first(); at; at = atl.next()) //write parameter documentation
{
if(forceDoc() || !at->getDoc().isEmpty())
{
js << " * @param " + cleanName(at->getName())<<m_endl;
js << formatDoc(at->getDoc()," * ");
}
}//end for : write parameter documentation
js << " */" << m_endl;
}//end if : write method documentation
js << classname << ".prototype." << cleanName(op->getName()) << " = function " << "(";
int i = atl.count();
int j=0;
for (at = atl.first(); at ;at = atl.next(),j++)
{
js << cleanName(at->getName())
<< (!(at->getInitialValue().isEmpty()) ? (QString(" = ")+at->getInitialValue()) : QString(""))
<< ((j < i-1)?", ":"");
}
js << ")" << m_endl << "{" << m_endl <<
m_indentation << m_endl << "}" << m_endl;
js << m_endl << m_endl;
}//end for
}
示例13: UMLAttribute
void UMLOperationDialog::slotNewParameter() {
int result = 0;
UMLAttribute* pAtt = 0;
QString currentName = m_pOperation->getUniqueParameterName();
UMLAttribute* newAttribute = new UMLAttribute(m_pOperation, currentName, Uml::id_Reserved);
ParmPropDlg dlg(this, m_doc, newAttribute);
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);
delete newAttribute;
return;
}
if( !pAtt ) {
newAttribute->setID( UniqueID::gen() );
newAttribute->setName( name );
newAttribute->setTypeName( dlg.getTypeName() );
newAttribute->setInitialValue( dlg.getInitialValue() );
newAttribute->setDoc( dlg.getDoc() );
newAttribute->setParmKind( dlg.getParmKind() );
m_pOperation->addParm( newAttribute );
m_pParmsLB -> insertItem( name );
m_doc -> setModified( true );
} else {
KMessageBox::sorry(this, i18n("The parameter name you have chosen\nis already being used in this operation."),
i18n("Parameter Name Not Unique"), false);
delete newAttribute;
}
} else {
delete newAttribute;
}
}
示例14: printAttributes
void SQLWriter::printAttributes(QTextStream& sql, UMLAttributeList attributeList, bool first) {
QString attrDoc = "";
UMLAttribute* at;
for (at=attributeList.first();at;at=attributeList.next())
{
// print , after attribute
if (first == false) {
sql <<",";
} else {
first = false;
}
// print documentation/comment of last attribute at end of line
if (attrDoc.isEmpty() == false)
{
sql << " -- " << attrDoc << m_endl;
} else {
sql << m_endl;
}
// write the attribute
sql << m_indentation << cleanName(at->getName()) << " " << at->getTypeName() << " "
<< (at->getInitialValue().isEmpty()?QString(""):QString(" DEFAULT ")+at->getInitialValue());
// now get documentation/comment of current attribute
attrDoc = at->getDoc();
}
// print documentation/comment at end of line
if (attrDoc.isEmpty() == false)
{
sql << " -- " << attrDoc << m_endl;
} else {
sql << m_endl;
}
return;
}
示例15: while
//.........这里部分代码省略.........
m_srcIndex++;
}
typeName = advance();
} else if (direction == QLatin1String("out")) {
dir = Uml::ParameterDirection::Out;
typeName = advance();
} else {
typeName = direction; // In Ada, the default direction is "in"
}
typeName.remove(QLatin1String("Standard."), Qt::CaseInsensitive);
typeName = expand(typeName);
if (op == NULL) {
// In Ada, the first parameter indicates the class.
UMLObject *type = Import_Utils::createUMLObject(UMLObject::ot_Class, typeName, currentScope());
UMLObject::ObjectType t = type->baseType();
if ((t != UMLObject::ot_Interface &&
(t != UMLObject::ot_Class || type->stereotype() == QLatin1String("record"))) ||
!m_classesDefinedInThisScope.contains(type)) {
// Not an instance bound method - we cannot represent it.
skipStmt(QLatin1String(")"));
break;
}
klass = static_cast<UMLClassifier*>(type);
op = Import_Utils::makeOperation(klass, name);
// The controlling parameter is suppressed.
parNameCount--;
if (parNameCount) {
for (uint i = 0; i < parNameCount; ++i) {
parName[i] = parName[i + 1];
}
}
}
for (uint i = 0; i < parNameCount; ++i) {
UMLAttribute *att = Import_Utils::addMethodParameter(op, typeName, parName[i]);
att->setParmKind(dir);
}
if (advance() != QLatin1String(";"))
break;
}
if (keyword == QLatin1String("function")) {
if (advance() != QLatin1String("return")) {
if (klass)
uError() << "importAda: expecting \"return\" at function "
<< name;
return false;
}
returnType = expand(advance());
returnType.remove(QLatin1String("Standard."), Qt::CaseInsensitive);
}
bool isAbstract = false;
if (advance() == QLatin1String("is") && advance() == QLatin1String("abstract"))
isAbstract = true;
if (klass != NULL && op != NULL)
Import_Utils::insertMethod(klass, op, m_currentAccess, returnType,
false, isAbstract, false, false, m_comment);
skipStmt();
return true;
}
if (keyword == QLatin1String("task") || keyword == QLatin1String("protected")) {
// Can task and protected objects/types be mapped to UML?
QString name = advance();
if (name == QLatin1String("type")) {
name = advance();
}
QString next = advance();
if (next == QLatin1String("(")) {