nis-util  1.0.D108
lib/colon/group.h
Go to the documentation of this file.
00001 //
00002 // nis-util - NIS Administration Utilities
00003 // Copyright (C) 2001, 2008, 2009, 2011, 2012 Peter Miller
00004 //
00005 // This program is free software; you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation; either version 2 of the License, or (at
00008 // your option) any later version.
00009 //
00010 // This program is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 // General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with this program. If not, see <http://www.gnu.org/licenses/>.
00017 //
00018 
00019 #ifndef LIB_COLON_GROUP_H
00020 #define LIB_COLON_GROUP_H
00021 
00022 #include <boost/shared_ptr.hpp>
00023 
00024 #include <lib/colon.h>
00025 
00030 class colon_group:
00031     public colon
00032 {
00033 public:
00034     typedef boost::shared_ptr<colon_group> pointer;
00035 
00039     virtual ~colon_group();
00040 
00048     static pointer create(const rcstring &filename);
00049 
00054     class record
00055     {
00056     public:
00057         typedef boost::shared_ptr<record> pointer;
00058 
00062         ~record();
00063 
00064         typedef std::vector<rcstring> members_t;
00065 
00081         static pointer create(const source_location &locn,
00082             const rcstring &name, const rcstring &password, const rcstring &gid,
00083             const members_t &members);
00084 
00085         const source_location &get_source_location(void) const { return locn; }
00086         rcstring get_name(void) const { return name; }
00087         rcstring get_password(void) const { return password; }
00088         rcstring get_gid(void) const { return gid; }
00089         long get_gid_binary(void) const;
00090         const members_t &get_members(void) const { return members; }
00091 
00092         rcstring get_use_instead(void) const { return use_instead; }
00093         bool is_members_only(void) const { return members_only; }
00094 
00101         rcstring representation(void) const;
00102 
00107         void append_member(const rcstring &user_name);
00108 
00113         bool is_member(const rcstring &user_name) const;
00114 
00115     private:
00131         record(const source_location &locn, const rcstring &name,
00132             const rcstring &password, const rcstring &gid,
00133             const members_t &members);
00134 
00139         source_location locn;
00140 
00145         rcstring name;
00146 
00151         rcstring password;
00152 
00157         rcstring gid;
00158 
00163         members_t members;
00164 
00170         rcstring use_instead;
00171 
00177         bool members_only;
00178     };
00179 
00191     record::pointer get(void);
00192 
00193 protected:
00200     colon_group(const rcstring &filename);
00201 
00202 private:
00214     bool validate(const record::pointer &rp);
00215 
00221     long last_gid;
00222 
00226     colon_group();
00227 
00231     colon_group(const colon_group &rhs);
00232 
00236     colon_group &operator=(const colon_group &rhs);
00237 };
00238 
00239 // vim: set ts=8 sw=4 et :
00240 #endif // LIB_COLON_GROUP_H