Reformat: delete trailing whitespace
[metaproxy-moved-to-github.git] / include / metaproxy / package.hpp
1 /* This file is part of Metaproxy.
2    Copyright (C) 2005-2012 Index Data
3
4 Metaproxy is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
7 version.
8
9 Metaproxy is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12 for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17 */
18
19 #ifndef YP2_PACKAGE_HPP
20 #define YP2_PACKAGE_HPP
21
22 #include <iosfwd>
23
24 #include <yazpp/gdu.h>
25
26 #include "router.hpp"
27 #include "filter.hpp"
28 #include "session.hpp"
29 #include "origin.hpp"
30 #include <boost/shared_ptr.hpp>
31
32 namespace metaproxy_1 {
33     class Package;
34 }
35
36
37 namespace std
38 {
39     std::ostream& operator<<(std::ostream& os, const metaproxy_1::Package& p);
40 }
41
42 namespace metaproxy_1 {
43
44     class Package {
45     public:
46         Package();
47
48         ~Package();
49
50         Package(metaproxy_1::Session &session,
51                 const metaproxy_1::Origin &origin);
52
53         /// copy constructor which copies route pos + logger
54         Package & copy_filter(const Package &p);
55
56         /// copy constructor which only copies the filter chain info
57         void copy_route(const Package &p);
58
59         /// send Package to it's next Filter defined in Router
60         void move();
61
62         /// send Package to other route
63         void move(std::string route);
64
65         /// access session - left val in assignment
66         metaproxy_1::Session & session();
67
68         /// get function - right val in assignment
69         Origin origin() const;
70
71         /// set function - left val in assignment
72         Origin & origin();
73
74         /// set function - can be chained
75         Package & router(const Router &router);
76
77         yazpp_1::GDU &request();
78
79         yazpp_1::GDU &response();
80
81         /// get function - right val in assignment
82         Session session() const;
83
84         void log(const char *module, int level, const char *fmt, ...);
85         void log_write(const char *buf, size_t sz);
86         void log_enable(void);
87         void log_reset(std::string &res);
88
89         class PackageLogger;
90         typedef boost::shared_ptr<PackageLogger> PackageLoggerPtr;
91
92     private:
93         Session m_session;
94         Origin m_origin;
95
96         RoutePos *m_route_pos;
97
98         PackageLoggerPtr p_logger;
99
100         yazpp_1::GDU m_request_gdu;
101         yazpp_1::GDU m_response_gdu;
102     };
103 }
104
105 #endif
106 /*
107  * Local variables:
108  * c-basic-offset: 4
109  * c-file-style: "Stroustrup"
110  * indent-tabs-mode: nil
111  * End:
112  * vim: shiftwidth=4 tabstop=8 expandtab
113  */
114