Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

PsNullOutputCreator.h

Go to the documentation of this file.
00001 /*
00002  * This file is part of openMask © INRIA, CNRS, Universite de Rennes 1 1993-2002, thereinafter the Software
00003  * 
00004  * The Software has been developped within the Siames Project. 
00005  * INRIA, the University of Rennes 1 and CNRS jointly hold intellectual property rights
00006  * 
00007  * The Software has been registered with the Agence pour la Protection des
00008  * Programmes (APP) under registration number IDDN.FR.001.510008.00.S.P.2001.000.41200
00009  *
00010  * This file may be distributed under the terms of the Q Public License
00011  * version 1.0 as defined by Trolltech AS of Norway and appearing in the file
00012  * LICENSE.QPL included in the packaging of this file.
00013  *
00014  * Licensees holding valid specific licenses issued by INRIA, CNRS or Université de Rennes 1 
00015  * for the software may use this file in accordance with that specific license
00016  *
00017  */
00018 #ifndef PsNullOutputCreatorHEADER
00019 #define PsNullOutputCreatorHEADER
00020 
00021 class PsController ;
00022 class PsSimulatedObject ;
00023 class PsOutputNT ;
00024 template <typename Type> class PsOutput ;
00025 #include <map>
00026 
00027 class PsNullOutputCreator {
00028 public:
00029    static void setController(PsController * ) ;
00030    template <typename Type> static PsOutput<Type> * getNullOutput () ;
00031 protected:
00032    static PsController & getController() ;
00033    static PsSimulatedObject & getSimulatedObject () ;
00034    
00035    static PsController * _theController ;
00036    static PsSimulatedObject * _theEmptyObject ;
00037    static map <const char *, PsOutputNT *> _theNullOutputs ;
00038 };
00039 
00040 #include <typeinfo>
00041 #include "PsNullOutput.h"
00042 
00043 template <typename Type>
00044 PsOutput<Type> *
00045 PsNullOutputCreator::getNullOutput () 
00046 {
00047    PsOutput<Type> * result ;
00048    map <const char *, PsOutputNT *>::iterator i = _theNullOutputs.find ( typeid(Type).name() ) ;
00049    if ( i == _theNullOutputs.end() ) 
00050       {
00051          result  = new PsNullOutput<Type>( PsNullOutputCreator::getSimulatedObject() ) ;
00052          i = _theNullOutputs.insert(map <const char *, PsOutputNT *>::value_type (typeid(Type).name(), 
00053                                                                                        result ) ).first ;
00054       }
00055    else 
00056       {
00057          result = dynamic_cast <PsNullOutput<Type> *> (i->second) ;
00058          assert ( result != NULL );
00059       }
00060    return result ;
00061 }
00062 
00063 #endif

logo OpenMask

Documentation generated on Mon Nov 25 15:25:01 2002

Generated with doxygen 1.2.12 by Dimitri van Heesch ,   1997-2001