Kea 3.3.3
bulk_lease_query.h
Go to the documentation of this file.
1// Copyright (C) 2022-2026 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#ifndef BULK_LEASE_QUERY_H
8#define BULK_LEASE_QUERY_H
9
10#include <config.h>
11
12#include <lease_query/blq_msg.h>
13
14#include <functional>
15
16#include <boost/enable_shared_from_this.hpp>
17
18namespace isc {
19namespace lease_query {
20
22typedef std::function<void ()> BlqPostCbArg;
23
25typedef std::function<void (const BlqPostCbArg&)> BlqPostCb;
26
28typedef std::function<bool (BlqResponsePtr)> BlqPushToSendCb;
29
31typedef std::function<void (Xid)> BlqQueryCompleteCb;
32
34class BulkLeaseQuery;
35
37typedef boost::shared_ptr<BulkLeaseQuery> BulkLeaseQueryPtr;
38
40class BulkLeaseQuery : public boost::enable_shared_from_this<BulkLeaseQuery> {
41public:
42
51 const BlqPostCb& post,
52 const BlqPushToSendCb& push_to_send,
53 const BlqQueryCompleteCb& query_complete)
54 : query_(query), post_(post), push_to_send_(push_to_send),
55 query_complete_(query_complete), query_type_(0),
56 started_(false), done_(false) {
57 if (!query) {
58 isc_throw(BadValue, "BulkLeaseQuery query is null");
59 }
60 }
61
63 virtual ~BulkLeaseQuery() {
64 }
65
71 virtual void init() = 0;
72
74 virtual void start() = 0;
75
80 if (!ptr) {
81 // Should not happen.
82 return;
83 }
84 ptr->start();
85 }
86
91 bool isProcessing() const {
92 return (started_);
93 }
94
98 bool isProcessed() const {
99 return (done_);
100 }
101
106 return (query_);
107 }
108
112 uint8_t getQueryType() const {
113 return (query_type_);
114 }
115
119 Xid getXid() const {
120 return (query_->getXid());
121 }
122
123protected:
125 virtual void setDone() {
126 done_ = true;
127 query_complete_(query_->getXid());
128 }
129
132
135
138
141
143 uint8_t query_type_;
144
147
149 bool done_;
150};
151
152} // end of namespace isc::lease_query
153} // end of namespace isc
154
155#endif // BULK_LEASE_QUERY_H
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
Base class for providing control flow for processing a bulk query.
BlqQueryCompleteCb query_complete_
The queryComplete callback.
bool isProcessing() const
Processing in progress predicate.
uint8_t query_type_
The query type.
virtual void start()=0
Start processing.
virtual void setDone()
Set the done flag.
BlqQueryPtr getQuery()
Get the query.
BlqPostCb post_
The post callback.
bool isProcessed() const
Processing finished predicate.
virtual ~BulkLeaseQuery()
Destructor.
BulkLeaseQuery(BlqQueryPtr query, const BlqPostCb &post, const BlqPushToSendCb &push_to_send, const BlqQueryCompleteCb &query_complete)
Constructor.
virtual void init()=0
Initialization.
bool started_
The processing is in progress.
uint8_t getQueryType() const
Get the query type.
BlqPushToSendCb push_to_send_
The pushToSend callback.
static void processStart(BulkLeaseQueryPtr ptr)
Class/static start processing.
bool done_
The processing finished.
Xid getXid() const
Get the transaction id of the query.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
boost::shared_ptr< BlqResponse > BlqResponsePtr
Defines a shared pointer to an BlqResponse.
Definition blq_msg.h:143
std::function< void(const BlqPostCbArg &)> BlqPostCb
Type of BLQ post callback.
std::function< void(Xid)> BlqQueryCompleteCb
Type of BLQ queryComplete callback.
std::function< void()> BlqPostCbArg
Type of BLQ post callback argument..
uint32_t Xid
Defines a Bulk LeaseQuery transaction id.
Definition blq_msg.h:18
boost::shared_ptr< BlqQuery > BlqQueryPtr
Defines a shared pointer to an BlqQuery.
Definition blq_msg.h:116
boost::shared_ptr< BulkLeaseQuery > BulkLeaseQueryPtr
Defines a shared pointer to a BulkLeaseQuery object.
std::function< bool(BlqResponsePtr)> BlqPushToSendCb
Type of BLQ pushToSend callback.
Defines the logger used by the top-level component of kea-lfc.