nis-util  1.0.D108
lib/space/automap.h
Go to the documentation of this file.
00001 //
00002 // nis-util - NIS Administration Utilities
00003 // Copyright (C) 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 along
00016 // with this program. If not, see <http://www.gnu.org/licenses/>.
00017 //
00018 
00019 #ifndef LIB_SPACE_AUTOMAP_H
00020 #define LIB_SPACE_AUTOMAP_H
00021 
00022 #include <boost/shared_ptr.hpp>
00023 #include <list>
00024 #include <map>
00025 
00026 #include <lib/space.h>
00027 #include <lib/space/automap/functor.h>
00028 #include <lib/space/automap/row.h>
00029 
00030 class space_hosts_slurp; // forward
00031 
00036 class space_automap:
00037     public space
00038 {
00039 public:
00040     typedef boost::shared_ptr<space_automap> pointer;
00041 
00045     virtual ~space_automap();
00046 
00051     static pointer create(const rcstring &filename);
00052 
00057     void read_and_process(void);
00058 
00064     void read_and_process(space_automap_functor &func,
00065         const space_hosts_slurp *hosts);
00066 
00071     void insert(const space_automap_row::pointer &rp);
00072 
00077     void insert_sub(const space_automap_row::pointer &rp);
00078 
00086     void walk(space_automap_functor &func);
00087 
00097     space_automap_row::pointer query(const rcstring &key) const;
00098 
00109     space_automap_row::pointer query_sub(const rcstring &key) const;
00110 
00111     typedef std::list<mount_point> keys_t;
00112 
00117     keys_t get_keys(void) const;
00118 
00123     void print(void) const;
00124 
00132     void print(const rcstring &filename) const;
00133 
00139     int yak_lex(void);
00140 
00145     bool empty(void) const;
00146 
00151     static void grammar_debug(void);
00152 
00153 private:
00158     space_automap(const rcstring &filename);
00159 
00160     typedef std::map<rcstring, space_automap_row::pointer> content_t;
00161 
00162     void parse(space_automap_functor &saver, const space_hosts_slurp *hosts);
00163 
00168     content_t content;
00169 
00175     content_t content_sub;
00176 
00181     space_automap();
00182 
00190     space_automap(const space_automap &rhs);
00191 
00199     space_automap &operator=(const space_automap &rhs);
00200 };
00201 
00202 // vim: set ts=8 sw=4 et :
00203 #endif // LIB_SPACE_AUTOMAP_H