Unity Scopes API
BufferedResultForwarder.h
1 /*
2  * Copyright (C) 2014 Canonical Ltd
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License version 3 as
6  * published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authored by: Pawel Stolowski <pawel.stolowski@canonical.com>
17  */
18 
19 #pragma once
20 
21 #include <unity/scopes/SearchListenerBase.h>
22 #include <unity/scopes/SearchReplyProxyFwd.h>
23 
24 namespace unity
25 {
26 
27 namespace scopes
28 {
29 
30 namespace experimental
31 {
32  class Annotation;
33 }
34 
35 namespace utility
36 {
37 
38 namespace internal
39 {
40  class BufferedResultForwarderImpl;
41 }
42 
44 {
45 public:
47  NONCOPYABLE(BufferedResultForwarder);
48  UNITY_DEFINES_PTRS(BufferedResultForwarder);
49 
50  virtual ~BufferedResultForwarder();
52 
62  BufferedResultForwarder::SPtr const& next_forwarder = BufferedResultForwarder::SPtr());
63 
74  void push(CategorisedResult result) override;
75 
83  bool is_ready() const;
84 
85 protected:
92  void set_ready();
93 
103 
104  void finished(CompletionDetails const& details) override;
105 
106 private:
107  friend class internal::BufferedResultForwarderImpl;
108 
109  std::unique_ptr<internal::BufferedResultForwarderImpl> p;
110 };
111 
112 } // namespace utility
113 
114 } // namespace scopes
115 
116 } // namespace unity
unity::scopes::SearchReplyProxy upstream() const
Get the upstream proxy.
Definition: BufferedResultForwarder.cpp:151
void finished(CompletionDetails const &details) override
Called once by the scopes run time after the final result for a request was sent. ...
Definition: BufferedResultForwarder.cpp:156
bool is_ready() const
Check if this forwarder is ready.
Definition: BufferedResultForwarder.cpp:136
BufferedResultForwarder(unity::scopes::SearchReplyProxy const &upstream, BufferedResultForwarder::SPtr const &next_forwarder=BufferedResultForwarder::SPtr())
Create a forwarder that sends (at least one) result to its upstream reply proxy before indicating tha...
Definition: BufferedResultForwarder.cpp:126
Base class for a client to receive and buffer the results of a query until another BufferedResultForw...
Definition: BufferedResultForwarder.h:43
Top-level namespace for all things Unity-related.
Definition: Version.h:49
Definition: ActionMetadata.h:31
Abstract base interface for a client to receive the results of a query.
Definition: SearchListenerBase.h:56
A container for details about the completion status of a query as well as any additional information ...
Definition: CompletionDetails.h:45
void push(CategorisedResult result) override
Forwards a single result before calling set_ready().
Definition: BufferedResultForwarder.cpp:146
A result, including the category it belongs to.
Definition: CategorisedResult.h:41
std::shared_ptr< SearchReply > SearchReplyProxy
Convenience type definition.
Definition: SearchReplyProxyFwd.h:34
void set_ready()
Mark this forwarder as ready.
Definition: BufferedResultForwarder.cpp:141