Mercurial > projects > hoofbaby
comparison deps/Platinum/Source/Core/PltEvent.h @ 0:3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
author | fraserofthenight |
---|---|
date | Mon, 06 Jul 2009 08:06:28 -0700 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:3425707ddbf6 |
---|---|
1 /***************************************************************** | |
2 | | |
3 | Platinum - Event | |
4 | | |
5 | Copyright (c) 2004-2008, Plutinosoft, LLC. | |
6 | All rights reserved. | |
7 | http://www.plutinosoft.com | |
8 | | |
9 | This program is free software; you can redistribute it and/or | |
10 | modify it under the terms of the GNU General Public License | |
11 | as published by the Free Software Foundation; either version 2 | |
12 | of the License, or (at your option) any later version. | |
13 | | |
14 | OEMs, ISVs, VARs and other distributors that combine and | |
15 | distribute commercially licensed software with Platinum software | |
16 | and do not wish to distribute the source code for the commercially | |
17 | licensed software under version 2, or (at your option) any later | |
18 | version, of the GNU General Public License (the "GPL") must enter | |
19 | into a commercial license agreement with Plutinosoft, LLC. | |
20 | | |
21 | This program is distributed in the hope that it will be useful, | |
22 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
24 | GNU General Public License for more details. | |
25 | | |
26 | You should have received a copy of the GNU General Public License | |
27 | along with this program; see the file LICENSE.txt. If not, write to | |
28 | the Free Software Foundation, Inc., | |
29 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
30 | http://www.gnu.org/licenses/gpl-2.0.html | |
31 | | |
32 ****************************************************************/ | |
33 | |
34 #ifndef _PLT_EVENT_H_ | |
35 #define _PLT_EVENT_H_ | |
36 | |
37 /*---------------------------------------------------------------------- | |
38 | includes | |
39 +---------------------------------------------------------------------*/ | |
40 #include "Neptune.h" | |
41 #include "PltHttpClientTask.h" | |
42 | |
43 /*---------------------------------------------------------------------- | |
44 | forward declarations | |
45 +---------------------------------------------------------------------*/ | |
46 class PLT_StateVariable; | |
47 class PLT_DeviceData; | |
48 class PLT_Service; | |
49 class PLT_TaskManager; | |
50 | |
51 /*---------------------------------------------------------------------- | |
52 | PLT_EventSubscriber class | |
53 +---------------------------------------------------------------------*/ | |
54 class PLT_EventSubscriber | |
55 { | |
56 public: | |
57 PLT_EventSubscriber(PLT_TaskManager* task_manager, | |
58 PLT_Service* service, | |
59 const char* sid, | |
60 int timeout = -1); | |
61 ~PLT_EventSubscriber(); | |
62 | |
63 PLT_Service* GetService(); | |
64 NPT_Ordinal GetEventKey(); | |
65 NPT_Result SetEventKey(NPT_Ordinal value); | |
66 NPT_SocketAddress GetLocalIf(); | |
67 NPT_Result SetLocalIf(NPT_SocketAddress value); | |
68 NPT_TimeStamp GetExpirationTime(); | |
69 NPT_Result SetTimeout(int timeout = -1); | |
70 const NPT_String& GetSID() const { return m_SID; } | |
71 NPT_Result FindCallbackURL(const char* callback_url); | |
72 NPT_Result AddCallbackURL(const char* callback_url); | |
73 NPT_Result Notify(NPT_List<PLT_StateVariable*>& vars); | |
74 | |
75 protected: | |
76 //members | |
77 PLT_TaskManager* m_TaskManager; | |
78 PLT_Service* m_Service; | |
79 NPT_Ordinal m_EventKey; | |
80 PLT_HttpClientSocketTask* m_SubscriberTask; | |
81 NPT_String m_SID; | |
82 NPT_SocketAddress m_LocalIf; | |
83 NPT_Array<NPT_String> m_CallbackURLs; | |
84 NPT_TimeStamp m_ExpirationTime; | |
85 }; | |
86 | |
87 /*---------------------------------------------------------------------- | |
88 | PLT_EventSubscriberFinderBySID | |
89 +---------------------------------------------------------------------*/ | |
90 class PLT_EventSubscriberFinderBySID | |
91 { | |
92 public: | |
93 // methods | |
94 PLT_EventSubscriberFinderBySID(const char* sid) : m_SID(sid) {} | |
95 | |
96 bool operator()(PLT_EventSubscriber* const & sub) const { | |
97 return m_SID.Compare(sub->GetSID(), true) ? false : true; | |
98 } | |
99 | |
100 private: | |
101 // members | |
102 NPT_String m_SID; | |
103 }; | |
104 | |
105 /*---------------------------------------------------------------------- | |
106 | PLT_EventSubscriberFinderByCallbackURL | |
107 +---------------------------------------------------------------------*/ | |
108 class PLT_EventSubscriberFinderByCallbackURL | |
109 { | |
110 public: | |
111 // methods | |
112 PLT_EventSubscriberFinderByCallbackURL(const char* callback_url) : | |
113 m_CallbackURL(callback_url) {} | |
114 | |
115 bool operator()(PLT_EventSubscriber* const & sub) const { | |
116 return NPT_SUCCEEDED(sub->FindCallbackURL(m_CallbackURL)); | |
117 } | |
118 | |
119 private: | |
120 // members | |
121 NPT_String m_CallbackURL; | |
122 }; | |
123 | |
124 /*---------------------------------------------------------------------- | |
125 | PLT_EventSubscriberFinderByService | |
126 +---------------------------------------------------------------------*/ | |
127 class PLT_EventSubscriberFinderByService | |
128 { | |
129 public: | |
130 // methods | |
131 PLT_EventSubscriberFinderByService(PLT_Service* service) : m_Service(service) {} | |
132 virtual ~PLT_EventSubscriberFinderByService() {} | |
133 bool operator()(PLT_EventSubscriber* const & eventSub) const; | |
134 | |
135 private: | |
136 // members | |
137 PLT_Service* m_Service; | |
138 }; | |
139 | |
140 #endif /* _PLT_EVENT_H_ */ |