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

- Search for |

# permissions.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_SAGA_DETAIL_PERMISSIONS_HPP
    00007 #define SAGA_SAGA_DETAIL_PERMISSIONS_HPP
    00008
    00009 #include <string>
    00010
    00011 // include dependent spec sections
    00012 #include <saga/saga/util.hpp>
    00013 #include <saga/saga/base.hpp>
    00014 #include <saga/saga/monitorable.hpp>
    00015 #include <saga/saga/call.hpp>
    00016 #include <saga/saga/task.hpp>
    00017
    00018 // For symbol import/export macros
    00019 #include <saga/saga-defs.hpp>
    00020
    00021 // suppress warnings about dependent classes not being exported from the dll
    00022 #if defined(BOOST_MSVC)
    00023 #pragma warning(push)
    00024 #pragma warning(disable : 4251 4231 4660)
    00025 #endif
    00026
    00028 // for modules not belonging to the engine attributes should not be exported
    00029 #if !defined (SAGA_CREATE_PREPROCESSED_FILES) && !defined(SAGA_EXPORT_PERMISSIONS)
    00030
    00031 # if defined(SAGA_ENGINE_EXPORTS) || defined(SAGA_PERMISSIONS_EXPORTS)
    00032 #   define SAGA_EXPORT_PERMISSIONS SAGA_SYMBOL_EXPORT
    00033 # elif !defined (SAGA_NO_IMPORT_PERMISSIONS) && !defined(BUILD_SAGA_LITE)
    00034 #   define SAGA_EXPORT_PERMISSIONS SAGA_SYMBOL_IMPORT
    00035 # else
    00036 #   define SAGA_EXPORT_PERMISSIONS /* empty */
    00037 # endif
    00038
    00039 #endif // !SAGA_CREATE_PREPROCESSED_FILES
    00040
    00042 namespace saga { namespace detail
    00043 {
    00046     template <typename Derived, typename Tag>
    00047     struct SAGA_EXPORT_PERMISSIONS permissions_priv
    00048     {
    00049         static saga::task permissions_allow (Derived const& this_,
    00050             std::string id, int p);
    00051         static saga::task permissions_deny (Derived const& this_,
    00052             std::string id, int p);
    00053         static saga::task permissions_check (Derived const& this_,
    00054             std::string id, int p);
    00055
    00056         static saga::task get_owner (Derived const& this_);
    00057         static saga::task get_group (Derived const& this_);
    00058     };
    00061
    00062
    00067     template <typename Derived>
    00068     struct SAGA_EXPORT_PERMISSIONS permissions
    00069     {
    00070     private:
    00071         template <typename Tag>
    00072         saga::task permissions_allowpriv (std::string id, int p, Tag) const
    00073         { return permissions_priv<Derived, Tag>::permissions_allow(derived(), id, p); }
    00074
    00075         template <typename Tag>
    00076         saga::task permissions_denypriv (std::string id, int p, Tag) const
    00077         { return permissions_priv<Derived, Tag>::permissions_deny(derived(), id, p); }
    00078
    00079         template <typename Tag>
    00080         saga::task permissions_checkpriv (std::string id, int p, Tag) const
    00081         { return permissions_priv<Derived, Tag>::permissions_check(derived(), id, p); }
    00082
    00083         template <typename Tag>
    00084         saga::task get_ownerpriv (Tag) const
    00085         { return permissions_priv<Derived, Tag>::get_owner(derived()); }
    00086
    00087         template <typename Tag>
    00088         saga::task get_grouppriv (Tag) const
    00089         { return permissions_priv<Derived, Tag>::get_group(derived()); }
    00090
    00091     public:
    00093         impl::permissions_interface* get_perm (void);
    00094         impl::permissions_interface* get_perm (void) const;
    00096
    00097     protected:
    00099         Derived& derived()
    00100         { return static_cast<Derived&>(*this); }
    00101         Derived const& derived() const
    00102         { return static_cast<Derived const&>(*this); }
    00104     public:
    00105
    00113         void permissions_allow(std::string permission_id, int flag)
    00114         {
    00115             permissions_allowpriv (permission_id, flag,
    00116                 saga::task_base::Sync());
    00117         }
    00119         SAGA_CALL_PUB_2_DEF_0(permissions_allow, std::string, int)
    00121
    00122
    00129         void permissions_deny(std::string permission_id, int flag)
    00130         {
    00131             permissions_denypriv (permission_id, flag,
    00132                 saga::task_base::Sync());
    00133         }
    00135         SAGA_CALL_PUB_2_DEF_0(permissions_deny, std::string, int)
    00137
    00138
    00145         bool permissions_check(std::string permission_id, int flag) const
    00146         {
    00147             saga::task t = permissions_checkpriv (permission_id, flag,
    00148                 saga::task_base::Sync());
    00149             return t.get_result<bool>();
    00150         }
    00152         SAGA_CALL_CONST_PUB_2_DEF_0(permissions_check, std::string, int)
    00154
    00155
    00161         std::string get_owner() const
    00162         {
    00163             saga::task t = get_ownerpriv (saga::task_base::Sync());
    00164             return t.get_result<std::string>();
    00165         }
    00167         SAGA_CALL_CONST_PUB_0_DEF_0(get_owner)
    00169
    00170
    00176         std::string get_group() const
    00177         {
    00178             saga::task t = get_grouppriv (saga::task_base::Sync());
    00179             return t.get_result<std::string>();
    00180         }
    00182         SAGA_CALL_CONST_PUB_0_DEF_0(get_group)
    00184     };
    00185
    00187 }}
    00188
    00189 #endif
    00190
    00191