STK++ 1.0
STK_IRecursiveTemplate.h
Go to the documentation of this file.
00001 /*--------------------------------------------------------------------*/
00002 /*     Copyright (C) 2004-2011  Serge Iovleff
00003 
00004  This program is free software; you can redistribute it and/or modify
00005  it under the terms of the GNU Lesser General Public License as
00006  published by the Free Software Foundation; either version 2 of the
00007  License, or (at your option) any later version.
00008 
00009  This program is distributed in the hope that it will be useful,
00010  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  GNU Lesser General Public License for more details.
00013 
00014  You should have received a copy of the GNU Lesser General Public
00015  License along with this program; if not, write to the
00016  Free Software Foundation, Inc.,
00017  59 Temple Place,
00018  Suite 330,
00019  Boston, MA 02111-1307
00020  USA
00021 
00022  Contact : Serge.Iovleff@stkpp.org
00023  */
00024 
00025 /*
00026  * Project:  stkpp::Sdk
00027  * created on: 7 août 2011
00028  * Purpose:  Create an interface base class for class using the Recursive
00029  * template paradigm.
00030  * Author:   iovleff, serge.iovleff@stkpp.org
00031  *
00032  **/
00033 
00038 #ifndef STK_IRECURSIVETEMPLATE_H
00039 #define STK_IRECURSIVETEMPLATE_H
00040 
00041 namespace STK
00042 {
00043 
00054 template<class Leaf>
00055 class IRecursiveTemplate
00056 {
00057   public:
00059     IRecursiveTemplate() {;}
00060 
00062     IRecursiveTemplate(IRecursiveTemplate const& leaf) { ;}
00063 
00065     virtual ~IRecursiveTemplate() {;}
00066 
00072     inline Leaf& asLeaf()
00073     { return static_cast<Leaf&>(*this); }
00074 
00080     inline Leaf const& asLeaf() const
00081     { return static_cast<Leaf const&>(*this); }
00082 
00088     inline Leaf* asPtrLeaf()
00089     { return static_cast<Leaf*>(this); }
00090 
00096     inline Leaf const* asPtrLeaf() const
00097     { return static_cast<Leaf const*>(this); }
00098 
00102     inline Leaf* clone() const
00103     { return new Leaf(this->asLeaf());}
00104 };
00105 
00106 } // namespace STK
00107 
00108 #endif /* STK_IRECURSIVETEMPLATE_H */