ESA JPIP server  0.1
app_config.h
Go to the documentation of this file.
1 #ifndef _APP_CONFIG_H_
2 #define _APP_CONFIG_H_
3 
4 
5 #include <string>
6 #include <iostream>
7 
8 
9 using namespace std;
10 
11 
18 class AppConfig
19 {
20 private:
21  int port_;
22  int logging_;
24  string address_;
25  string images_folder_;
26  string caching_folder_;
27  string logging_folder_;
32 
33 public:
38  {
39  port_ = 0;
40  logging_ = 0;
41  address_ = "";
42  log_requests_ = 0;
43  images_folder_ = "";
44  caching_folder_ = "";
45  logging_folder_ = "";
46  max_chunk_size_ = 0;
47  max_connections_ = 0;
48  cache_max_time_ = 0;
49  com_time_out_ = -1;
50  }
51 
57  bool Load(const char *file_name);
58 
59  friend ostream& operator <<(ostream &out, const AppConfig &cfg)
60  {
61  out << "Configuration:" << endl;
62  out << "\tListen at: " << cfg.address_ << ":" << cfg.port_ << endl;
63  out << "\tFolders:" << endl;
64  out << "\t\tImages: " << cfg.images_folder_ << endl;
65  out << "\t\tCaching: " << cfg.caching_folder_ << endl;
66  out << "\t\tLogging: " << cfg.logging_folder_ << endl;
67  out << "\tConnections: " << endl;
68  out << "\t\tMax. number: " << cfg.max_connections_ << endl;
69  out << "\t\tMax. time-out: " << cfg.com_time_out() << endl;
70  out << "\tGeneral:" << endl;
71  out << "\t\tLogging: " << (cfg.logging_ == 1 ? "yes" : "no") << endl;
72  out << "\t\tLog. requests: " << (cfg.log_requests_ == 1 ? "yes" : "no") << endl;
73  out << "\t\tChunk max. size: "<< cfg.max_chunk_size_ << endl;
74  return out;
75  }
76 
80  int port() const
81  {
82  return port_;
83  }
84 
88  string address() const
89  {
90  return address_;
91  }
92 
96  string images_folder() const
97  {
98  return images_folder_;
99  }
100 
104  string caching_folder() const
105  {
106  return caching_folder_;
107  }
108 
112  string logging_folder() const
113  {
114  return logging_folder_;
115  }
116 
120  int max_chunk_size() const
121  {
122  return max_chunk_size_;
123  }
124 
128  int max_connections() const
129  {
130  return max_connections_;
131  }
132 
136  bool logging() const
137  {
138  return (logging_ == 1);
139  }
140 
144  bool log_requests() const
145  {
146  return (log_requests_ == 1);
147  }
148 
152  int com_time_out() const
153  {
154  return com_time_out_;
155  }
156 
161  int cache_max_time() const
162  {
163  return cache_max_time_;
164  }
165 
166  virtual ~AppConfig()
167  {
168  }
169 };
170 
171 #endif /* _APP_CONFIG_H_ */
string images_folder() const
Returns the folder of the images.
Definition: app_config.h:96
int max_chunk_size_
Maximum chunk size.
Definition: app_config.h:28
int com_time_out() const
Returns the connection time-out.
Definition: app_config.h:152
string caching_folder() const
Returns the folder used for caching.
Definition: app_config.h:104
virtual ~AppConfig()
Definition: app_config.h:166
AppConfig()
Initializes the object with zero and empty values.
Definition: app_config.h:37
int logging_
true if logs messages are allowed
Definition: app_config.h:22
int cache_max_time() const
Returns the maximum time for the cache files in seconds.
Definition: app_config.h:161
Contains the configuration parameters of the application.
Definition: app_config.h:18
int max_chunk_size() const
Returns the maximum chunk size.
Definition: app_config.h:120
int cache_max_time_
Maximum time for the cache files.
Definition: app_config.h:31
string address() const
Returns the listening address.
Definition: app_config.h:88
AppConfig cfg
Definition: esa_jpip_server.cc:38
string caching_folder_
Directory for the caching files.
Definition: app_config.h:26
string logging_folder_
Directory for the logging files.
Definition: app_config.h:27
bool log_requests() const
Returns true if the client requests are logged.
Definition: app_config.h:144
bool logging() const
Returns true if the logging messages are allowed.
Definition: app_config.h:136
int port() const
Returns the listening port.
Definition: app_config.h:80
string address_
Listening address.
Definition: app_config.h:24
int max_connections() const
Returns the maximum number of connections.
Definition: app_config.h:128
int com_time_out_
Connection time-out.
Definition: app_config.h:30
string images_folder_
Directory for the images.
Definition: app_config.h:25
int log_requests_
true if the client requests are logged
Definition: app_config.h:23
int port_
Listening port.
Definition: app_config.h:21
int max_connections_
Maximum number of connections.
Definition: app_config.h:29
ostream & operator<<(ostream &out, const Request &request)
Definition: request.cc:65
string logging_folder() const
Returns the folder used for the logging files.
Definition: app_config.h:112