00001 // OSB library ************************************************ -*- C++ -*- 00006 /* 00007 AUTHOR(S): Stephan Broennimann (vb) 00008 00009 RCS information 00010 $Name: OSB_060808 $ 00011 $Revision: 1.17.2.1 $ 00012 00013 License 00014 OSB rating and billing library for communication networks 00015 Copyright (C) 2004, 2005, 2006 OSB systems 00016 00017 This file may be distributed and/or modify under the terms of the 00018 GNU General Public License (GPL) as published by the Free Software 00019 Foundation which is provided in the file LICENSE.GPL included in the 00020 packaging of this file. 00021 00022 The file is distributed in the hope that it will be useful, but WITHOUT 00023 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00024 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00025 for more details. 00026 00027 Holders of a OSB Commercial License may use this file under the terms 00028 and conditions of this commercial license. 00029 */ 00030 #ifndef _OSBUSRGRP_H_ 00031 #define _OSBUSRGRP_H_ 00032 00033 // ************************************************************************ 00034 // included header files 00035 // + standard includes 00036 #include <string> 00037 #include <list> 00038 00039 // + libraries 00040 00041 // + local headers 00042 #include "osbaccess.h" 00043 #include "osbconst.h" 00044 #include "osbid.h" 00045 00046 // + class declarations 00047 namespace OSB_LIB { 00048 class UserMgmtCfg; 00049 } 00050 namespace OSB_DB { 00051 class UserGroupGw; 00052 class Session; 00053 }; 00054 00055 // ************************************************************************ 00056 // namespace extensions 00057 namespace OSB_LIB { 00058 00059 // ************************************************************************ 00060 // forward declarations 00061 class UserGroup; 00062 00063 // ************************************************************************ 00064 // type definitions 00065 00066 // ************************************************************************ 00067 // class definitions 00083 class UserGroup { 00085 friend class OSB_DB::UserGroupGw; 00087 friend class UserMgmtCfg; 00088 public: 00090 typedef Id<UserGroup> Oid; 00091 public: 00093 explicit UserGroup( 00094 const Oid& oid = Oid() 00095 ); 00097 explicit UserGroup( 00098 ModuleId module 00099 ); 00100 00101 public: 00103 00104 00105 const Oid oid() const; 00107 const ModuleId module() const; 00109 const std::string& name() const; 00111 const std::string& des() const; 00113 const GrpAccessMap& accessMap() const; 00115 00116 public: 00118 00119 00126 void setName(const std::string& name); 00133 void setDes(const std::string& des); 00135 00144 void read(const OSB_DB::Session& session); 00145 00146 private: 00148 00149 00158 void save( 00159 const OSB_DB::Session& session 00160 ); 00161 00172 void remove( 00173 const OSB_DB::Session& session 00174 ); 00175 00185 static void lock( 00186 const OSB_DB::Session& session, 00187 const Oid& id 00188 ); 00189 00197 void lock( 00198 const OSB_DB::Session& session 00199 ) const; 00200 00210 static void handleObjectStatus( 00211 ObjectStatus os, 00212 const Oid& id 00213 ); 00215 00216 private: 00228 void incObjVs(const OSB_DB::Session& session); 00229 00230 private: 00232 Oid oid_; 00234 ModuleId module_; 00236 std::string name_; 00238 std::string des_; 00240 long objVs_; 00242 GrpAccessMap accessMap_; 00243 }; // class UserGroup 00244 00253 class UserGroups { 00255 friend class UserMgmtCfg; 00257 friend class OSB_DB::UserGroupGw; 00258 public: 00263 typedef std::list<UserGroup> Cont; 00265 typedef Cont::const_iterator ConstIter; 00266 00267 public: 00269 bool empty() const; 00271 size_t size() const; 00273 ConstIter begin() const; 00275 ConstIter end() const; 00276 00284 const UserGroup& get(const UserGroup::Oid& grpId) const; 00285 00287 void read(const OSB_DB::Session& session); 00288 00289 private: 00297 UserGroup& get(const UserGroup::Oid& grpId); 00298 00306 void insert(const UserGroup& grp); 00307 00313 void remove(const UserGroup::Oid grpId); 00314 00316 UserGroup* find(const UserGroup::Oid& grpId); 00317 00318 private: 00320 Cont cont_; 00321 }; // class UserGroups 00322 } // namespace OSB_LIB 00323 00324 // ************************************************************************ 00325 // inline definitions 00326 namespace OSB_LIB { 00327 } // namespace OSB_LIB 00328 #endif // #ifndef _OSBUSRGRP_H_