本文整理汇总了C++中UMLClassifier::package方法的典型用法代码示例。如果您正苦于以下问题:C++ UMLClassifier::package方法的具体用法?C++ UMLClassifier::package怎么用?C++ UMLClassifier::package使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UMLClassifier
的用法示例。
在下文中一共展示了UMLClassifier::package方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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
//.........这里部分代码省略.........
示例2: 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);
//.........这里部分代码省略.........