umbrello API Documentation

rubycodegenerationpolicy.cpp

00001 /***************************************************************************
00002                           rubycodegenerationpolicy.cpp
00003                           Derived from the Java code generator by thomas
00004 
00005     begin                : Thur Jul 21 2005
00006     author               : Richard Dale
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  *   copyright (C) 2006-2007                                               *
00017  *   Umbrello UML Modeller Authors <uml-devel@uml.sf.net>                  *
00018  ***************************************************************************/
00019 
00020 // own header
00021 #include "rubycodegenerationpolicy.h"
00022 // qt/kde includes
00023 #include <kconfig.h>
00024 // app includes
00025 #include "rubycodegenerationpolicypage.h"
00026 #include "rubycodegenerator.h"
00027 #include "../uml.h"
00028 
00029 const bool RubyCodeGenerationPolicy::DEFAULT_AUTO_GEN_ATTRIB_ACCESSORS = true;
00030 const bool RubyCodeGenerationPolicy::DEFAULT_AUTO_GEN_ASSOC_ACCESSORS = true;
00031 
00032 // Constructors/Destructors
00033 //
00034 
00035 RubyCodeGenerationPolicy::RubyCodeGenerationPolicy(KConfig *config)
00036 {
00037     init();
00038     setDefaults(config,false);
00039 }
00040 
00041 RubyCodeGenerationPolicy::~RubyCodeGenerationPolicy ( ) { }
00042 
00043 //
00044 // Methods
00045 //
00046 
00047 // Accessor methods
00048 //
00049 
00050 // Public attribute accessor methods
00051 //
00052 
00057 void RubyCodeGenerationPolicy::setAutoGenerateAttribAccessors( bool var ) {
00058     m_autoGenerateAttribAccessors = var;
00059     m_commonPolicy->emitModifiedCodeContentSig();
00060 }
00061 
00066 void RubyCodeGenerationPolicy::setAutoGenerateAssocAccessors( bool var ) {
00067     m_autoGenerateAssocAccessors = var;
00068     m_commonPolicy->emitModifiedCodeContentSig();
00069 }
00070 
00075 bool RubyCodeGenerationPolicy::getAutoGenerateAttribAccessors( ){
00076     return m_autoGenerateAttribAccessors;
00077 }
00078 
00083 bool RubyCodeGenerationPolicy::getAutoGenerateAssocAccessors( ){
00084     return m_autoGenerateAssocAccessors;
00085 }
00086 
00087 // Other methods
00088 //
00089 
00090 void RubyCodeGenerationPolicy::writeConfig ( KConfig * config )
00091 {
00092     // @todo do we need to call CodeGenerationPolicy::writeConfig ???
00093 
00094     // write ONLY the Ruby specific stuff
00095     config->setGroup("Ruby Code Generation");
00096 
00097     config->writeEntry("autoGenAccessors",getAutoGenerateAttribAccessors());
00098     config->writeEntry("autoGenAssocAccessors",getAutoGenerateAssocAccessors());
00099 }
00100 
00101 void RubyCodeGenerationPolicy::setDefaults ( CodeGenPolicyExt * clone, bool emitUpdateSignal )
00102 {
00103 
00104     RubyCodeGenerationPolicy * rclone;
00105     if (!clone)
00106         return;
00107 
00108     // NOW block signals for ruby param setting
00109     blockSignals(true); // we need to do this because otherwise most of these
00110     // settors below will each send the modifiedCodeContent() signal
00111     // needlessly (we can just make one call at the end).
00112 
00113 
00114     // now do ruby-specific stuff IF our clone is also a RubyCodeGenerationPolicy object
00115     if((rclone = dynamic_cast<RubyCodeGenerationPolicy*>(clone)))
00116     {
00117         setAutoGenerateAttribAccessors(rclone->getAutoGenerateAttribAccessors());
00118         setAutoGenerateAssocAccessors(rclone->getAutoGenerateAssocAccessors());
00119     }
00120 
00121     blockSignals(false); // "as you were citizen"
00122 
00123     if(emitUpdateSignal)
00124         m_commonPolicy->emitModifiedCodeContentSig();
00125 
00126 }
00127 
00128 void RubyCodeGenerationPolicy::setDefaults( KConfig * config, bool emitUpdateSignal )
00129 {
00130 
00131     if(!config)
00132         return;
00133 
00134     // call the superclass to init default stuff
00135     m_commonPolicy->setDefaults(config, false);
00136 
00137     // NOW block signals (because call to super-class method will leave value at "true")
00138     blockSignals(true); // we need to do this because otherwise most of these
00139     // settors below will each send the modifiedCodeContent() signal
00140     // needlessly (we can just make one call at the end).
00141 
00142     // now do ruby specific stuff
00143     config -> setGroup("Ruby Code Generation");
00144 
00145     setAutoGenerateAttribAccessors(config->readBoolEntry("autoGenAccessors",DEFAULT_AUTO_GEN_ATTRIB_ACCESSORS));
00146     setAutoGenerateAssocAccessors(config->readBoolEntry("autoGenAssocAccessors",DEFAULT_AUTO_GEN_ASSOC_ACCESSORS));
00147 
00148     blockSignals(false); // "as you were citizen"
00149 
00150     if(emitUpdateSignal)
00151         m_commonPolicy->emitModifiedCodeContentSig();
00152 }
00153 
00154 
00159 CodeGenerationPolicyPage * RubyCodeGenerationPolicy::createPage ( QWidget *parent, const char *name ) {
00160     return new RubyCodeGenerationPolicyPage ( parent, name, this );
00161 }
00162 
00163 void RubyCodeGenerationPolicy::init() {
00164     m_commonPolicy = UMLApp::app()->getCommonPolicy();
00165     m_autoGenerateAttribAccessors = DEFAULT_AUTO_GEN_ATTRIB_ACCESSORS;
00166     m_autoGenerateAssocAccessors = DEFAULT_AUTO_GEN_ASSOC_ACCESSORS;
00167 }
00168 
00169 
00170 #include "rubycodegenerationpolicy.moc"
KDE Logo
This file is part of the documentation for umbrello Version 3.1.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Jun 26 08:08:00 2007 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003