Kea 3.1.7
bulk_lease_query.h
Go to the documentation of this file.
1// Copyright (C) 2022-2025 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 <blq_msg.h>
13#include <boost/enable_shared_from_this.hpp>
14#include <functional>
15
16namespace isc {
17namespace lease_query {
18
20typedef std::function<void ()> BlqPostCbArg;
21
23typedef std::function<void (const BlqPostCbArg&)> BlqPostCb;
24
26typedef std::function<bool (BlqResponsePtr)> BlqPushToSendCb;
27
29typedef std::function<void (Xid)> BlqQueryCompleteCb;
30
32class BulkLeaseQuery;
33
35typedef boost::shared_ptr<BulkLeaseQuery> BulkLeaseQueryPtr;
36
38class BulkLeaseQuery : public boost::enable_shared_from_this<BulkLeaseQuery> {
39public:
40
49 const BlqPostCb& post,
50 const BlqPushToSendCb& push_to_send,
51 const BlqQueryCompleteCb& query_complete)
52 : query_(query), post_(post), push_to_send_(push_to_send),
53 query_complete_(query_complete), query_type_(0),
54 started_(false), done_(false) {
55 if (!query) {
56 isc_throw(BadValue, "BulkLeaseQuery query is null");
57 }
58 }
59
61 virtual ~BulkLeaseQuery() {
62 }
63
69 virtual void init() = 0;
70
72 virtual void start() = 0;
73
78 if (!ptr) {
79 // Should not happen.
80 return;
81 }
82 ptr->start();
83 }
84
89 bool isProcessing() const {
90 return (started_);
91 }
92
96 bool isProcessed() const {
97 return (done_);
98 }
99
104 return (query_);
105 }
106
110 uint8_t getQueryType() const {
111 return (query_type_);
112 }
113
117 Xid getXid() const {
118 return (query_->getXid());
119 }
120
121protected:
123 virtual void setDone() {
124 done_ = true;
125 query_complete_(query_->getXid());
126 }
127
130
133
136
139
141 uint8_t query_type_;
142
145
147 bool done_;
148};
149
150} // end of namespace isc::lease_query
151} // end of namespace isc
152
153#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.