| TerraLib 4.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Examples

- File List
- File Members

E:/Projetos_Primeiro_Semestre_2012/TerraView/terralib/src/terralib/kernel/TePrototype.h
Go to the documentation of this file.

    00001 /************************************************************************************
    00002 TerraLib - a library for developing GIS applications.
    00003 Copyright © 2001-2007 INPE and Tecgraf/PUC-Rio.
    00004
    00005 This code is part of the TerraLib library.
    00006 This library is free software; you can redistribute it and/or
    00007 modify it under the terms of the GNU Lesser General Public
    00008 License as published by the Free Software Foundation; either
    00009 version 2.1 of the License, or (at your option) any later version.
    00010
    00011 You should have received a copy of the GNU Lesser General Public
    00012 License along with this library.
    00013
    00014 The authors reassure the license terms regarding the warranties.
    00015 They specifically disclaim any warranties, including, but not limited to,
    00016 the implied warranties of merchantability and fitness for a particular purpose.
    00017 The library provided hereunder is on an "as is" basis, and the authors have no
    00018 obligation to provide maintenance, support, updates, enhancements, or modifications.
    00019 In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
    00020 indirect, special, incidental, or consequential damages arising out of the use
    00021 of this library and its documentation.
    00022 *************************************************************************************/
    00026 #ifndef TePrototype_H
    00027 #define TePrototype_H
    00028
    00029 /*
    00030            See the book "Design Patterns - Elements of Reusable Object-Oriented Software", by Gamma et. al.
    00031            for further documentation.
    00032 */
    00033
    00034 #include "TeDefines.h"
    00035
    00036 template <class T>
    00037 class TePrototype
    00038 {
    00039 public:
    00040
    00042            typedef  TePrototype<T>* TePrototypePtr;
    00043
    00044 // -- Normal Constructor
    00045
    00047            TePrototype ();
    00048
    00050            virtual ~TePrototype() {}
    00051
    00053            static T* clone ();
    00054
    00056     virtual T* build () = 0;
    00057
    00058 private:
    00059            static TePrototypePtr instance_;
    00060 };
    00061
    00062 // Initialisation of static variable
    00063 template <class T>
    00064 typename TePrototype<T>::TePrototypePtr TePrototype<T>::instance_;
    00065
    00066 // Constructor
    00067 template <class T>
    00068 TePrototype<T>::TePrototype()
    00069 {
    00070            // Put the object in the factory dictionary
    00071            instance_ = this;
    00072 }
    00073
    00074 // Virtual Constructor
    00075 template <class T>
    00076 T*
    00077 TePrototype<T>::clone ()
    00078 {
    00079            return instance_->build();
    00080 }
    00081
    00082 #endif
    00083

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines