00001 /* 00002 * Copyright (C) 2003-2009 Olivier Boudeville 00003 * 00004 * This file is part of the Ceylan library. 00005 * 00006 * The Ceylan library is free software: you can redistribute it and/or modify 00007 * it under the terms of either the GNU Lesser General Public License or 00008 * the GNU General Public License, as they are published by the Free Software 00009 * Foundation, either version 3 of these Licenses, or (at your option) 00010 * any later version. 00011 * 00012 * The Ceylan library is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU Lesser General Public License and the GNU General Public License 00016 * for more details. 00017 * 00018 * You should have received a copy of the GNU Lesser General Public 00019 * License and the GNU General Public License along with the Ceylan library. 00020 * If not, see <http://www.gnu.org/licenses/>. 00021 * 00022 * Author: Olivier Boudeville (olivier.boudeville@esperide.com) 00023 * 00024 */ 00025 00026 00027 #ifndef CEYLAN_GENERIC_MVC_DEFINES_H_ 00028 #define CEYLAN_GENERIC_MVC_DEFINES_H_ 00029 00030 00031 #include "CeylanException.h" // for inheritance 00032 00033 00034 #include <string> 00035 00036 00037 00038 /* 00039 * @note In most cases, this generic (template-based) MVC version should be 00040 * preferred to the event-based MVC one (ex: based on Ceylan::MVC::Model). 00041 * 00042 */ 00043 00044 00045 /* 00046 * With the MVC framework, we have Controller -> Model -> View, with '->' 00047 * meaning "depending on". 00048 * 00049 * Therefore a model, in terms of declaration, could depend (only) on its 00050 * views. 00051 * 00052 * However, in terms of life-cycle management, having a model know all its 00053 * MVC-related components (views and controllers) is more convenient, as 00054 * when the model determines it should be deallocated, it can manage 00055 * automatically its related objects (i.e. deallocate its views and 00056 * controllers). 00057 * 00058 * All references detained by a MVC instance to other instances should be 00059 * 'const': if A -> B, then A will not post updates to B, on the contrary B 00060 * will pick information from A, thus A may reference B just for life-cycle 00061 * reasons ('const' will suffice), and B will only call 'const' methods of A 00062 * to get the informations it needs (hence 'const' should suffice again). 00063 * 00064 */ 00065 00066 00067 /* 00068 * Note that, at this level of abstraction, a MVC class does not have to know 00069 * the specific class(es) it depends on (ex: a SingleViewGenericModel just 00070 * need a BaseView pointer, regardless of the actual view class). 00071 * 00072 * However, the point is that, as soon as these mother classes are subclassed, 00073 * these actual subclasses will need to know the specific class they 00074 * depend on, as they intend to call their class-specific methods. 00075 * Hence for example a SingleViewGenericModel would need to rely on a 00076 * referencee to MySpecificView, rather than on a mere BaseView. 00077 * 00078 * Therefore, as soon as a MVC class can have a reference on another, we 00079 * indeed need to define a templated version of it, so that we keep the 00080 * actual type (class) of referenced instances. 00081 * 00082 */ 00083 00084 00085 00086 // Allows to avoid complex header dependencies. 00087 00088 00089 namespace Ceylan 00090 { 00091 00092 00093 namespace MVC 00094 { 00095 00096 00097 class GenericMVCException : public Ceylan::Exception 00098 { 00099 00100 public: 00101 00102 00103 GenericMVCException( const std::string & message ) : 00104 Ceylan::Exception( message ) 00105 { 00106 00107 } 00108 00109 00110 virtual ~GenericMVCException() throw() 00111 { 00112 00113 } 00114 00115 } ; 00116 00117 00118 } 00119 00120 00121 } 00122 00123 00124 00125 #endif // CEYLAN_GENERIC_MVC_DEFINES_H_ 00126