OMKIAccessRule.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-2002, 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_III_IACCESSRULE_H
00024 #define OMK_III_IACCESSRULE_H
00025 
00026 #include "OMKInteraction.h"
00027 #include "OMKName.h"
00028 #include "OBTPrototypeFactory.h"
00029 #include "OMKTracer.h"
00030 #include "OMKControlTakeOverPrm.h"
00031 #include "OMKParametersAccessor.inl"
00032 #include <iostream>
00033 
00034 namespace OMK  
00035 {
00036   namespace Iii
00037   {
00038 //-----------------------------------------------------------------------------
00039 #define DECLARE_ACCESS_RULE_FACTORY( AccessRuleClass ) \
00040 public: \
00041  \
00042   friend class OMK::Iii::AccessRuleCreatorT< AccessRuleClass > ; \
00043  \
00044   static OMK::Name OMK_CLASS_ID ; \
00045  \
00046   static const bool REGISTERED_IN_ACCESS_RULE_FACTORY ; \
00047 protected: \
00048  \
00050         AccessRuleClass( const OMK::ConfigurationParameterDescriptor* node ) ; \
00051 public: \
00052         virtual ~AccessRuleClass() 
00053 
00054 //-----------------------------------------------------------------------------
00055 #define REGISTER_ACCESS_RULE_FACTORY( AccessRuleClass, Id )\
00056   /* Factory */ \
00057   OMK::Name AccessRuleClass::OMK_CLASS_ID( Id ) ; \
00058   const bool AccessRuleClass::REGISTERED_IN_ACCESS_RULE_FACTORY( OMK::AccessRuleFactory::getInstance().registerCreator< OMK::Iii::AccessRuleCreatorT< AccessRuleClass > > ( AccessRuleClass::OMK_CLASS_ID ) )
00059 
00060 
00061 //-----------------------------------------------------------------------------
00068 class IAccessRule 
00069 {
00070 public:
00071   enum FreezableType
00072   {
00073     UNFREEZABLE,
00074     FREEZABLE_AT_TOOL_LEVEL,
00075     FREEZABLE_AT_ANY_LEVEL
00076   } ;
00077 protected:
00078   IAccessRule( const ConfigurationParameterDescriptor* node ) ;
00079 public:
00080   virtual ~IAccessRule() ;
00081   virtual Type::AccessLevel getAccessLevel( const Name& groupName ) const ;
00082   virtual const Type::AccessGroupLevel& getCurrentAccessLevel() const { return _currentLevel ; }
00083   virtual const Type::AccessGroupLevel& getDefaultAccessLevel() const { return _defaultLevel ; }
00084   virtual void setCurrentLevel( const Type::AccessGroupLevel& level, Type::AccessLevel toolLevel ) = 0 ;
00085   virtual void resetCurrentLevel() ;
00086   virtual bool isAccessGranted( Type::AccessLevel level, const Name& group ) const ;
00087 protected:
00088   Type::AccessGroupLevel _defaultLevel ;
00089   Type::AccessGroupLevel _currentLevel ;
00090   Type::AccessLevel _freezableLevel ;
00091   FreezableType _freezableType ;
00092 } ;
00093 
00094 //-----------------------------------------------------------------------------
00102 class OMKIII_API AccessRuleCreator
00103 {
00104 public:
00105   virtual ~AccessRuleCreator() {}
00106   virtual IAccessRule* operator()( const ConfigurationParameterDescriptor* node ) const
00107   {
00108     OMERROR( "Creator is not registered" ) ;
00109     throw Exception( "Creator is not registered" ) ;
00110     return 0 ;
00111   }
00112 } ;
00113 
00114 //-----------------------------------------------------------------------------
00120 template <class T>
00121 class AccessRuleCreatorT : public AccessRuleCreator
00122 {
00123 public:
00124         IAccessRule* operator()( const ConfigurationParameterDescriptor* node ) const
00125         {
00126                 return new T( node ) ;
00127         }
00128 } ;
00129 
00130 
00131 
00132   }// namespace Iii
00133 
00134 //-----------------------------------------------------------------------------
00159 typedef OBT::Singleton< OBT::PrototypeFactory< OMK::Name, Iii::AccessRuleCreator > > AccessRuleFactory ;
00160 }// namespace OMK
00161 
00162 template class OMKIII_API OBT::PrototypeFactory< OMK::Name, OMK::Iii::AccessRuleCreator > ;
00163 template class OMKIII_API OBT::Singleton< OBT::PrototypeFactory< OMK::Name, OMK::Iii::AccessRuleCreator > > ;
00164 
00165 #endif // defined OMK_III_IACCESSRULE_H

logo OpenMask

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

Generated with doxygen by Dimitri van Heesch ,   1997-2007