tntnet.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2003-2007 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_TNTNET_H
31 #define TNT_TNTNET_H
32 
33 #include <tnt/tntconfig.h>
34 #include <tnt/mapping.h>
35 #include <string>
36 
37 namespace tnt
38 {
39  struct TntConfig;
40  class TntnetImpl;
41 
86  class Tntnet
87  {
88  public:
93  Tntnet();
94 
99  Tntnet(const Tntnet& t);
100 
105  Tntnet& operator=(const Tntnet& t);
106 
108  void init(const TntConfig& config);
109 
117  void listen(const std::string& ipaddr, unsigned short int port);
118 
123  void listen(unsigned short int port)
124  { listen(std::string(), port); }
125 
130  void sslListen(const std::string& certificateFile, const std::string& keyFile,
131  const std::string& ipaddr, unsigned short int port);
132 
137  void sslListen(const std::string& certificateFile, const std::string& keyFile,
138  unsigned short int port)
139  { sslListen(certificateFile, keyFile, std::string(), port); }
140 
147  void run();
148 
150  static void shutdown();
151 
153  static bool shouldStop();
154 
156  unsigned getMinThreads() const;
157 
159  void setMinThreads(unsigned n);
160 
162  unsigned getMaxThreads() const;
163 
165  void setMaxThreads(unsigned n);
166 
168 
183  Mapping& mapUrl(const std::string& url, const std::string& ci);
184 
185  Mapping& mapUrl(const std::string& url, const Compident& ci);
186 
188  void mapUrl(const std::string& url, const std::string& pathinfo, const std::string& ci);
189 
191  Mapping& mapUrl(const std::string& url, const Maptarget& ci);
192 
194  Mapping& vMapUrl(const std::string& vhost, const std::string& url, const Maptarget& ci);
195 
209  void setAppName(const std::string& appname);
210 
212  const std::string& getAppName() const;
213 
221  void setAccessLog(const std::string& logfile_path);
222 
223  private:
224  TntnetImpl* _impl;
225  };
226 }
227 
228 #endif // TNT_TNTNET_H
229