Main Page | Class Hierarchy | Class List | Directories | File List | Class Members | Related Pages

Module.h

00001 /***************************************************************************
00002  *   Copyright (C) 2006 by Graeme Foster                                   *
00003  *   email    foster.graeme@gmail.com                                      *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 
00021 #ifndef __MODULE_H
00022 #define __MODULE_H
00023 
00024 #include "DataClass.h"
00025 #include "Programme.h"
00026 
00027 class Module : public DataClass
00028 {
00029 private: // Properties
00030 //      Programme *     parent;
00031         QString         name;
00032         QString         nomenclature;
00033         int                     duration;
00034         int                     weeklyPeriods;
00035         short                   semester;
00036         
00037 protected: // Properties
00038         friend class ModuleItem;
00039         static int insertSQL;
00040         static int updateSQL;
00041         static int deleteSQL;
00042         static int uniqueNameSQL;
00043         static int uniqueNomenclatureSQL;
00044         static int errorSQL;
00045         
00046 public: // Methods
00047         // Constructor
00048         Module();
00049         Module(int pID
00050                         ,Programme * parent
00051                         ,QString name
00052                         ,QString nomenclature
00053                         ,int duration
00054                         ,int weeklyPeriods
00055                         ,short pSemester);
00056         static void PrepareSQL(sql * dbConn);
00057 
00058         // Get Methods
00059         inline virtual QString getDescription()const{return getNomenclature();}
00060         inline QString getName()const{return name;}
00061         inline QString getNomenclature()const{return nomenclature;}
00062         inline int getDuration()const{return duration;}
00063         inline int getWeeklyPeriods()const{return weeklyPeriods;}
00064         inline short getSemester()const{return semester;}
00065         inline Institute * getInst();
00066         inline QString getInstName()const;
00067         inline int getInstID();
00068         inline Programme * getProg(){return static_cast<Programme *>(parent);}
00069         inline QString getProgName()const;
00070         inline int getProgID() {return getParentID();}
00071         // Set Methods
00072         inline bool setName(QString pName){name = pName; return true;}
00073         inline bool setNomenclature(QString pNomenclature){nomenclature = pNomenclature; return true;}
00074         inline bool setDuration(int pDuration){duration = pDuration; return true;}
00075         inline bool setWeeklyPeriods(int pPeriods){weeklyPeriods = pPeriods; return true;}
00076         inline bool setSemester(int pSem){semester = pSem; return true;}
00077         // Methods to determine if the field is unique 
00078         static bool uniqueName(QString name, int parentID);
00079         static bool uniqueNomenclature(QString nomenclature, int parentID);
00080 
00081         inline bool isEvenSem(){if (semester%2==0) return true; else return false;}
00082         inline bool isOddSem(){if (semester%2==1) return true; else return false;}
00083         
00084 protected: // Methods
00085         void bindValues(int preparedSQL, int start);
00086 };
00087 
00088 inline Institute * Module::getInst()
00089 {
00090         if (parent!= 0)
00091                 return getProg()->getInstitute();
00092         else
00093                 return 0;
00094 }
00095 
00096 inline int Module::getInstID()
00097 {
00098         if (parent!= 0)
00099                 return getProg()->getInstID();
00100         else
00101                 return NO_PARENT;
00102 }
00103 
00104 inline QString Module::getInstName()const
00105 {
00106         if (parent!= 0)
00107                 return static_cast<Programme *>(parent)->getInstName();
00108         else
00109                 return QString();
00110 }
00111 
00112 inline QString Module::getProgName()const
00113 {
00114         if (parent!= 0)
00115                 return static_cast<Programme *>(parent)->getName();
00116         else
00117                 return QString();
00118 }
00119 
00120 #endif

Generated on Thu Apr 6 16:27:16 2006 for time-table by  doxygen 1.4.4