|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * This file contains the headers of Plugin, FrontendPlugin, |
|
16 * CommChannelPlugin and CommChannelPluginObserver classes and implementation |
|
17 * of DummyCommObserver. |
|
18 */ |
|
19 |
|
20 #ifndef PLUGIN_H |
|
21 #define PLUGIN_H |
|
22 |
|
23 #pragma warning ( disable : 4786 ) |
|
24 |
|
25 #include <string> |
|
26 #include "common.h" |
|
27 |
|
28 using namespace std; |
|
29 |
|
30 //********************************************************************************** |
|
31 // Class Plugin |
|
32 // |
|
33 //********************************************************************************** |
|
34 |
|
35 class Plugin |
|
36 { |
|
37 public: |
|
38 enum PluginType { null, dummy, frontend, comm_channel }; |
|
39 |
|
40 public: |
|
41 virtual PluginType GetType() { return null; } |
|
42 virtual DWORD Init(); |
|
43 virtual const string& GetName(string *name = NULL); |
|
44 |
|
45 protected: |
|
46 Plugin(); |
|
47 |
|
48 protected: |
|
49 string m_Name; |
|
50 }; |
|
51 |
|
52 //********************************************************************************** |
|
53 // Class FrontendPlugin |
|
54 // |
|
55 //********************************************************************************** |
|
56 |
|
57 class FrontendPlugin : public Plugin |
|
58 { |
|
59 public: |
|
60 virtual PluginType GetType() { return frontend; } |
|
61 virtual DWORD Init(); |
|
62 }; |
|
63 |
|
64 //********************************************************************************** |
|
65 // Class CommChannelPluginObserver |
|
66 // |
|
67 //********************************************************************************** |
|
68 |
|
69 class CommChannelPluginObserver |
|
70 { |
|
71 public: |
|
72 virtual void NotifyDataAvailable() = 0; |
|
73 virtual void NotifyCommChannelOpened() = 0; |
|
74 virtual void NotifyCommChannelClosed() = 0; |
|
75 }; |
|
76 |
|
77 //********************************************************************************** |
|
78 // Class DummyCommObserver |
|
79 // |
|
80 //********************************************************************************** |
|
81 |
|
82 class DummyCommObserver : public CommChannelPluginObserver |
|
83 { |
|
84 public: |
|
85 void NotifyDataAvailable() { }; |
|
86 void NotifyCommChannelOpened() { }; |
|
87 void NotifyCommChannelClosed() { }; |
|
88 }; |
|
89 |
|
90 //********************************************************************************** |
|
91 // Class CommChannelPlugin |
|
92 // |
|
93 // This class is the parent class of all communication channel plugins used |
|
94 // in DataGateway. |
|
95 //********************************************************************************** |
|
96 |
|
97 class CommChannelPlugin : public Plugin |
|
98 { |
|
99 public: |
|
100 PluginType GetType() { return comm_channel; } |
|
101 virtual DWORD Init(); |
|
102 virtual DWORD Open() = 0; |
|
103 virtual bool IsOpen() { return m_Open; } |
|
104 /* |
|
105 * This method closes and deletes the instance of plugin |
|
106 */ |
|
107 virtual DWORD Close() = 0; |
|
108 /* |
|
109 * This method is used to send Data object and Receive Data object |
|
110 */ |
|
111 virtual DWORD SendReceive(Data* data_in, Data** data_out, long timeout = 5000) = 0; |
|
112 /* |
|
113 * This method is used to send Data object |
|
114 */ |
|
115 virtual DWORD Send(Data* data_in, long timeout = 5000) = 0; |
|
116 /* |
|
117 * This method is used to receive Data object |
|
118 */ |
|
119 virtual DWORD Receive(Data** data_out, long timeout = 5000) = 0; |
|
120 /* |
|
121 * This method creates instance of specified plugin |
|
122 */ |
|
123 static CommChannelPlugin* Instance(const string& pluginname, |
|
124 const CommChannelPluginObserver* observer = NULL); |
|
125 /* |
|
126 * This method initializes and connects the instance of plugin |
|
127 */ |
|
128 static DWORD Connect(); |
|
129 /* |
|
130 * This method closes and deletes the instance of plugin |
|
131 */ |
|
132 static DWORD Disconnect(); |
|
133 |
|
134 protected: |
|
135 CommChannelPlugin(const CommChannelPluginObserver* observer = NULL); |
|
136 const CommChannelPluginObserver* GetObserver() { return m_Observer; } |
|
137 |
|
138 protected: |
|
139 const CommChannelPluginObserver* m_Observer; |
|
140 bool m_Open; |
|
141 |
|
142 private: |
|
143 static CommChannelPlugin* m_Self; |
|
144 }; |
|
145 |
|
146 #endif |
|
147 |
|
148 // End of the file |