Kea 3.1.1
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), started_(false), done_(false) {
54 if (!query) {
55 isc_throw(BadValue, "BulkLeaseQuery query is null");
56 }
57 }
58
60 virtual ~BulkLeaseQuery() {
61 }
62
68 virtual void init() = 0;
69
71 virtual void start() = 0;
72
77 if (!ptr) {
78 // Should not happen.
79 return;
80 }
81 ptr->start();
82 }
83
88 bool isProcessing() const {
89 return (started_);
90 }
91
95 bool isProcessed() const {
96 return (done_);
97 }
98
103 return (query_);
104 }
105
109 uint8_t getQueryType() const {
110 return (query_type_);
111 }
112
116 Xid getXid() const {
117 return (query_->getXid());
118 }
119
120protected:
122 virtual void setDone() {
123 done_ = true;
124 query_complete_(query_->getXid());
125 }
126
129
132
135
138
140 uint8_t query_type_;
141
144
146 bool done_;
147};
148
149} // end of namespace isc::lease_query
150} // end of namespace isc
151
152#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.