pion-net  4.0.9
PionAdminRights.hpp
1 // -----------------------------------------------------------------------
2 // pion-common: a collection of common libraries used by the Pion Platform
3 // -----------------------------------------------------------------------
4 // Copyright (C) 2007-2008 Atomic Labs, Inc. (http://www.atomiclabs.com)
5 //
6 // Distributed under the Boost Software License, Version 1.0.
7 // See http://www.boost.org/LICENSE_1_0.txt
8 //
9 
10 #ifndef __PION_PIONADMINRIGHTS_HEADER__
11 #define __PION_PIONADMINRIGHTS_HEADER__
12 
13 #include <pion/PionConfig.hpp>
14 #include <pion/PionLogger.hpp>
15 #include <boost/cstdint.hpp>
16 #include <boost/thread/mutex.hpp>
17 
18 
19 namespace pion { // begin namespace pion
20 
21 
25 class PION_COMMON_API PionAdminRights {
26 public:
27 
34  PionAdminRights(bool use_log = true);
35 
37  virtual ~PionAdminRights() { release(); }
38 
40  void release(void);
41 
42 
43 private:
44 
46  static const boost::int16_t ADMIN_USER_ID;
47 
49  static boost::mutex m_mutex;
50 
52  PionLogger m_logger;
53 
55  boost::unique_lock<boost::mutex> m_lock;
56 
58  boost::int16_t m_user_id;
59 
61  bool m_has_rights;
62 
64  bool m_use_log;
65 };
66 
67 
68 } // end namespace pion
69 
70 #endif
71 
virtual ~PionAdminRights()
destructor releases administrative rights