SAGA Adaptor CPI v.1.0
permissions_cpi.hpp
Go to the documentation of this file.
00001 //  Copyright (c) 2005-2009 Hartmut Kaiser
00002 // 
00003 //  Distributed under the Boost Software License, Version 1.0. (See accompanying 
00004 //  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
00005 
00006 #ifndef SAGA_IMPL_ENGINE_PERMISSIONS_CPI_HPP
00007 #define SAGA_IMPL_ENGINE_PERMISSIONS_CPI_HPP
00008 
00009 #include <string>
00010 
00011 #include <saga/saga/util.hpp>
00012 #include <saga/saga/types.hpp>
00013 #include <saga/saga/exception.hpp>
00014 
00015 #include <saga/impl/call.hpp>
00016 #include <saga/impl/config.hpp>
00017 #include <saga/impl/engine/cpi.hpp>
00018 #include <saga/impl/engine/register_members.hpp>
00019 #include <saga/saga/adaptors/attribute_cpi.hpp>
00020 
00022 namespace saga { namespace impl { namespace v1_0 {
00023 
00025     class permissions_cpi : public attribute_cpi
00026     {
00027     protected:
00028         typedef saga::impl::proxy proxy;
00029         typedef saga::impl::v1_0::cpi cpi;
00030         typedef saga::impl::v1_0::cpi_info cpi_info;
00031         typedef saga::impl::v1_0::preference_type preference_type;
00032 
00033     public:
00034         permissions_cpi(proxy* p, cpi_info const& info, 
00035                 TR1::shared_ptr<saga::adaptor> adaptor, cpi::flags flags) 
00036             : attribute_cpi (p, info, adaptor, flags) 
00037         { 
00038         }
00039          
00040         ~permissions_cpi(void) 
00041         {
00042         }
00043 
00044         SAGA_CALL_CPI_DECL_VIRT_2(permissions_cpi, saga::impl::void_t, permissions_allow, std::string, int)
00045         SAGA_CALL_CPI_DECL_VIRT_2(permissions_cpi, saga::impl::void_t, permissions_deny, std::string, int)
00046         SAGA_CALL_CPI_DECL_VIRT_2(permissions_cpi, bool, permissions_check, std::string, int)
00047         SAGA_CALL_CPI_DECL_VIRT_0(permissions_cpi, std::string, get_owner)
00048         SAGA_CALL_CPI_DECL_VIRT_0(permissions_cpi, std::string, get_group)
00049 
00050     }; // class permissions_cpi
00051 
00053 }}} // namespace saga::impl::v1_0
00054 
00056 namespace saga { namespace adaptors { namespace v1_0 {
00057 
00059 // register permissions CPI functions
00060     template <typename Derived>
00061     inline bool
00062     register_permissions_functions(
00063         std::vector<saga::impl::v1_0::cpi_info>& infos, 
00064         saga::impl::v1_0::cpi::maker_type maker, 
00065         saga::impl::v1_0::preference_type const& prefs, 
00066         saga::uuid const& cpi_uuid, saga::uuid const& adaptor_uuid, 
00067         std::string const& cpi_name)
00068     {
00069         bool retval = false;
00070         saga::impl::v1_0::cpi_info info(saga::adaptors::permissions_cpi,
00071             cpi_name, maker, prefs, cpi_uuid, adaptor_uuid);
00072           
00073         SAGA_LOG(SAGA_VERBOSE_LEVEL_BLURB)
00074             << "begin register_permissions_functions: " 
00075             << adaptor_uuid.string() << ":";
00076 
00077         typedef saga::impl::v1_0::permissions_cpi base_cpi;
00078 
00079         typedef void (base_cpi::*base_sync_permissions_allow_type)(saga::impl::void_t&, std::string, int);
00080         typedef saga::task (base_cpi::*base_async_permissions_allow_type)(std::string, int);
00081         typedef void (Derived::*sync_permissions_allow_type)(saga::impl::void_t&, std::string, int);
00082         typedef saga::task (Derived::*async_permissions_allow_type)(std::string, int);
00083 
00084         SAGA_REGISTER_MEMBER_EX(retval, info, base_cpi, Derived, permissions_allow, prefs,
00085             base_sync_permissions_allow_type, base_async_permissions_allow_type,
00086             sync_permissions_allow_type, async_permissions_allow_type);
00087 
00088         typedef void (base_cpi::*base_sync_permissions_deny_type)(saga::impl::void_t&, std::string, int);
00089         typedef saga::task (base_cpi::*base_async_permissions_deny_type)(std::string, int);
00090         typedef void (Derived::*sync_permissions_deny_type)(saga::impl::void_t&, std::string, int);
00091         typedef saga::task (Derived::*async_permissions_deny_type)(std::string, int);
00092 
00093         SAGA_REGISTER_MEMBER_EX(retval, info, base_cpi, Derived, permissions_deny, prefs,
00094             base_sync_permissions_deny_type, base_async_permissions_deny_type,
00095             sync_permissions_deny_type, async_permissions_deny_type);
00096 
00097         SAGA_REGISTER_MEMBER(retval, info, base_cpi, Derived, permissions_check, prefs);
00098         SAGA_REGISTER_MEMBER(retval, info, base_cpi, Derived, get_owner, prefs);
00099         SAGA_REGISTER_MEMBER(retval, info, base_cpi, Derived, get_group, prefs);
00100 
00101         infos.push_back(info);
00102 
00103         SAGA_LOG(SAGA_VERBOSE_LEVEL_BLURB)
00104             << "end register_permissions_functions";
00105 
00106         return retval;    // is true if at least one function got registered
00107     }
00108 
00110     template <typename Derived>
00111     class permissions_cpi 
00112       : public saga::impl::v1_0::permissions_cpi
00113     {
00114     protected:
00115         typedef saga::impl::proxy proxy;
00116         typedef saga::impl::v1_0::cpi cpi;
00117         typedef saga::impl::v1_0::cpi_info cpi_info;
00118         typedef saga::impl::v1_0::preference_type preference_type;
00119         typedef saga::impl::v1_0::permissions_cpi base_type;
00120         
00121     public:
00122         permissions_cpi (proxy* p, cpi_info const& info, 
00123               TR1::shared_ptr<saga::adaptor> adaptor, cpi::flags flags) 
00124             : base_type(p, info, adaptor, flags) 
00125         { 
00126         }
00127          
00128         ~permissions_cpi (void) 
00129         {
00130         }
00131 
00133         // generic factory function
00134         static cpi* cpi_maker (proxy* p, cpi_info const& info,
00135             saga::ini::ini const& glob_ini, saga::ini::ini const& adap_ini,
00136             TR1::shared_ptr<saga::adaptor> adaptor)
00137         {
00138             return new Derived (p, info, glob_ini, adap_ini, adaptor);
00139         }
00140 
00142         // register implemented functions
00143         static void 
00144         register_cpi(std::vector<cpi_info>& infos, preference_type prefs, 
00145             saga::uuid adaptor_uuid)
00146         {
00147             // register attribute CPI functions
00148             saga::uuid cpi_uuid;
00149             register_permissions_functions<Derived>(infos, 
00150                 &saga::adaptors::v1_0::permissions_cpi<Derived>::cpi_maker, 
00151                 prefs, cpi_uuid, adaptor_uuid, saga::adaptors::permissions_cpi);
00152         }
00153 
00155         // generic up-cast of the impl pointer       
00156         TR1::shared_ptr<Derived> shared_from_this()
00157         {
00158             return TR1::static_pointer_cast<Derived>(
00159                 this->base_type::shared_from_this());
00160         }
00161 
00162     }; // class permissions_cpi
00163 
00165 }}}   // namespace saga::adaptors::v1_0
00166 
00167 #endif 
00168 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines