
/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

/*  This code generated by: 
 *      Author : thomas
 *      Date   : Mon Jun 23 2003
 */

#ifndef CPPCODEGENERATIONPOLICY_H
#define CPPCODEGENERATIONPOLICY_H

#include <qstring.h>
#include "../codegenerationpolicy.h"

class KConfig;
class CodeGenerationPolicyPage;
class CPPCodeGenerator;

class CPPCodeGenerationPolicy : public CodeGenerationPolicy
{
	Q_OBJECT
public:

	enum CPPCommentStyle { SlashStar=0, DoubleSlash };

	static const CPPCommentStyle DEFAULT_COMMENT;
        static const bool DEFAULT_AUTO_GEN_EMPTY_CONSTRUCTORS;
        static const bool DEFAULT_AUTO_GEN_ACCESSORS;
	static const bool DEFAULT_INLINE_ACCESSORS;
        static const bool DEFAULT_INLINE_OPERATIONS;
 	static const bool DEFAULT_VIRTUAL_DESTRUCTORS;
	static const bool DEFAULT_PACKAGE_IS_NAMESPACE;

	static const bool DEFAULT_STRING_INCLUDE_GLOBAL;
	static const bool DEFAULT_VECTOR_INCLUDE_GLOBAL;

	static const char * DEFAULT_STRING_CLASS_NAME;
	static const char * DEFAULT_STRING_CLASS_INCLUDE;
	static const char * DEFAULT_VECTOR_CLASS_NAME;
	static const char * DEFAULT_VECTOR_CLASS_INCLUDE;
	static const char * DEFAULT_VECTOR_METHOD_APPEND;
	static const char * DEFAULT_VECTOR_METHOD_REMOVE;
	static const char * DEFAULT_VECTOR_METHOD_INIT;
	static const char * DEFAULT_OBJECT_METHOD_INIT;

	// Constructors/Destructors
	//  

	/**
	 * Constructors 
	 */
	CPPCodeGenerationPolicy ( CPPCodeGenerator * parent, CodeGenerationPolicy * defaults = 0 );
	CPPCodeGenerationPolicy ( CPPCodeGenerator * parent, KConfig * config = 0 );

	/**
	 * Empty Destructor
	 */
	virtual ~CPPCodeGenerationPolicy ( );

	// Public attribute accessor methods
	//  

        /**
         * Set the value of m_inlineAccessors
         * @param new_var the new value
         */
        void setAccessorsAreInline ( bool var );

        /**
         * Get the value of m_inlineAccessors
         * @return value the boolean value of m_inlineAccessors
         */
        bool getAccessorsAreInline( );

        /**
         * Set the value of m_inlineOperations
         * @param new_var the new value
         */
        void setOperationsAreInline ( bool var );

        /**
         * Get the value of m_inlineOperations
         * @return value the boolean value of m_inlineOperations
         */
        bool getOperationsAreInline( );

       /**
         * Set the value of m_virtualDestructors
         * @param new_var the new value
         */
        void setDestructorsAreVirtual ( bool var );

        /**
         * Get the value of m_virtualDestructors
         * @return value the boolean value of m_virtualDestructors
         */
        bool getDestructorsAreVirtual( );

      /**
         * Set the value of m_packageIsNamespace
         * @param new_var the new value
         */
        void setPackageIsNamespace ( bool var );

        /**
         * Get the value of m_packageIsNamespace
         * @return value the boolean value of m_packageIsNamespace
         */
        bool getPackageIsNamespace( );


       /**
         * Set the value of m_autoGenerateAccessors
         * @param new_var the new value
         */
        void setAutoGenerateAccessors ( bool var );

       /**
         * Get the value of m_autoGenerateAccessors
         * @return value the boolean value of m_autoGenerateAccessors
         */
        bool getAutoGenerateAccessors( );

	/**
         * Set the value of m_autoGenerateConstructors
         * @param new_var the new value
         */
	void setAutoGenerateConstructors ( bool var ); 

       /**
         * Get the value of m_autoGenerateConstructors
         * @return value the boolean value of m_autoGenerateConstructors
         */
	bool getAutoGenerateConstructors ( );

	/**
	 * Set the value of m_commentStyle
	 * @param new_var the new value of m_commentStyle
	 */
	void setCommentStyle ( CPPCommentStyle new_var );

	/**
	 * Get the value of m_commentStyle
	 * @return the value of m_commentStyle
	 */
	CPPCommentStyle getCommentStyle ( );

        // a little utiltity method to call getParentGenerator()->getBuildMakefile()
        bool getBuildMakefile();

        // a little utility method so we can have our codegenerationpolicy page can change
        // the status of the building the Makefile document 
        void setBuildMakefile(bool buildIt);

	/** We want to be flexible about which classes are allowed for generation
	 * of the CPP code. In the next 4 methods, we give accessors that allow getting
	 * the names of the classes, and their include files for string and vectors.
	 */
	QString getStringClassName();
	QString getStringClassNameInclude();
	QString getVectorClassName();
	QString getVectorClassNameInclude();

	/** determine if the string include is global one */
	bool stringIncludeIsGlobal ();
	bool vectorIncludeIsGlobal ();

         /** also allow setting these parameters! */
        void setStringClassName(QString value);
        void setStringClassNameInclude(QString value);
        void setVectorClassName(QString value);
        void setVectorClassNameInclude(QString value);

	/** allow setting of these params */
	void setStringIncludeIsGlobal (bool value);
	void setVectorIncludeIsGlobal (bool value);

	/** More flexible generation. We want to allow the user to specifiy how the 
	 *  bodies of the vector methods should be auto-generated.
	 */
	QString getVectorMethodAppend(const QString & variableName ="", const QString & itemClassName = "");
	QString getVectorMethodRemove(const QString & variableName ="", const QString & itemClassName = "");
	QString getVectorMethodInit(const QString & variableName ="", const QString & itemClassName = "");

	/** Be somewhat flexible about how new object classes are initialized.
	 * Not sure if this should be user configureable. For now, it isnt.
	 */
	QString getObjectMethodInit(const QString & variableName ="", const QString & itemClassName = "");

        /**
         * set the defaults for this code generator from the passed generator.
         */
        virtual void setDefaults (CodeGenerationPolicy * defaults, bool emitUpdateSignal = true);

        /**
         * set the defaults from a config file for this code generator from the passed KConfig pointer.
         */
        virtual void setDefaults(KConfig * config, bool emitUpdateSignal = true);

	/**
         * write Default params to passed KConfig pointer.
         */
        virtual void writeConfig (KConfig * config);

	/**
         * Create a new dialog interface for this object.
         * @return dialog object
         */
        CodeGenerationPolicyPage * createPage ( QWidget *parent = 0, const char * name = 0);

protected:

	/**
	 */
	void init ( );

private:

        CPPCodeGenerator * m_parentCodeGenerator;

	CPPCommentStyle m_commentStyle;
	bool m_autoGenerateConstructors;
        bool m_autoGenerateAccessors;

        bool m_inlineAccessors;
        bool m_inlineOperations;
        bool m_virtualDestructors;
        bool m_packageIsNamespace;

	bool m_stringIncludeIsGlobal;
	bool m_vectorIncludeIsGlobal;

	QString m_stringClassName;
	QString m_stringClassNameInclude;
	QString m_vectorClassName;
	QString m_vectorClassNameInclude;
	QString m_vectorMethodAppendBase;
	QString m_vectorMethodRemoveBase;
	QString m_vectorMethodInitBase;
	QString m_objectMethodInitBase;

	void initFields( CPPCodeGenerator * parent) ;

};

#endif // CPPCODEGENERATIONPOLICY_H
