configurator.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008 Tommi Maekitalo
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * As a special exception, you may use this file as part of a free
10  * software library without restriction. Specifically, if other files
11  * instantiate templates or use macros or inline functions from this
12  * file, or you compile this file and link it with other files to
13  * produce an executable, this file does not by itself cause the
14  * resulting executable to be covered by the GNU General Public
15  * License. This exception does not however invalidate any other
16  * reasons why the executable file might be covered by the GNU Library
17  * General Public License.
18  *
19  * This library is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22  * Lesser General Public License for more details.
23  *
24  * You should have received a copy of the GNU Lesser General Public
25  * License along with this library; if not, write to the Free Software
26  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
27  */
28 
29 #ifndef TNT_CONFIGURATOR_H
30 #define TNT_CONFIGURATOR_H
31 
32 #include <tnt/tntnet.h>
33 #include <tnt/worker.h>
34 #include <tnt/sessionscope.h>
35 #include <tnt/httpreply.h>
36 #include <tnt/backgroundworker.h>
37 #include <tnt/tntconfig.h>
38 
39 namespace tnt
40 {
52  {
53  Tntnet& tntnet;
54 
55  public:
56  explicit Configurator(tnt::Tntnet& tntnet_)
57  : tntnet(tntnet_)
58  { }
59 
61  unsigned getMinThreads() const
62  { return TntConfig::it().minThreads; }
64  void setMinThreads(unsigned n)
65  { TntConfig::it().minThreads = n; }
66 
68  unsigned getMaxThreads() const
69  { return TntConfig::it().maxThreads; }
71  void setMaxThreads(unsigned n)
72  { TntConfig::it().maxThreads = n; }
73 
75  unsigned getTimerSleep() const
76  { return TntConfig::it().timerSleep; }
78  void setTimerSleep(unsigned sec)
79  { TntConfig::it().timerSleep = sec; }
80 
82  unsigned getThreadStartDelay() const
83  { return TntConfig::it().threadStartDelay; }
85  void setThreadStartDelay(unsigned sec)
86  { TntConfig::it().threadStartDelay = sec; }
87 
89  unsigned getQueueSize() const
90  { return TntConfig::it().queueSize; }
92  void setQueueSize(unsigned n)
93  { TntConfig::it().queueSize = n; }
94 
96  unsigned getMaxRequestTime() const
97  { return TntConfig::it().maxRequestTime; }
99  void setMaxRequestTime(unsigned sec)
100  { TntConfig::it().maxRequestTime = sec; }
101 
103  bool getEnableCompression() const
104  { return TntConfig::it().enableCompression; }
106  void setEnableCompression(bool sw = true)
107  { TntConfig::it().enableCompression = sw; }
108 
110  unsigned getSessionTimeout() const
111  { return TntConfig::it().sessionTimeout; }
113  void setSessionTimeout(unsigned sec)
114  { TntConfig::it().sessionTimeout = sec; }
115 
117  int getListenBacklog() const
118  { return TntConfig::it().listenBacklog; }
120  void setListenBacklog(int n)
121  { TntConfig::it().listenBacklog = n; }
122 
124  unsigned getListenRetry() const
125  { return TntConfig::it().listenRetry; }
127  void setListenRetry(int n)
128  { TntConfig::it().listenRetry = n; }
129 
135  unsigned getMaxUrlMapCache() const
136  { return TntConfig::it().maxUrlMapCache; }
138  void setMaxUrlMapCache(int n)
139  { TntConfig::it().maxUrlMapCache = n; }
140 
144  size_t getMaxRequestSize() const
145  { return TntConfig::it().maxRequestSize; }
147  void setMaxRequestSize(size_t s)
148  { TntConfig::it().maxRequestSize = s; }
149 
156  unsigned getSocketReadTimeout() const
157  { return TntConfig::it().socketReadTimeout; }
159  void setSocketReadTimeout(unsigned ms)
160  { TntConfig::it().socketReadTimeout = ms; }
161 
164  unsigned getSocketWriteTimeout() const
165  { return TntConfig::it().socketWriteTimeout; }
167  void setSocketWriteTimeout(unsigned ms)
169 
172  unsigned getKeepAliveMax() const
173  { return TntConfig::it().keepAliveMax; }
175  void setKeepAliveMax(unsigned ms)
176  { TntConfig::it().keepAliveMax = ms; }
177 
182  unsigned getSocketBufferSize() const
183  { return TntConfig::it().socketBufferSize; }
185  void setSocketBufferSize(unsigned ms)
186  { TntConfig::it().socketBufferSize = ms; }
187 
191  unsigned getMinCompressSize() const
192  { return TntConfig::it().minCompressSize; }
194  void setMinCompressSize(unsigned s)
195  { TntConfig::it().minCompressSize = s; }
196 
201  unsigned getKeepAliveTimeout() const
202  { return TntConfig::it().keepAliveTimeout; }
204  void setKeepAliveTimeout(unsigned s)
206 
209  const std::string& getDefaultContentType() const
210  { return TntConfig::it().defaultContentType; }
212  void setDefaultContentType(const std::string& s)
214 
215  void setAccessLog(const std::string& accessLog)
216  { TntConfig::it().accessLog = accessLog; }
217 
218  void setMaxBackgroundTasks(unsigned n)
219  { TntConfig::it().backgroundTasks = n; }
220  unsigned getMaxBackgroundTasks() const
221  { return TntConfig::it().backgroundTasks; }
222  };
223 
224 }
225 
226 #endif // TNT_CONFIGURATOR_H
227