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 
30 #ifndef TNT_CONFIGURATOR_H
31 #define TNT_CONFIGURATOR_H
32 
33 #include <tnt/tntnet.h>
34 #include <tnt/sessionscope.h>
35 #include <tnt/httpreply.h>
36 #include <tnt/tntconfig.h>
37 
38 namespace tnt
39 {
51  {
52  Tntnet& _tntnet;
53 
54  public:
55  explicit Configurator(tnt::Tntnet& tntnet)
56  : _tntnet(tntnet)
57  { }
58 
60  unsigned getMinThreads() const
61  { return TntConfig::it().minThreads; }
63  void setMinThreads(unsigned n)
64  { TntConfig::it().minThreads = n; }
65 
67  unsigned getMaxThreads() const
68  { return TntConfig::it().maxThreads; }
70  void setMaxThreads(unsigned n)
71  { TntConfig::it().maxThreads = n; }
72 
75  { return TntConfig::it().timerSleep; }
78  { TntConfig::it().timerSleep = sec; }
79 
82  { return TntConfig::it().threadStartDelay; }
85  { TntConfig::it().threadStartDelay = sec; }
86 
88  unsigned getQueueSize() const
89  { return TntConfig::it().queueSize; }
91  void setQueueSize(unsigned n)
92  { TntConfig::it().queueSize = n; }
93 
96  { return TntConfig::it().maxRequestTime; }
99  { TntConfig::it().maxRequestTime = sec; }
100 
102  bool getEnableCompression() const
103  { return TntConfig::it().enableCompression; }
105  void setEnableCompression(bool sw = true)
106  { TntConfig::it().enableCompression = sw; }
107 
110  { return TntConfig::it().sessionTimeout; }
113  { TntConfig::it().sessionTimeout = sec; }
114 
116  int getListenBacklog() const
117  { return TntConfig::it().listenBacklog; }
119  void setListenBacklog(int n)
120  { TntConfig::it().listenBacklog = n; }
121 
123  unsigned getListenRetry() const
124  { return TntConfig::it().listenRetry; }
126  void setListenRetry(int n)
127  { TntConfig::it().listenRetry = n; }
128 
134  unsigned getMaxUrlMapCache() const
135  { return TntConfig::it().maxUrlMapCache; }
137  void setMaxUrlMapCache(int n)
138  { TntConfig::it().maxUrlMapCache = n; }
139 
143  size_t getMaxRequestSize() const
144  { return TntConfig::it().maxRequestSize; }
146  void setMaxRequestSize(size_t s)
147  { TntConfig::it().maxRequestSize = s; }
148 
156  { return TntConfig::it().socketReadTimeout; }
159  { TntConfig::it().socketReadTimeout = ms; }
160 
164  { return TntConfig::it().socketWriteTimeout; }
168 
171  unsigned getKeepAliveMax() const
172  { return TntConfig::it().keepAliveMax; }
174  void setKeepAliveMax(unsigned ms)
175  { TntConfig::it().keepAliveMax = ms; }
176 
181  unsigned getSocketBufferSize() const
182  { return TntConfig::it().socketBufferSize; }
184  void setSocketBufferSize(unsigned ms)
185  { TntConfig::it().socketBufferSize = ms; }
186 
190  unsigned getMinCompressSize() const
191  { return TntConfig::it().minCompressSize; }
193  void setMinCompressSize(unsigned s)
194  { TntConfig::it().minCompressSize = s; }
195 
201  { return TntConfig::it().keepAliveTimeout; }
205 
208  const std::string& getDefaultContentType() const
209  { return TntConfig::it().defaultContentType; }
211  void setDefaultContentType(const std::string& s)
213 
214  void setAccessLog(const std::string& accessLog)
215  { TntConfig::it().accessLog = accessLog; }
216  };
217 }
218 
219 #endif // TNT_CONFIGURATOR_H
220