00001 #ifndef SERVER_H
00002 #define SERVER_H
00003
00004 #include <string>
00005 #include <stdexcept>
00006 #include <iostream>
00007
00008 #include "index.h"
00009
00016 class Server {
00017 public:
00034 Server(const string& config_fn) throw (runtime_error);
00035 ~Server();
00036
00047 bool ok_to_index(const string& path, ostream& err) const;
00052 bool serve(iostream& ios);
00053
00054 const string& config_fn() const { return config_fn_; }
00055 const string& index_fn() const { return index_fn_; }
00056 const string& ignore_fn() const { return ignore_fn_; }
00057 const string& log_fn() const { return log_fn_; }
00058 const int port() const { return port_; }
00059 const string::size_type wordlength() const { return wordlength_; }
00060 const string::size_type max_cmd() const { return max_cmd_; }
00061 const string error() const { return "ERROR "; }
00062 const string ok() const { return "OK"; }
00063 ostream& log() const { return *log_; }
00064 const Index& index() const { return *index_; }
00065 Index& index() { return *index_; }
00066
00067 private:
00068 string config_fn_;
00069 string index_fn_;
00070 string ignore_fn_;
00071 string log_fn_;
00072 int port_;
00073 string::size_type wordlength_;
00074 string::size_type max_cmd_;
00075
00076 ostream* log_;
00077 Index* index_;
00078 };
00079 #endif
00080