本文整理汇总了C++中UMLClassifier::name方法的典型用法代码示例。如果您正苦于以下问题:C++ UMLClassifier::name方法的具体用法?C++ UMLClassifier::name怎么用?C++ UMLClassifier::name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UMLClassifier
的用法示例。
在下文中一共展示了UMLClassifier::name方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: umbrellify
/**
* Create an Umbrello object from a PetalNode of the Logical View.
*
* @return True for success.
* Given a PetalNode for which the mapping to Umbrello is not yet
* implemented umbrellify() is a no-op but also returns true.
*/
bool umbrellify(PetalNode *node, UMLPackage *parentPkg = NULL)
{
if (node == NULL) {
uError() << "umbrellify: node is NULL";
return false;
}
QStringList args = node->initialArgs();
QString objType = args[0];
QString name = clean(args[1]);
Uml::IDType id = quid(node);
if (objType == "Class_Category") {
UMLObject *o = Import_Utils::createUMLObject(UMLObject::ot_Package, name, parentPkg);
o->setID(id);
PetalNode *logical_models = node->findAttribute("logical_models").node;
if (logical_models) {
UMLPackage *localParent = static_cast<UMLPackage*>(o);
PetalNode::NameValueList atts = logical_models->attributes();
for (int i = 0; i < atts.count(); ++i) {
umbrellify(atts[i].second.node, localParent);
}
} else if (!handleControlledUnit(node, name, id, parentPkg)) {
uDebug() << "umbrellify: handling of " << objType << " " << name
<< " is not yet implemented";
}
} else if (objType == "Class") {
UMLObject *o = Import_Utils::createUMLObject(UMLObject::ot_Class, name, parentPkg);
o->setID(id);
UMLClassifier *c = static_cast<UMLClassifier*>(o);
// set stereotype
QString stereotype = clean(node->findAttribute("stereotype").string);
if (!stereotype.isEmpty()) {
if (stereotype.toLower() == "interface")
c->setBaseType(UMLObject::ot_Interface);
else
c->setStereotype(stereotype);
}
// insert attributes
AttributesReader attReader(c);
attReader.read(node, c->name());
// insert operations
OperationsReader opReader(c);
opReader.read(node, c->name());
// insert generalizations
SuperclassesReader superReader(c);
superReader.read(node, c->name());
// insert realizations
RealizationsReader realReader(c);
realReader.read(node, c->name());
} else if (objType == "Association") {
PetalNode *roles = node->findAttribute("roles").node;
if (node == NULL) {
uError() << "umbrellify: cannot find roles of Association";
return false;
}
UMLAssociation *assoc = new UMLAssociation(Uml::AssociationType::UniAssociation);
PetalNode::NameValueList roleList = roles->attributes();
for (uint i = 0; i <= 1; ++i) {
PetalNode *roleNode = roleList[i].second.node;
if (roleNode == NULL) {
uError() << "umbrellify: roleNode of Association is NULL";
return false;
}
if (roleNode->name() != "Role") {
uDebug() << "umbrellify(" << name << "): expecting Role, found \""
<< roleNode->name();
continue;
}
// index 0 corresponds to Umbrello roleB
// index 1 corresponds to Umbrello roleA
UMLRole *role = assoc->getUMLRole((Uml::Role_Type) !i);
QStringList initialArgs = roleNode->initialArgs();
if (initialArgs.count() > 1) {
QString roleName = clean(initialArgs[1]);
if (! roleName.startsWith(QLatin1String("$UNNAMED")))
role->setName(roleName);
}
role->setID(quid(roleNode));
QString quidref = quidu(roleNode);
QString type = clean(roleNode->findAttribute("supplier").string);
if (!quidref.isEmpty()) {
role->setSecondaryId(quidref);
}
if (!type.isEmpty()) {
role->setSecondaryFallback(type);
}
QString label = clean(roleNode->findAttribute("label").string);
if (!label.isEmpty()) {
role->setName(label);
}
QString client_cardinality = clean(roleNode->findAttribute("client_cardinality").string);
//.........这里部分代码省略.........
示例2: writeClass
/**
* Call this method to generate C++ code for a UMLClassifier.
* @param c the class you want to generate code for.
*/
void RubyWriter::writeClass(UMLClassifier *c)
{
if (!c) {
uDebug() << "Cannot write class of NULL concept!";
return;
}
UMLClassifierList superclasses = c->getSuperClasses();
UMLAssociationList aggregations = c->getAggregations();
UMLAssociationList compositions = c->getCompositions();
//find an appropriate name for our file
fileName_ = findFileName(c, QLatin1String(".rb"));
if (fileName_.isEmpty()) {
emit codeGenerated(c, false);
return;
}
QFile fileh;
if (!openFile(fileh, fileName_)) {
emit codeGenerated(c, false);
return;
}
QTextStream h(&fileh);
className_ = cleanName(c->name());
//////////////////////////////
//Start generating the code!!
/////////////////////////////
//try to find a heading file (license, coments, etc)
QString str;
str = getHeadingFile(QLatin1String(".rb"));
if (!str.isEmpty()) {
str.replace(QRegExp(QLatin1String("%filename%")), fileName_);
str.replace(QRegExp(QLatin1String("%filepath%")), fileh.fileName());
h << str << m_endl;
}
if (forceDoc() || !c->doc().isEmpty()) {
QString docStr = c->doc();
docStr.replace(QRegExp(QLatin1String("\\n")), QLatin1String("\n# "));
docStr.remove(QLatin1String("@ref "));
docStr.replace(QLatin1String("@see"), QLatin1String("_See_"));
docStr.replace(QLatin1String("@short"), QLatin1String("_Summary_"));
docStr.replace(QLatin1String("@author"), QLatin1String("_Author_"));
h << "#" << m_endl;
h << "# " << docStr << m_endl;
h << "#" << m_endl << m_endl;
}
// write inheritances out
UMLClassifier *concept;
h << "class " << cppToRubyType(className_) << (superclasses.count() > 0 ? QLatin1String(" < ") : QString());
int i = 0;
foreach (concept, superclasses) {
if (i == 0) {
h << cppToRubyType(concept->name()) << m_endl;
} else {
// Assume ruby modules that can be mixed in, after the first
// superclass name in the list
h << m_indentation << "include " << cppToRubyType(concept->name()) << m_endl;
}
i++;
}
h << m_endl;
// write comment for sub-section IF needed
if (forceDoc() || c->hasAccessorMethods()) {
h << m_indentation << "#" << m_endl;
h << m_indentation << "# Accessor Methods" << m_endl;
h << m_indentation << "#" << m_endl << m_endl;
// Accessor methods for attributes
writeAttributeMethods(c->getAttributeList(Uml::Visibility::Public), Uml::Visibility::Public, h);
writeAttributeMethods(c->getAttributeList(Uml::Visibility::Protected), Uml::Visibility::Protected, h);
writeAttributeMethods(c->getAttributeList(Uml::Visibility::Private), Uml::Visibility::Private, h);
h << m_endl;
}
//operations
writeOperations(c, h);
//finish files
h << "end" << m_endl << m_endl;
//close files and notfiy we are done
fileh.close();
emit codeGenerated(c, true);
}
示例3: updateContent
// This method will cause the class to rebuild its text representation.
// based on the parent classifier object.
// For any situation in which this is called, we are either building the code
// document up, or replacing/regenerating the existing auto-generated parts. As
// such, we will want to insert everything we resonablely will want
// during creation. We can set various parts of the document (esp. the
// comments) to appear or not, as needed.
void CPPHeaderCodeDocument::updateContent()
{
// Gather info on the various fields and parent objects of this class...
UMLClassifier * c = getParentClassifier();
Q_ASSERT(c != NULL);
CodeGenPolicyExt *pe = UMLApp::app()->policyExt();
CPPCodeGenerationPolicy * policy = dynamic_cast<CPPCodeGenerationPolicy*>(pe);
// first, set the global flag on whether or not to show classfield info
const CodeClassFieldList * cfList = getCodeClassFieldList();
CodeClassFieldList::const_iterator it = cfList->begin();
CodeClassFieldList::const_iterator end = cfList->end();
for(; it != end; ++it)
(*it)->setWriteOutMethods(policy->getAutoGenerateAccessors());
// attribute-based ClassFields
// we do it this way to have the static fields sorted out from regular ones
CodeClassFieldList staticPublicAttribClassFields = getSpecificClassFields (CodeClassField::Attribute, true, Uml::Visibility::Public);
CodeClassFieldList publicAttribClassFields = getSpecificClassFields (CodeClassField::Attribute, false, Uml::Visibility::Public);
CodeClassFieldList staticProtectedAttribClassFields = getSpecificClassFields (CodeClassField::Attribute, true, Uml::Visibility::Protected);
CodeClassFieldList protectedAttribClassFields = getSpecificClassFields (CodeClassField::Attribute, false, Uml::Visibility::Protected);
CodeClassFieldList staticPrivateAttribClassFields = getSpecificClassFields (CodeClassField::Attribute, true, Uml::Visibility::Private);
CodeClassFieldList privateAttribClassFields = getSpecificClassFields (CodeClassField::Attribute, false, Uml::Visibility::Private);
// association-based ClassFields
// don't care if they are static or not..all are lumped together
CodeClassFieldList publicPlainAssocClassFields = getSpecificClassFields (CodeClassField::PlainAssociation, Uml::Visibility::Public);
CodeClassFieldList publicAggregationClassFields = getSpecificClassFields (CodeClassField::Aggregation, Uml::Visibility::Public);
CodeClassFieldList publicCompositionClassFields = getSpecificClassFields (CodeClassField::Composition, Uml::Visibility::Public);
CodeClassFieldList protPlainAssocClassFields = getSpecificClassFields (CodeClassField::PlainAssociation, Uml::Visibility::Protected);
CodeClassFieldList protAggregationClassFields = getSpecificClassFields (CodeClassField::Aggregation, Uml::Visibility::Protected);
CodeClassFieldList protCompositionClassFields = getSpecificClassFields (CodeClassField::Composition, Uml::Visibility::Protected);
CodeClassFieldList privPlainAssocClassFields = getSpecificClassFields (CodeClassField::PlainAssociation, Uml::Visibility::Private);
CodeClassFieldList privAggregationClassFields = getSpecificClassFields (CodeClassField::Aggregation, Uml::Visibility::Private);
CodeClassFieldList privCompositionClassFields = getSpecificClassFields (CodeClassField::Composition, Uml::Visibility::Private);
bool hasOperationMethods = false;
UMLOperationList list = c->getOpList();
hasOperationMethods = ! list.isEmpty();
bool hasNamespace = false;
bool isEnumeration = false;
bool isInterface = parentIsInterface();
bool hasclassFields = hasClassFields();
bool forcedoc = UMLApp::app()->commonPolicy()->getCodeVerboseDocumentComments();
QString endLine = UMLApp::app()->commonPolicy()->getNewLineEndingChars();
UMLClassifierList superclasses = c->findSuperClassConcepts();
// START GENERATING CODE/TEXT BLOCKS and COMMENTS FOR THE DOCUMENT
//
// Write the hash define stuff to prevent multiple parsing/inclusion of header
QString cppClassName = CodeGenerator::cleanName(c->name());
QString hashDefine = CodeGenerator::cleanName(c->name().toUpper().simplified());
QString defText = QLatin1String("#ifndef ") + hashDefine + QLatin1String("_H") + endLine + QLatin1String("#define ") + hashDefine + QLatin1String("_H");
addOrUpdateTaggedCodeBlockWithComments(QLatin1String("hashDefBlock"), defText, QString(), 0, false);
// INCLUDE CODEBLOCK
//
// Q: Why all utils? Isnt just List and Vector the only classes we are using?
// A: doesn't matter at all; its more readable to just include '*' and cpp compilers
// don't slow down or anything. (TZ)
QString includeStatement;
bool stringGlobal = policy->stringIncludeIsGlobal();
QString sStartBrak = stringGlobal ? QLatin1String("<") : QLatin1String("\"");
QString sEndBrak = stringGlobal ? QLatin1String(">") : QLatin1String("\"");
includeStatement.append(QLatin1String("#include ") + sStartBrak + policy->getStringClassNameInclude() + sEndBrak + endLine);
if (hasObjectVectorClassFields())
{
bool vecGlobal = policy->vectorIncludeIsGlobal();
QString vStartBrak = vecGlobal ? QLatin1String("<") : QLatin1String("\"");
QString vEndBrak = vecGlobal ? QLatin1String(">") : QLatin1String("\"");
QString value =QLatin1String("#include ") + vStartBrak + policy->getVectorClassNameInclude() + vEndBrak;
includeStatement.append(value + endLine);
}
//only include classes in a different package from this class
UMLPackageList includes;
QMap<UMLPackage *, QString> packageMap; // so we don't repeat packages
CodeGenerator::findObjectsRelated(c, includes);
foreach(UMLPackage* con, includes) {
if (con->baseType() != UMLObject::ot_Datatype && !packageMap.contains(con)) {
packageMap.insert(con, con->package());
if(con != getParentClassifier())
includeStatement.append(QLatin1String("#include \"") + CodeGenerator::cleanName(con->name().toLower()) + QLatin1String(".h\"") + endLine);
}
}
// now, add/update the includes codeblock
//.........这里部分代码省略.........
示例4: updateContent
// This method will cause the class to rebuild its text representation.
// based on the parent classifier object.
// For any situation in which this is called, we are either building the code
// document up, or replacing/regenerating the existing auto-generated parts. As
// such, we will want to insert everything we resonablely will want
// during creation. We can set various parts of the document (esp. the
// comments) to appear or not, as needed.
void DClassifierCodeDocument::updateContent()
{
// Gather info on the various fields and parent objects of this class...
UMLClassifier * c = getParentClassifier();
Q_ASSERT(c != 0);
CodeGenerationPolicy * commonPolicy = UMLApp::app()->commonPolicy();
CodeGenPolicyExt * pe = UMLApp::app()->policyExt();
DCodeGenerationPolicy * policy = dynamic_cast<DCodeGenerationPolicy*>(pe);
// first, set the global flag on whether or not to show classfield info
// This depends on whether or not we have attribute/association classes
const CodeClassFieldList * cfList = getCodeClassFieldList();
CodeClassFieldList::const_iterator it = cfList->begin();
CodeClassFieldList::const_iterator end = cfList->end();
for (; it != end; ++it) {
CodeClassField * field = *it;
if (field->parentIsAttribute())
field->setWriteOutMethods(policy->getAutoGenerateAttribAccessors());
else
field->setWriteOutMethods(policy->getAutoGenerateAssocAccessors());
}
// attribute-based ClassFields
// we do it this way to have the static fields sorted out from regular ones
CodeClassFieldList staticAttribClassFields = getSpecificClassFields (CodeClassField::Attribute, true);
CodeClassFieldList attribClassFields = getSpecificClassFields (CodeClassField::Attribute, false);
// association-based ClassFields
// don't care if they are static or not..all are lumped together
CodeClassFieldList plainAssocClassFields = getSpecificClassFields (CodeClassField::PlainAssociation);
CodeClassFieldList aggregationClassFields = getSpecificClassFields (CodeClassField::Aggregation);
CodeClassFieldList compositionClassFields = getSpecificClassFields (CodeClassField::Composition);
bool isInterface = parentIsInterface();
bool hasOperationMethods = false;
UMLOperationList list = c->getOpList();
hasOperationMethods = ! list.isEmpty();
QString endLine = commonPolicy->getNewLineEndingChars(); // a shortcut..so we don't have to call this all the time
//
// START GENERATING CODE/TEXT BLOCKS and COMMENTS FOR THE DOCUMENT
//
//
// PACKAGE CODE BLOCK
//
QString pkgs = getPackage();
pkgs.replace(QRegExp(QLatin1String("::")), QLatin1String("."));
QString packageText = getPackage().isEmpty() ? QString() : QString(QLatin1String("package ")+pkgs+QLatin1Char(';')+endLine);
CodeBlockWithComments * pblock = addOrUpdateTaggedCodeBlockWithComments(QLatin1String("packages"), packageText, QString(), 0, false);
if (packageText.isEmpty() && pblock->contentType() == CodeBlock::AutoGenerated)
pblock->setWriteOutText(false);
else
pblock->setWriteOutText(true);
// IMPORT CODEBLOCK
//
// Q: Why all utils? Aren't just List and Vector the only classes we are using?
// A: doesn't matter at all; it is more readable to just include '*' and d compilers
// don't slow down or anything. (TZ)
QString importStatement;
if (hasObjectVectorClassFields())
importStatement.append(QLatin1String("import d.util.*;"));
//only import classes in a different package from this class
UMLPackageList imports;
QMap<UMLPackage*, QString> packageMap; // so we don't repeat packages
CodeGenerator::findObjectsRelated(c, imports);
for (UMLPackageListIt importsIt(imports); importsIt.hasNext();) {
UMLPackage *con = importsIt.next();
// NO (default) datatypes in the import statement.. use defined
// ones whould be possible, but no idea how to do that...at least for now.
// Dynamic casting is slow..not an optimal way to do this.
if (!packageMap.contains(con) && !con->isUMLDatatype())
{
packageMap.insert(con, con->package());
// now, we DON'T need to import classes that are already in our own package
// (that is, IF a package is specified). Otherwise, we should have a declaration.
if (con->package() != c->package() ||
(c->package().isEmpty() && con->package().isEmpty()))
{
importStatement.append(endLine+QLatin1String("import "));
if (!con->package().isEmpty())
importStatement.append(con->package()+QLatin1Char('.'));
importStatement.append(CodeGenerator::cleanName(con->name())+QLatin1Char(';'));
}
}
}
// now, add/update the imports codeblock
CodeBlockWithComments * iblock = addOrUpdateTaggedCodeBlockWithComments(QLatin1String("imports"), importStatement, QString(), 0, false);
//.........这里部分代码省略.........