OMKExtensionManager.h

Go to the documentation of this file.
00001 
00002 /************************************************************************/
00003 /* This file is part of openMask(c) INRIA, CNRS, Universite de Rennes 1 */
00004 /* 1993-2007, thereinafter the Software                                 */
00005 /*                                                                      */
00006 /* The Software has been developped within the Siames Project.          */
00007 /* INRIA, the University of Rennes 1 and CNRS jointly hold intellectual */
00008 /* property rights                                                      */
00009 /*                                                                      */
00010 /* The Software has been registered with the Agence pour la Protection  */
00011 /* des Programmes (APP) under registration number                       */
00012 /* IDDN.FR.001.510008.00.S.P.2001.000.41200                             */
00013 /*                                                                      */
00014 /* This file may be distributed under the terms of the Q Public License */
00015 /* version 1.0 as defined by Trolltech AS of Norway and appearing in    */
00016 /* the file LICENSE.QPL included in the packaging of this file.         */
00017 /*                                                                      */
00018 /* Licensees holding valid specific licenses issued by INRIA, CNRS or   */
00019 /* Universite Rennes 1 for the software may use this file in            */
00020 /* acordance with that specific license                                 */
00021 /************************************************************************/
00022                 
00023 #if !defined OMK_EXTENSIONMANAGER_H
00024 #define OMK_EXTENSIONMANAGER_H
00025 
00026 #include "OMKSimulatedObject.h"
00027 #include "OMKExtension.h"
00028 
00029 namespace OMK  
00030 {
00031 
00043 class OMK_API ExtensionManager
00044 {
00045 public:
00047 
00048 
00049   ExtensionManager() ;
00052   virtual ~ExtensionManager() ;
00054 
00057 
00058 public:
00062   typedef std::pair< Name, Name > CreateAndAddExtensionPrm ;
00064   DECLARE_TYPE_EVENT( CreateAndAddExtensionPrm, CreateAndAddExtension ) ;
00066   typedef std::map< Name, Extension* > ExtensionStore ;
00068   typedef std::list< Extension* > ExtensionList ;
00076   Extension* createAndAddExtension( ExtensibleSimulatedObject* owner, const Name& classId, const Name& id ) ;
00080   void createExtensionsFromParameters( ExtensibleSimulatedObject* owner, const ConfigurationParameterDescriptor * node ) ;
00085   void deleteExtensions() ;
00088   void preComputeExtension() ;
00091   void postComputeExtension() ;
00131   bool loadFromExtensionsParameters( const ConfigurationParameterDescriptor* extensionNode ) ;
00132   bool loadFromObjectParameters( const ConfigurationParameterDescriptor* node ) ;
00138   void loadOrder( const ConfigurationParameterDescriptor* node,
00139                   const std::string& name,
00140                   ExtensionList& extensionsList ) ;
00148   void addExtension( Extension* extension ) ;
00153   Extension* removeExtension( const Name& id ) ;
00156   void removeAndDeleteExtension( const Name& id ) { delete removeExtension( id ) ; }
00159   Extension* getExtension( const Name& id ) ;
00164   template< typename Type > 
00165   Type* getExtensionT( const Name& id ) ;
00167 
00170   ExtensionStore _extensions ;
00173   ExtensionList _orderedExtensionsForLoadParameters ;
00175   ExtensionList _orderedExtensionsForPreCompute ;
00177   ExtensionList _orderedExtensionsForPostCompute ;
00178 } ;
00179 //-----------------------------------------------------------------------------
00180 template< typename Type > 
00181 Type* ExtensionManager::getExtensionT( const Name& id ) 
00182 { 
00183   // look for the extension
00184   Extension* extension = getExtension( id ) ;
00185   // cast it
00186   Type* extensionT = dynamic_cast< Type* >( extension ) ;
00187   if( extension && !extensionT ) 
00188   { 
00189     // Unable to cast <=> wrong type
00190     OMTRACEID( OMK_DEBUG_OMK_EXT, 
00191       "Unable to convert the extension" << std::endl
00192       << ">>> :-( The extension \"" << id.getString() << "\" is not of the type \"" << typeid( Type ).name() << "\"" << std::endl ) ; 
00193   }
00194   // and return id
00195   return extensionT ;
00196 }
00197 
00198 }// namespace OMK
00199 
00200 #endif // defined OMK_EXTENSIONMANAGER_H

logo OpenMask

Documentation generated on Mon Jun 9 11:45:56 2008

Generated with doxygen by Dimitri van Heesch ,   1997-2007