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 * In terms of life-cycle management, having a model know all its 00050 * MVC-related components (views and controllers) is more convenient, as 00051 * when the model determines it should be deallocated, it can manage 00052 * automatically its related objects (i.e. deallocate its views and 00053 * controllers). 00054 * 00055 * All references detained by a MVC instance to other instances should be 00056 * 'const': if A -> B, then A will not post updates to B, on the contrary B 00057 * will pick information from A, thus A may reference B just for life-cycle 00058 * reasons ('const' will suffice), and B will only call 'const' methods of A 00059 * to get the informations it needs (hence 'const' should suffice again). 00060 * 00061 * Therefore A may only reference a generic mother class of B (as A 00062 * will not act on it, only maybe have to deallocate it), whereas B needs 00063 * to know the actual (specialized) class of A, since it will have to call 00064 * (const) methods of it. 00065 * 00066 */ 00067 00068 00069 /* 00070 * Note that, at this level of abstraction, a MVC class does not have to know 00071 * the specific class(es) it depends on (ex: a SingleViewGenericModel just 00072 * need a BaseView pointer, regardless of the actual view class). 00073 * 00074 * However, the point is that, as soon as these mother classes are subclassed, 00075 * these actual subclasses will need to know the specific class they 00076 * depend on, as they intend to call their class-specific methods. 00077 * Hence for example a SingleViewGenericModel would need to rely on a 00078 * referencee to MySpecificView, rather than on a mere BaseView. 00079 * 00080 * Therefore, as soon as a MVC class can have a reference on another, we 00081 * indeed need to define a templated version of it, so that we keep the 00082 * actual type (class) of referenced instances. 00083 * 00084 */ 00085 00086 00087 00088 // Allows to avoid complex header dependencies. 00089 00090 00091 namespace Ceylan 00092 { 00093 00094 00095 namespace MVC 00096 { 00097 00098 00099 class GenericMVCException : public Ceylan::Exception 00100 { 00101 00102 public: 00103 00104 00105 GenericMVCException( const std::string & message ) : 00106 Ceylan::Exception( message ) 00107 { 00108 00109 } 00110 00111 00112 virtual ~GenericMVCException() throw() 00113 { 00114 00115 } 00116 00117 } ; 00118 00119 00120 } 00121 00122 00123 } 00124 00125 00126 00127 #endif // CEYLAN_GENERIC_MVC_DEFINES_H_ 00128