• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdesdk API Reference
  • KDE Home
  • Contact Us
 

umbrello/umbrello

  • sources
  • kde-4.12
  • kdesdk
  • umbrello
  • umbrello
  • codegenerators
codegenerator.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * This program is free software; you can redistribute it and/or modify *
3  * it under the terms of the GNU General Public License as published by *
4  * the Free Software Foundation; either version 2 of the License, or *
5  * (at your option) any later version. *
6  * *
7  * copyright (C) 2003 Brian Thomas <thomas@mail630.gsfc.nasa.gov> *
8  * copyright (C) 2004-2013 *
9  * Umbrello UML Modeller Authors <umbrello-devel@kde.org> *
10  ***************************************************************************/
11 
12 // own header
13 #include "codegenerator.h"
14 
15 // app includes
16 #include "debug_utils.h"
17 #include "overwritedialogue.h"
18 #include "codeviewerdialog.h"
19 #include "simplecodegenerator.h"
20 #include "attribute.h"
21 #include "association.h"
22 #include "classifier.h"
23 #include "classifiercodedocument.h"
24 #include "codedocument.h"
25 #include "codegenerationpolicy.h"
26 #include "operation.h"
27 #include "uml.h"
28 #include "umldoc.h"
29 #include "umlobject.h"
30 #include "umlattributelist.h"
31 #include "umloperationlist.h"
32 
33 // kde includes
34 #include <klocale.h>
35 #include <kmessagebox.h>
36 #include <kdialog.h>
37 #include <kapplication.h>
38 
39 // qt includes
40 #include <QDateTime>
41 #include <QDir>
42 #include <QDomDocument>
43 #include <QDomElement>
44 #include <QPointer>
45 #include <QRegExp>
46 #include <QTextStream>
47 
48 // system includes
49 #include <cstdlib> // to get the user name
50 
54 CodeGenerator::CodeGenerator()
55  : m_applyToAllRemaining(true),
56  m_document(UMLApp::app()->document()),
57  m_lastIDIndex(0)
58 {
59  // initial population of our project generator
60  // CANNOT Be done here because we would call pure virtual method
61  // of newClassifierDocument (bad!).
62  // We should only call from the child
63  // initFromParentDocument();
64 }
65 
69 CodeGenerator::~CodeGenerator()
70 {
71  // destroy all owned codedocuments
72  qDeleteAll(m_codedocumentVector);
73  m_codedocumentVector.clear();
74 }
75 
80 QString CodeGenerator::getUniqueID(CodeDocument * codeDoc)
81 {
82  QString id = codeDoc->ID();
83 
84  // does this document already exist? then just return its present id
85  if (!id.isEmpty() && findCodeDocumentByID(id)) {
86  return id;
87  }
88 
89  // approach now differs by whether or not it is a classifier code document
90  ClassifierCodeDocument * classDoc = dynamic_cast<ClassifierCodeDocument*>(codeDoc);
91  if (classDoc) {
92  UMLClassifier *c = classDoc->getParentClassifier();
93  id = Uml::ID::toString(c->id()); // this is supposed to be unique already..
94  }
95  else {
96  QString prefix = "doc";
97  QString id = prefix + "_0";
98  int number = m_lastIDIndex;
99  for (; findCodeDocumentByID(id); ++number) {
100  id = prefix + '_' + QString::number(number);
101  }
102  m_lastIDIndex = number;
103  }
104 
105  return id;
106 }
107 
112 CodeDocument * CodeGenerator::findCodeDocumentByID(const QString &tag)
113 {
114  CodeDocument* doc = m_codeDocumentDictionary.value(tag);
115  if (doc) {
116  return doc;
117  }
118  else {
119  return NULL;
120  }
121 }
122 
127 bool CodeGenerator::addCodeDocument(CodeDocument * doc)
128 {
129  QString tag = doc->ID();
130 
131  // assign a tag if one doesn't already exist
132  if (tag.isEmpty()) {
133  tag = getUniqueID(doc);
134  doc->setID(tag);
135  }
136 
137  if (m_codeDocumentDictionary.contains(tag)) {
138  return false; // return false, we already have some object with this tag in the list
139  }
140  else {
141  m_codeDocumentDictionary.insert(tag, doc);
142  }
143 
144  m_codedocumentVector.append(doc);
145  return true;
146 }
147 
152 bool CodeGenerator::removeCodeDocument(CodeDocument * remove_object)
153 {
154  QString tag = remove_object->ID();
155  if (!(tag.isEmpty())) {
156  m_codeDocumentDictionary.remove(tag);
157  }
158  else {
159  return false;
160  }
161 
162  m_codedocumentVector.removeAll(remove_object);
163  return true;
164 }
165 
171 CodeDocumentList * CodeGenerator::getCodeDocumentList()
172 {
173  return &m_codedocumentVector;
174 }
175 
176 // the vanilla version
177 
181 CodeViewerDialog * CodeGenerator::getCodeViewerDialog(QWidget* parent, CodeDocument *doc,
182  Settings::CodeViewerState state)
183 {
184  return new CodeViewerDialog(parent, doc, state);
185 }
186 
191 void CodeGenerator::loadFromXMI(QDomElement & qElement)
192 {
193  // look for our particular child element
194  QDomNode node = qElement.firstChild();
195  QDomElement element = node.toElement();
196  QString langType = Uml::ProgrammingLanguage::toString(language());
197 
198  if (qElement.tagName() != "codegenerator"
199  || qElement.attribute("language", "UNKNOWN") != langType) {
200  return;
201  }
202  // got our code generator element, now load
203  // codedocuments
204  QDomNode codeDocNode = qElement.firstChild();
205  QDomElement codeDocElement = codeDocNode.toElement();
206  while (!codeDocElement.isNull()) {
207  QString docTag = codeDocElement.tagName();
208  QString id = codeDocElement.attribute("id", "-1");
209  if (docTag == "sourcecode") {
210  loadCodeForOperation(id, codeDocElement);
211  }
212  else if (docTag == "codedocument" || docTag == "classifiercodedocument") {
213  CodeDocument * codeDoc = findCodeDocumentByID(id);
214  if (codeDoc) {
215  codeDoc->loadFromXMI(codeDocElement);
216  }
217  else {
218  uWarning() << "missing code document for id:" << id;
219  }
220  }
221  else {
222  uWarning() << "got strange codegenerator child node:" << docTag << ", ignoring.";
223  }
224  codeDocNode = codeDocElement.nextSibling();
225  codeDocElement = codeDocNode.toElement();
226  }
227 }
228 
233 void CodeGenerator::loadCodeForOperation(const QString& idStr, const QDomElement& codeDocElement)
234 {
235  Uml::ID::Type id = Uml::ID::fromString(idStr);
236  UMLObject *obj = m_document->findObjectById(id);
237  if (obj) {
238  uDebug() << "found UMLObject for id:" << idStr;
239  QString value = codeDocElement.attribute("value", "");
240 
241  UMLObject::ObjectType t = obj->baseType();
242  if (t == UMLObject::ot_Operation) {
243  UMLOperation *op = static_cast<UMLOperation*>(obj);
244  op->setSourceCode(value);
245  }
246  else {
247  uError() << "sourcecode id " << idStr << " has unexpected type " << UMLObject::toString(t);
248  }
249  }
250  else {
251  uError() << "unknown sourcecode id " << idStr;
252  }
253 }
254 
258 void CodeGenerator::saveToXMI(QDomDocument & doc, QDomElement & root)
259 {
260  QString langType = Uml::ProgrammingLanguage::toString(language());
261  QDomElement docElement = doc.createElement("codegenerator");
262  docElement.setAttribute("language", langType);
263 
264  if (dynamic_cast<SimpleCodeGenerator*>(this)) {
265  UMLClassifierList concepts = m_document->classesAndInterfaces();
266  foreach (UMLClassifier *c, concepts) {
267  UMLOperationList operations = c->getOpList();
268  foreach (UMLOperation *op, operations) {
269  // save the source code
270  QString code = op->getSourceCode();
271  if (code.isEmpty()) {
272  continue;
273  }
274  QDomElement codeElement = doc.createElement("sourcecode");
275  codeElement.setAttribute("id", Uml::ID::toString(op->id()));
276  codeElement.setAttribute("value", code);
277  docElement.appendChild(codeElement);
278  }
279  }
280  }
281  else {
282  const CodeDocumentList * docList = getCodeDocumentList();
283  CodeDocumentList::const_iterator it = docList->begin();
284  CodeDocumentList::const_iterator end = docList->end();
285  for (; it != end; ++it) {
286  (*it)->saveToXMI(doc, docElement);
287  }
288  }
289  root.appendChild(docElement);
290 }
291 
308 void CodeGenerator::initFromParentDocument()
309 {
310  // Walk through the document converting classifiers into
311  // classifier code documents as needed (e.g only if doesn't exist)
312  UMLClassifierList concepts = m_document->classesAndInterfaces();
313  foreach (UMLClassifier *c, concepts) {
314  // Doesn't exist? Then build one.
315  CodeDocument * codeDoc = findCodeDocumentByClassifier(c);
316  if (!codeDoc) {
317  codeDoc = newClassifierCodeDocument(c);
318  addCodeDocument(codeDoc); // this will also add a unique tag to the code document
319  }
320  }
321 }
322 
328 void CodeGenerator::syncCodeToDocument()
329 {
330  CodeDocumentList::iterator it = m_codedocumentVector.begin();
331  CodeDocumentList::iterator end = m_codedocumentVector.end();
332  for (; it != end; ++it) {
333  (*it)->synchronize();
334  }
335 }
336 
337 // in this 'vanilla' version, we only worry about adding classifier
338 // documents
339 
343 void CodeGenerator::checkAddUMLObject(UMLObject * obj)
344 {
345  if (!obj) {
346  return;
347  }
348 
349  UMLClassifier * c = dynamic_cast<UMLClassifier*>(obj);
350  if (c) {
351  CodeDocument * cDoc = newClassifierCodeDocument(c);
352  addCodeDocument(cDoc);
353  }
354 }
355 
359 void CodeGenerator::checkRemoveUMLObject(UMLObject * obj)
360 {
361  if (!obj) {
362  return;
363  }
364 
365  UMLClassifier * c = dynamic_cast<UMLClassifier*>(obj);
366  if (c) {
367  ClassifierCodeDocument * cDoc = (ClassifierCodeDocument*) findCodeDocumentByClassifier(c);
368  if (cDoc) {
369  removeCodeDocument(cDoc);
370  }
371  }
372 }
373 
380 CodeDocument * CodeGenerator::findCodeDocumentByClassifier(UMLClassifier * classifier)
381 {
382  return findCodeDocumentByID(Uml::ID::toString(classifier->id()));
383 }
384 
390 void CodeGenerator::writeCodeToFile()
391 {
392  writeListedCodeDocsToFile(&m_codedocumentVector);
393 }
394 
400 void CodeGenerator::writeCodeToFile(UMLClassifierList & concepts)
401 {
402  CodeDocumentList docs;
403 
404  foreach (UMLClassifier *concept, concepts) {
405  CodeDocument * doc = findCodeDocumentByClassifier(concept);
406  if (doc) {
407  docs.append(doc);
408  }
409  }
410 
411  writeListedCodeDocsToFile(&docs);
412 }
413 
414 // Main method. Will write out passed code documents to file as appropriate.
415 
419 void CodeGenerator::writeListedCodeDocsToFile(CodeDocumentList * docs)
420 {
421  // iterate thru all code documents
422  CodeDocumentList::iterator it = docs->begin();
423  CodeDocumentList::iterator end = docs->end();
424  for (; it != end; ++it)
425  {
426  // we need this so we know when to emit a 'codeGenerated' signal
427  ClassifierCodeDocument * cdoc = dynamic_cast<ClassifierCodeDocument *>(*it);
428  bool codeGenSuccess = false;
429 
430  // we only write the document, if so requested
431  if ((*it)->getWriteOutCode()) {
432  QString filename = findFileName(*it);
433  // check that we may open that file for writing
434  QFile file;
435  if (openFile(file, filename)) {
436  QTextStream stream(&file);
437  stream << (*it)->toString() << endl;
438  file.close();
439  codeGenSuccess = true; // we wrote the code - OK
440  emit showGeneratedFile(file.fileName());
441  }
442  else {
443  uWarning() << "Cannot open file :" << file.fileName() << " for writing!";
444  codeGenSuccess = false;
445  }
446  }
447 
448  if (cdoc) {
449  emit codeGenerated(cdoc->getParentClassifier(), codeGenSuccess);
450  }
451  }
452 }
453 
458 CodeDocument * CodeGenerator::newCodeDocument()
459 {
460  CodeDocument * newCodeDoc = new CodeDocument();
461  return newCodeDoc;
462 }
463 
482 QString CodeGenerator::getHeadingFile(const QString &file)
483 {
484  return UMLApp::app()->commonPolicy()->getHeadingFile(file);
485 }
486 
502 QString CodeGenerator::overwritableName(const QString& name, const QString &extension)
503 {
504  CodeGenerationPolicy *pol = UMLApp::app()->commonPolicy();
505  QDir outputDirectory = pol->getOutputDirectory();
506  QString filename = name + extension;
507 
508  if (!outputDirectory.exists(filename)) {
509  return filename;
510  }
511 
512  int suffix;
513  QPointer<OverwriteDialogue> overwriteDialog =
514  new OverwriteDialogue(name, outputDirectory.absolutePath(),
515  m_applyToAllRemaining, kapp->activeWindow());
516  switch (pol->getOverwritePolicy()) { //if it exists, check the OverwritePolicy we should use
517  case CodeGenerationPolicy::Ok: //ok to overwrite file
518  filename = name + extension;
519  break;
520  case CodeGenerationPolicy::Ask: //ask if we can overwrite
521  switch(overwriteDialog->exec()) {
522  case KDialog::Yes: //overwrite file
523  if (overwriteDialog->applyToAllRemaining()) {
524  pol->setOverwritePolicy(CodeGenerationPolicy::Ok);
525  filename = name + extension;
526  }
527  else {
528  m_applyToAllRemaining = false;
529  }
530  break;
531  case KDialog::No: //generate similar name
532  suffix = 1;
533  while (1) {
534  filename = name + "__" + QString::number(suffix) + extension;
535  if (!outputDirectory.exists(filename))
536  break;
537  suffix++;
538  }
539  if (overwriteDialog->applyToAllRemaining()) {
540  pol->setOverwritePolicy(CodeGenerationPolicy::Never);
541  }
542  else {
543  m_applyToAllRemaining = false;
544  }
545  break;
546  case KDialog::Cancel: //don't output anything
547  if (overwriteDialog->applyToAllRemaining()) {
548  pol->setOverwritePolicy(CodeGenerationPolicy::Cancel);
549  }
550  else {
551  m_applyToAllRemaining = false;
552  }
553  delete overwriteDialog;
554  return QString();
555  break;
556  }
557  break;
558  case CodeGenerationPolicy::Never: //generate similar name
559  suffix = 1;
560  while (1) {
561  filename = name + "__" + QString::number(suffix) + extension;
562  if (!outputDirectory.exists(filename)) {
563  break;
564  }
565  suffix++;
566  }
567  break;
568  case CodeGenerationPolicy::Cancel: //don't output anything
569  delete overwriteDialog;
570  return QString();
571  break;
572  }
573 
574  delete overwriteDialog;
575  return filename;
576 }
577 
586 bool CodeGenerator::openFile(QFile & file, const QString &fileName)
587 {
588  //open files for writing.
589  if (fileName.isEmpty()) {
590  uWarning() << "cannot find a file name";
591  return false;
592  }
593  else {
594  QDir outputDirectory = UMLApp::app()->commonPolicy()->getOutputDirectory();
595  file.setFileName(outputDirectory.absoluteFilePath(fileName));
596  if(!file.open(QIODevice::WriteOnly)) {
597  KMessageBox::sorry(0, i18n("Cannot open file %1 for writing. Please make sure the folder exists and you have permissions to write to it.", file.fileName()), i18n("Cannot Open File"));
598  return false;
599  }
600  return true;
601  }
602 }
603 
609 QString CodeGenerator::cleanName(const QString &name)
610 {
611  QString retval = name;
612  retval.replace(QRegExp("\\W+"), "_");
613  return retval;
614 }
615 
625 QString CodeGenerator::findFileName(CodeDocument * codeDocument)
626 {
627  // Get the path name
628  QString path = codeDocument->getPath();
629 
630  // if path is given add this as a directory to the file name
631  QString name;
632  if (!path.isEmpty()) {
633  path.replace(QRegExp("::"), "/"); // Simple hack!
634  name = path + '/' + codeDocument->getFileName();
635  path = '/' + path;
636  }
637  else { // determine the "natural" file name
638  name = codeDocument->getFileName();
639  }
640 
641  // Convert all "::" to "/" : Platform-specific path separator
642  name.replace(QRegExp("::"), "/"); // Simple hack!
643 
644  // if a path name exists check the existence of the path directory
645  if (!path.isEmpty()) {
646  QDir outputDirectory = UMLApp::app()->commonPolicy()->getOutputDirectory();
647  QDir pathDir(outputDirectory.absolutePath() + path);
648 
649  // does our complete output directory exist yet? if not, try to create it
650  if (!pathDir.exists()) {
651  // ugh. dir separator here is UNIX specific..
652  const QStringList dirs = pathDir.absolutePath().split('/');
653  QString currentDir;
654 
655  QStringList::const_iterator end(dirs.end());
656  for (QStringList::const_iterator dir(dirs.begin()); dir != end; ++dir) {
657  currentDir += '/' + *dir;
658  if (! (pathDir.exists(currentDir) || pathDir.mkdir(currentDir))) {
659  KMessageBox::error(0, i18n("Cannot create the folder:\n") +
660  pathDir.absolutePath() + i18n("\nPlease check the access rights"),
661  i18n("Cannot Create Folder"));
662  return NULL;
663  }
664  }
665  }
666  }
667 
668  name.simplified();
669  name.replace(QRegExp(" "),"_");
670 
671  return overwritableName(name, codeDocument->getFileExtension());
672 }
673 
682 void CodeGenerator::findObjectsRelated(UMLClassifier *c, UMLPackageList &cList)
683 {
684  UMLPackage *temp;
685  UMLAssociationList associations = c->getAssociations();
686 
687  foreach (UMLAssociation *a, associations) {
688  temp = 0;
689  switch (a->getAssocType()) {
690  case Uml::AssociationType::Generalization:
691  case Uml::AssociationType::Realization:
692  // only the "b" end is seen by the "a" end, not other way around
693  {
694  UMLObject *objB = a->getObject(Uml::RoleType::B);
695  if (objB != c) {
696  temp = (UMLPackage*)objB;
697  }
698  }
699  break;
700  case Uml::AssociationType::Dependency:
701  case Uml::AssociationType::UniAssociation:
702  {
703  UMLObject *objA = a->getObject(Uml::RoleType::A);
704  UMLObject *objB = a->getObject(Uml::RoleType::B);
705  if (objA == c) {
706  temp = static_cast<UMLPackage*>(objB);
707  }
708  }
709  break;
710  case Uml::AssociationType::Aggregation:
711  case Uml::AssociationType::Composition:
712  case Uml::AssociationType::Association:
713  {
714  UMLObject *objA = a->getObject(Uml::RoleType::A);
715  UMLObject *objB = a->getObject(Uml::RoleType::B);
716  if (objA == c && objB->baseType() != UMLObject::ot_Datatype) {
717  temp = static_cast<UMLPackage*>(objB);
718  }
719  }
720  break;
721  default: // all others.. like for state diagrams..we currently don't use
722  break;
723  }
724 
725  // now add in list ONLY if it is not already there
726  if (temp && !cList.count(temp)) {
727  cList.append(temp);
728  }
729  }
730 
731  //operations
732  UMLOperationList opl(c->getOpList());
733  foreach(UMLOperation *op, opl) {
734  temp = 0;
735  //check return value
736  temp = (UMLClassifier*) op->getType();
737  if (temp && temp->baseType() != UMLObject::ot_Datatype && !cList.count(temp)) {
738  cList.append(temp);
739  }
740  //check parameters
741  UMLAttributeList atl = op->getParmList();
742  foreach(UMLAttribute *at, atl) {
743  temp = (UMLClassifier*)at->getType();
744  if (temp && temp->baseType() != UMLObject::ot_Datatype && !cList.count(temp)) {
745  cList.append(temp);
746  }
747  }
748  }
749 
750  //attributes
751  if (!c->isInterface()) {
752  UMLAttributeList atl = c->getAttributeList();
753  foreach (UMLAttribute *at, atl) {
754  temp=0;
755  temp = (UMLClassifier*) at->getType();
756  if (temp && temp->baseType() != UMLObject::ot_Datatype && !cList.count(temp)) {
757  cList.append(temp);
758  }
759  }
760  }
761 }
762 
772 QString CodeGenerator::formatDoc(const QString &text, const QString &linePrefix, int lineWidth)
773 {
774  const QString endLine = UMLApp::app()->commonPolicy()->getNewLineEndingChars();
775  QString output;
776  QStringList lines = text.split(endLine);
777  for (QStringList::ConstIterator lit = lines.constBegin(); lit != lines.constEnd(); ++lit) {
778  QString input = *lit;
779  input.remove(QRegExp("\\s+$"));
780  if (input.length() < lineWidth) {
781  output += linePrefix + input + endLine;
782  continue;
783  }
784  int index;
785  while ((index = input.lastIndexOf(" ", lineWidth)) >= 0) {
786  output += linePrefix + input.left(index) + endLine; // add line
787  input.remove(0, index + 1); // remove processed string, including white space
788  }
789  if (!input.isEmpty()) {
790  output += linePrefix + input + endLine;
791  }
792  }
793  return output;
794 }
795 
803 QString CodeGenerator::formatSourceCode(const QString& code, const QString& indentation)
804 {
805  const QString endLine = UMLApp::app()->commonPolicy()->getNewLineEndingChars();
806  QString output;
807  if (! code.isEmpty()) {
808  QStringList lines = code.split(endLine);
809  for (int i = 0; i < lines.size(); ++i) {
810  output += indentation + lines.at(i) + endLine;
811  }
812  }
813  return output;
814 }
815 
821 void CodeGenerator::connect_newcodegen_slots()
822 {
823  connect(m_document, SIGNAL(sigObjectCreated(UMLObject*)),
824  this, SLOT(checkAddUMLObject(UMLObject*)));
825  connect(m_document, SIGNAL(sigObjectRemoved(UMLObject*)),
826  this, SLOT(checkRemoveUMLObject(UMLObject*)));
827  CodeGenerationPolicy *commonPolicy = UMLApp::app()->commonPolicy();
828  connect(commonPolicy, SIGNAL(modifiedCodeContent()),
829  this, SLOT(syncCodeToDocument()));
830 }
831 
832 // these are utility methods for accessing the default
833 // code gen policy object and should go away when we
834 // finally implement the CodeGenDialog class -b.t.
835 
836 void CodeGenerator::setForceDoc(bool f)
837 {
838  UMLApp::app()->commonPolicy()->setCodeVerboseDocumentComments(f);
839 }
840 
841 bool CodeGenerator::forceDoc() const
842 {
843  return UMLApp::app()->commonPolicy()->getCodeVerboseDocumentComments();
844 }
845 
846 void CodeGenerator::setForceSections(bool f)
847 {
848  UMLApp::app()->commonPolicy()->setCodeVerboseSectionComments(f);
849 }
850 
851 bool CodeGenerator::forceSections() const
852 {
853  return UMLApp::app()->commonPolicy()->getCodeVerboseSectionComments();
854 }
855 
860 QStringList CodeGenerator::defaultDatatypes()
861 {
862  return QStringList();
863  //empty by default, override in your code generator
864 }
865 
873 bool CodeGenerator::isReservedKeyword(const QString & keyword)
874 {
875  const QStringList keywords = reservedKeywords();
876  return keywords.contains(keyword);
877 }
878 
882 QStringList CodeGenerator::reservedKeywords() const
883 {
884  static QStringList emptyList;
885  return emptyList;
886 }
887 
891 void CodeGenerator::createDefaultStereotypes()
892 {
893  //empty by default, override in your code generator
894  //e.g. m_document->createDefaultStereotypes("constructor");
895 }
896 
897 #include "codegenerator.moc"
Uml::AssociationType::Aggregation
Definition: basictypes.h:101
UMLAssociation::getObject
UMLObject * getObject(Uml::RoleType::Enum role) const
Returns the UMLObject assigned to the given role.
Definition: association.cpp:476
umlobject.h
UMLPackage
This class contains the non-graphical information required for a UML Package.
Definition: package.h:32
UMLClassifier
This class defines the non-graphical information required for a UML Classifier (ie a class or interfa...
Definition: classifier.h:39
Uml::AssociationType::Generalization
Definition: basictypes.h:100
CodeGenerator::overwritableName
QString overwritableName(const QString &name, const QString &extension)
Remove (and possibly delete) all AutoGenerated content type CodeDocuments but leave the UserGenerated...
Definition: codegenerator.cpp:502
UMLClassifierListItem::getType
UMLClassifier * getType() const
Returns the type of the UMLClassifierListItem.
Definition: classifierlistitem.cpp:100
CodeDocumentList
QList< CodeDocument * > CodeDocumentList
Definition: codedocumentlist.h:17
CodeGenerator::setForceSections
void setForceSections(bool f)
Definition: codegenerator.cpp:846
association.h
CodeGenerator::getCodeViewerDialog
virtual CodeViewerDialog * getCodeViewerDialog(QWidget *parent, CodeDocument *doc, Settings::CodeViewerState state)
Get the editing dialog for this code document.
Definition: codegenerator.cpp:181
CodeGenerator::loadFromXMI
virtual void loadFromXMI(QDomElement &element)
Load codegenerator data from xmi.
Definition: codegenerator.cpp:191
ClassifierCodeDocument
class ClassifierCodeDocument A CodeDocument which represents a UMLClassifier (e.g.
Definition: classifiercodedocument.h:33
Uml::RoleType::A
Definition: basictypes.h:209
CodeGenerator::addCodeDocument
bool addCodeDocument(CodeDocument *add_object)
Add a CodeDocument object to the m_codedocumentVector List.
Definition: codegenerator.cpp:127
Uml::AssociationType::UniAssociation
Definition: basictypes.h:112
codedocument.h
CodeGenerator::openFile
bool openFile(QFile &file, const QString &name)
Opens a file named "name" for writing in the outputDirectory.
Definition: codegenerator.cpp:586
CodeGenerator::formatDoc
static QString formatDoc(const QString &text, const QString &linePrefix=" *", int lineWidth=80)
Format documentation for output in source files.
Definition: codegenerator.cpp:772
CodeGenerationPolicy::getNewLineEndingChars
QString getNewLineEndingChars() const
Utility function to get the actual characters.
Definition: codegenerationpolicy.cpp:248
CodeGenerator::isReservedKeyword
virtual bool isReservedKeyword(const QString &keyword)
Check whether the given string is a reserved word for the language of this code generator.
Definition: codegenerator.cpp:873
Uml::RoleType::B
Definition: basictypes.h:210
CodeDocument::loadFromXMI
virtual void loadFromXMI(QDomElement &root)
Load params from the appropriate XMI element node.
Definition: codedocument.cpp:347
QWidget
UMLApp::app
static UMLApp * app()
Get the last created instance of this class.
Definition: uml.cpp:206
UMLAttribute
This class is used to set up information for an attribute.
Definition: attribute.h:27
CodeGenerator::m_document
UMLDoc * m_document
The document object.
Definition: codegenerator.h:189
CodeGenerator::writeCodeToFile
virtual void writeCodeToFile()
This method is here to provide class wizard the ability to write out only those classes which are sel...
Definition: codegenerator.cpp:390
CodeGenerationPolicy
class CodeGenerationPolicy This class describes the code generation policy for this project...
Definition: codegenerationpolicy.h:29
UMLAttributeList
This sub-class adds copyInto and clone to the QPtrList base class.
Definition: umlattributelist.h:26
CodeGenerationPolicy::Cancel
Definition: codegenerationpolicy.h:46
CodeGenerationPolicy::setCodeVerboseDocumentComments
void setCodeVerboseDocumentComments(bool new_var)
Set the value of m_codeVerboseDocumentComments Whether or not verbose code commenting for documentati...
Definition: codegenerationpolicy.cpp:134
CodeGenerator::newCodeDocument
virtual CodeDocument * newCodeDocument()
Create a new Code document belonging to this package.
Definition: codegenerator.cpp:458
UMLObject::ot_Operation
Definition: umlobject.h:59
CodeGenerator::getHeadingFile
virtual QString getHeadingFile(const QString &file)
Gets the heading file (as a string) to be inserted at the beginning of the generated file...
Definition: codegenerator.cpp:482
uWarning
#define uWarning()
Definition: debug_utils.h:97
ClassifierCodeDocument::getParentClassifier
UMLClassifier * getParentClassifier()
Get the value of m_parentclassifier.
Definition: classifiercodedocument.cpp:271
CodeGenerator::findCodeDocumentByID
CodeDocument * findCodeDocumentByID(const QString &id)
Find a code document by the given id string.
Definition: codegenerator.cpp:112
classifier.h
debug_utils.h
CodeDocument::getPath
virtual QString getPath()
Get the value of the path to this code document.
Definition: codedocument.cpp:100
overwritedialogue.h
CodeGenerator::connect_newcodegen_slots
void connect_newcodegen_slots()
Connect additional slots.
Definition: codegenerator.cpp:821
Uml::AssociationType::Dependency
Definition: basictypes.h:102
codegenerationpolicy.h
UMLObject
This class is the non-graphical version of UMLWidget.
Definition: umlobject.h:41
UMLAssociation
This class contains the non-graphic representation of an association.
Definition: association.h:32
CodeGenerator::checkAddUMLObject
virtual void checkAddUMLObject(UMLObject *obj)
This function checks for adding objects to the UMLDocument.
Definition: codegenerator.cpp:343
CodeGenerationPolicy::getOutputDirectory
QDir getOutputDirectory()
Get the value of m_outputDirectory location of where output files will go.
Definition: codegenerationpolicy.cpp:206
CodeGenerator::forceDoc
bool forceDoc() const
Definition: codegenerator.cpp:841
UMLCanvasObject::getAssociations
UMLAssociationList getAssociations()
Return the list of associations for the CanvasObject.
Definition: umlcanvasobject.cpp:337
CodeGenerationPolicy::getCodeVerboseDocumentComments
bool getCodeVerboseDocumentComments() const
Get the value of m_codeVerboseDocumentComments Whether or not verbose code commenting for documentati...
Definition: codegenerationpolicy.cpp:147
simplecodegenerator.h
CodeGenerator::language
virtual Uml::ProgrammingLanguage::Enum language() const =0
Return the unique language enum that identifies this type of code generator.
codegenerator.h
UMLObject::toString
static QString toString(ObjectType ot)
Helper function for debug output.
Definition: umlobject.cpp:1094
UMLOperation::setSourceCode
void setSourceCode(const QString &code)
Sets the source code for this operation.
Definition: operation.cpp:432
UMLClassifier::isInterface
bool isInterface() const
Returns true if this classifier represents an interface.
Definition: classifier.cpp:112
attribute.h
CodeGenerator::CodeGenerator
CodeGenerator()
Constructor for a code generator.
Definition: codegenerator.cpp:54
CodeGenerator::reservedKeywords
virtual QStringList reservedKeywords() const
Get list of reserved keywords.
Definition: codegenerator.cpp:882
umlattributelist.h
CodeGenerator::codeGenerated
void codeGenerated(UMLClassifier *concept, bool generated)
UMLAssociation::getAssocType
Uml::AssociationType::Enum getAssocType() const
Returns the AssociationType::Enum of the UMLAssociation.
Definition: association.cpp:103
CodeGenerator::defaultDatatypes
virtual QStringList defaultDatatypes()
Return the default datatypes for your language (bool, int etc).
Definition: codegenerator.cpp:860
Uml::ProgrammingLanguage::toString
QString toString(Enum item)
Return string corresponding to the given ProgrammingLanguage.
Definition: basictypes.cpp:801
CodeGenerator::getUniqueID
QString getUniqueID(CodeDocument *codeDoc)
Get a unique id for this codedocument.
Definition: codegenerator.cpp:80
CodeDocument::ID
QString ID() const
Get the value of m_ID.
Definition: codedocument.cpp:142
CodeDocument::getFileExtension
QString getFileExtension() const
Get the value of m_fileExtension.
Definition: codedocument.cpp:82
CodeDocument
A document containing the code for one file.
Definition: codedocument.h:32
CodeGenerationPolicy::Never
Definition: codegenerationpolicy.h:46
UMLClassifierList
QList< UMLClassifier * > UMLClassifierList
Definition: umlclassifierlist.h:17
Uml::AssociationType::Association
Definition: basictypes.h:103
CodeGenerator::saveToXMI
virtual void saveToXMI(QDomDocument &doc, QDomElement &root)
Save the XMI representation of this object.
Definition: codegenerator.cpp:258
UMLApp
The base class for UML application windows.
Definition: uml.h:81
umloperationlist.h
uDebug
#define uDebug()
Definition: debug_utils.h:95
UMLPackageList
QList< UMLPackage * > UMLPackageList
Definition: umlpackagelist.h:17
Uml::AssociationType::Realization
Definition: basictypes.h:111
CodeGenerator::formatSourceCode
static QString formatSourceCode(const QString &code, const QString &indentation)
Format source code for output in source files by adding the correct indentation to every line of code...
Definition: codegenerator.cpp:803
CodeGenerator::findObjectsRelated
static void findObjectsRelated(UMLClassifier *c, UMLPackageList &cList)
Finds all classes in the current document to which objects of class c are in some way related...
Definition: codegenerator.cpp:682
CodeGenerationPolicy::setCodeVerboseSectionComments
void setCodeVerboseSectionComments(bool new_var)
Set the value of m_codeVerboseSectionComments Whether or not verbose code commenting for sections is ...
Definition: codegenerationpolicy.cpp:110
CodeViewerDialog
This class is sooo ugly I don't know where to begin.
Definition: codeviewerdialog.h:27
UMLApp::commonPolicy
CodeGenerationPolicy * commonPolicy() const
Returns the default code generation policy.
Definition: uml.cpp:2132
Uml::AssociationType::Composition
Definition: basictypes.h:110
CodeGenerator::getCodeDocumentList
CodeDocumentList * getCodeDocumentList()
Get the list of CodeDocument objects held by m_codedocumentVector.
Definition: codegenerator.cpp:171
UMLDoc::classesAndInterfaces
UMLClassifierList classesAndInterfaces(bool includeNested=true)
Returns a list of the classes and interfaces in this UMLDoc.
Definition: umldoc.cpp:2491
Uml::ID::Type
std::string Type
Definition: basictypes.h:317
CodeGenerationPolicy::getOverwritePolicy
OverwritePolicy getOverwritePolicy() const
Get the value of m_overwritePolicy Policy of how to deal with overwriting existing files...
Definition: codegenerationpolicy.cpp:80
codeviewerdialog.h
CodeGenerationPolicy::getCodeVerboseSectionComments
bool getCodeVerboseSectionComments() const
Get the value of m_codeVerboseSectionComments Whether or not verbose code commenting for sections is ...
Definition: codegenerationpolicy.cpp:122
UMLObject::baseType
ObjectType baseType() const
Returns the type of the object.
Definition: umlobject.cpp:366
CodeGenerator::m_applyToAllRemaining
bool m_applyToAllRemaining
Used by overwriteDialogue to know if the apply to all remaining files checkbox should be checked (is ...
Definition: codegenerator.h:184
Settings::CodeViewerState
configurable params for the code viewer tool
Definition: codeviewerstate.h:20
Uml::ID::toString
QString toString(const ID::Type &id)
Definition: basictypes.cpp:1048
CodeGenerator::createDefaultStereotypes
virtual void createDefaultStereotypes()
Create the default stereotypes for your language (constructor, int etc).
Definition: codegenerator.cpp:891
UMLDoc::findObjectById
UMLObject * findObjectById(Uml::ID::Type id)
Used to find a reference to a UMLObject by its ID.
Definition: umldoc.cpp:766
UMLClassifier::getAttributeList
UMLAttributeList getAttributeList() const
Returns the attributes for the specified scope.
Definition: classifier.cpp:441
operation.h
OverwriteDialogue
Used by CodeGenerator::findFileName when it needs to ask the user if they want to overwrite and exist...
Definition: overwritedialogue.h:29
umldoc.h
CodeGenerator::checkRemoveUMLObject
virtual void checkRemoveUMLObject(UMLObject *obj)
This function checks for removing objects from the UMLDocument.
Definition: codegenerator.cpp:359
UMLOperation
This class represents an operation in the UML model.
Definition: operation.h:24
UMLObject::ObjectType
ObjectType
Definition: umlobject.h:47
CodeGenerator::setForceDoc
void setForceDoc(bool f)
Definition: codegenerator.cpp:836
CodeGenerator::newClassifierCodeDocument
virtual CodeDocument * newClassifierCodeDocument(UMLClassifier *classifier)=0
A series of accessor method constructors that we need to define for any particular language...
CodeGenerator::writeListedCodeDocsToFile
void writeListedCodeDocsToFile(CodeDocumentList *docs)
The actual internal routine which writes code documents.
Definition: codegenerator.cpp:419
CodeGenerator::findCodeDocumentByClassifier
CodeDocument * findCodeDocumentByClassifier(UMLClassifier *classifier)
Find a code document by the given classifier.
Definition: codegenerator.cpp:380
CodeGenerator::m_codeDocumentDictionary
QHash< QString, CodeDocument * > m_codeDocumentDictionary
Definition: codegenerator.h:178
UMLOperation::getSourceCode
QString getSourceCode() const
Returns the source code for this operation.
Definition: operation.cpp:440
CodeGenerator::~CodeGenerator
virtual ~CodeGenerator()
Destructor.
Definition: codegenerator.cpp:69
CodeGenerator::removeCodeDocument
bool removeCodeDocument(CodeDocument *remove_object)
Replace (or possibly add a new) CodeDocument object to the m_codedocumentVector List.
Definition: codegenerator.cpp:152
uError
#define uError()
Definition: debug_utils.h:96
UMLClassifier::getOpList
UMLOperationList getOpList(bool includeInherited=false, UMLClassifierSet *alreadyTraversed=0)
Return a list of operations for the Classifier.
Definition: classifier.cpp:960
CodeGenerator::forceSections
bool forceSections() const
Definition: codegenerator.cpp:851
CodeGenerator::cleanName
static QString cleanName(const QString &name)
Replaces spaces with underscores and capitalises as defined in m_modname.
Definition: codegenerator.cpp:609
CodeGenerator::findFileName
QString findFileName(CodeDocument *codeDocument)
Finds an appropriate file name for the given CodeDocument, taking into account the Overwrite Policy a...
Definition: codegenerator.cpp:625
CodeGenerator::showGeneratedFile
void showGeneratedFile(const QString &filename)
CodeGenerator::syncCodeToDocument
virtual void syncCodeToDocument()
Force a synchronize of this code generator, and its present contents, to that of the parent UMLDocume...
Definition: codegenerator.cpp:328
CodeGenerationPolicy::Ok
Definition: codegenerationpolicy.h:46
Uml::ID::fromString
ID::Type fromString(const QString &id)
Definition: basictypes.cpp:1053
classifiercodedocument.h
CodeGenerationPolicy::getHeadingFile
QString getHeadingFile(const QString &str)
Gets the heading file (as a string) to be inserted at the beginning of the generated file...
Definition: codegenerationpolicy.cpp:540
CodeGenerationPolicy::Ask
Definition: codegenerationpolicy.h:46
CodeDocument::getFileName
QString getFileName() const
Get the value of m_filename.
Definition: codedocument.cpp:63
UMLObject::ot_Datatype
Definition: umlobject.h:54
keyword
static const struct HashTable keyword
Definition: keywords.lut.h:123
CodeDocument::setID
void setID(const QString &new_id)
Set the value of m_ID.
Definition: codedocument.cpp:133
CodeGenerationPolicy::setOverwritePolicy
void setOverwritePolicy(OverwritePolicy new_var)
Set the value of m_overwritePolicy Policy of how to deal with overwriting existing files...
Definition: codegenerationpolicy.cpp:69
uml.h
QList
UMLOperation::getParmList
UMLAttributeList getParmList() const
Returns a list of parameters.
Definition: operation.cpp:171
CodeGenerator::initFromParentDocument
virtual void initFromParentDocument()
Initialize this code generator from its parent UMLDoc.
Definition: codegenerator.cpp:308
UMLObject::id
virtual Uml::ID::Type id() const
Returns the ID of the object.
Definition: umlobject.cpp:394
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:05:59 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

umbrello/umbrello

Skip menu "umbrello/umbrello"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdesdk API Reference

Skip menu "kdesdk API Reference"
  • kapptemplate
  • kcachegrind
  • kompare
  • lokalize
  • okteta
  • umbrello
  •   umbrello

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal