OSDN Git Service

389e3822a82d19981b1d1df7bda1cc258e617856
[ultramonkey-l7/ultramonkey-l7-v3.git] / l7vsd / include / schedule_module_base.h
1 /*
2  *    @file    schedule_module_base.h
3  *    @brief    shared object schedule module abstract class
4  *
5  * L7VSD: Linux Virtual Server for Layer7 Load Balancing
6  * Copyright (C) 2009  NTT COMWARE Corporation.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21  * 02110-1301 USA
22  *
23  **********************************************************************/
24 #ifndef    SCHEDULE_MODULE_BASE_H
25 #define    SCHEDULE_MODULE_BASE_H
26
27 #include <boost/asio.hpp>
28 #include <boost/function.hpp>
29 #include "logger_enum.h"
30 #include "module_base.h"
31 #include "realserver.h"
32
33 namespace l7vs
34 {
35
36 //
37 //! @class schedule_module_base
38 //!    @brief    schedule module abstract base class.
39 //! @brief    all schedule module is extened this class.
40 class schedule_module_base : public module_base
41 {
42 public:
43         //! realserver list iterator type
44         typedef    std::list<l7vs::realserver>
45         rslist_type;
46         typedef    boost::function< rslist_type::iterator(void)>
47         rslist_iterator_begin_func_type;
48         typedef    boost::function< rslist_type::iterator(void)>
49         rslist_iterator_end_func_type;
50         typedef    boost::function< rslist_type::iterator(rslist_type::iterator)>
51         rslist_iterator_next_func_type;
52 public:
53         //!    constractor
54         schedule_module_base(std::string in_modulename) : module_base(in_modulename) {};
55         //! destractor
56         virtual    ~schedule_module_base() {};
57         //!    initialize function
58         virtual    void    initialize() = 0;
59         //! handle schedule called then schedule function for TCP/IP endpoint
60         //! @param[in]    thread id
61         //! @param[in]    list iterator first function object
62         //!    @param[in]    list iterator last function object
63         //!    @param[in]    list iterator next function object
64         //! @param[out]    scheduled TCP/IP endpoint
65         virtual    void    handle_schedule(
66                 boost::thread::id,
67                 rslist_iterator_begin_func_type,
68                 rslist_iterator_end_func_type,
69                 rslist_iterator_next_func_type,
70                 boost::asio::ip::tcp::endpoint &) = 0;
71
72         //! handle schedule calles then schedule function for UDP endpoint
73         //! @param[in]    thread id
74         //! @param[in]    list iterator first function object
75         //!    @param[in]    list iterator last function object
76         //!    @param[in]    list iterator next function object
77         //! @param[out]    scheduled UDP endpoint
78         virtual    void    handle_schedule(
79                 boost::thread::id,
80                 rslist_iterator_begin_func_type,
81                 rslist_iterator_end_func_type,
82                 rslist_iterator_next_func_type,
83                 boost::asio::ip::udp::endpoint &) = 0;
84
85 };
86
87 }    //namespace l7vs
88
89 #endif //SCHEDULE_MODULE_BASE_H