Skip to content
database.hh 1.29 KiB
Newer Older
Seblu's avatar
Seblu committed
/*
  This file is part of SLS.
Seblu's avatar
Seblu committed
  Copyright (C) 2008 Sebastien LUTTRINGER <contact@seblu.net>
Seblu's avatar
Seblu committed

Seblu's avatar
Seblu committed
  SLS is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
Seblu's avatar
Seblu committed
  the Free Software Foundation; version 2 of the License.
Seblu's avatar
Seblu committed

Seblu's avatar
Seblu committed
  SLS is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.
Seblu's avatar
Seblu committed

Seblu's avatar
Seblu committed
  You should have received a copy of the GNU General Public License
  along with SLS; if not, write to the Free Software
Seblu's avatar
Seblu committed
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
Seblu's avatar
Seblu committed
*/
Seblu's avatar
Seblu committed

Seblu's avatar
Seblu committed
#ifndef DATABASE_HH
# define DATABASE_HH
Seblu's avatar
Seblu committed

Seblu's avatar
Seblu committed
# include <sqlite3.h>
# include "sls.hh"
Seblu's avatar
Seblu committed

// Data container

class Database {
Seblu's avatar
Seblu committed
public:
  Database();

  void open(const string &path);
  void close();

protected:
  void load_hosts_();
  void load_groups_();
  void load_users_();
  void load_scripts_();
  void load_aliases_();

  void save_hosts_();
  void save_groups_();
  void save_users_();
  void save_scripts_();
  void save_aliases_();

  void exec(const string &sql);

private:
  sqlite3 *db_;

  Hosts hosts_;
  Groups groups_;
  Users users_;
  Scripts scripts_;
  Aliases aliases_;
Seblu's avatar
Seblu committed
};

#endif