931a54911f1aa58f62802bc5db1d6e19b1ee89a4
[platform/core/location/maps-plugin-here.git] / inc / engine / common / QueryListener.h
1 /*
2  * Copyright (C) 2013 HERE Global B.V. All rights reserved.
3  * This software, including documentation, is protected by copyright controlled by
4  * HERE Global B.V. (“Software”). All rights are reserved. Copying, including reproducing,
5  * storing, adapting or translating, any or all of this material requires the prior
6  * written consent of HERE Global B.V. You may use this
7  * Software in accordance with the terms and conditions defined in the
8  * HERE Location Platform Services Terms and Conditions, available at
9  * http://developer.here.com/terms-conditions-base
10  *
11  * As an additional permission to the above, you may distribute Software,
12  * in object code format as part of an Application, according to, and subject to, terms and
13  * conditions defined in the Tizen Software Development kit (“SDK”) License Agreement.
14  * You may distribute such object code format Application under terms of your choice,
15  * provided that the header and source files of the Software have not been modified.
16  */
17
18 #ifndef QUERYLISTENER_H
19 #define QUERYLISTENER_H
20
21 #include <tr1/memory>
22 #include "common/HereMaps_global.h"
23
24 #ifndef TIZEN_MIGRATION
25 #include <FBaseRtEvent.h>
26 #include <FBaseRtIEventListener.h>
27 #include <FBaseRtIEventArg.h>
28 #endif
29
30 HERE_MAPS_BEGIN_NAMESPACE
31
32 class BaseReply;
33 class ErrorBase;
34
35 typedef std::tr1::shared_ptr<BaseReply> BaseReplyPtr;
36 /**
37  * This class encapsulates an object that is notified when a response to a query
38  * has become available. 
39  * 
40  * Derived classes must implement the virtual methods of this class.
41  */
42 class EXPORT_API QueryListener
43 #ifndef TIZEN_MIGRATION
44 : public Tizen::Base::Runtime::Event
45 , public Tizen::Base::Runtime::IEventListener
46 #endif
47 {
48 public:
49     /**
50      * This is the default constructor for the class.
51      */
52     QueryListener();
53
54     /**
55      * This is a virtual destructor for the class.
56      */
57     virtual ~QueryListener();
58
59     /**
60      * This method triggers a call to the listener's method
61      * <code>OnReplySuccess()</code>. 
62      * 
63      * @param pReply A pointer to the query reply.
64      */
65     void NotifyForSuccess(BaseReplyPtr pReply);
66
67     /**
68      * This method triggers a call to the listener's method
69      * <code>OnReplyFailure()</code>. 
70      * 
71      * @param pReply A pointer to the query reply.
72      */
73     void NotifyForFailure(BaseReplyPtr pReply);
74
75     /**
76      * This method is a callback invoked when a query is successful. The
77      * implementation of this method handles the reply to a successful query.
78      * 
79      * @param rReply A Reference to the query reply object.
80      *
81      */
82     virtual void OnReplySuccess(BaseReply& rReply) = 0;
83
84     /**
85      * This method is a callback invoked when a query fails. The
86      * implementation of this method handles the reply.
87      *
88      * @param rReply A Constant reference to the reply. Only the error and user
89      *        data are valid.
90      */
91 #ifdef TIZEN_MIGRATION
92     virtual void OnFailure(const BaseReply& rReply) = 0;
93 #else
94     virtual void OnFailure(const BaseReply& rReply);
95 #endif
96
97 private:
98     HERE_MAPS_NO_COPY_NO_ASSIGN(QueryListener);
99     class Arguments;
100 #ifndef TIZEN_MIGRATION
101     void FireImpl(Tizen::Base::Runtime::IEventListener& rListener, const Tizen::Base::Runtime::IEventArg& rArgs);
102 #endif
103 };
104
105 HERE_MAPS_END_NAMESPACE
106
107 #endif