1 | /* |
2 | * PROGRAM: Firebird interface. |
3 | * MODULE: firebird/Interface.h |
4 | * DESCRIPTION: Base class for all FB interfaces / plugins. |
5 | * |
6 | * The contents of this file are subject to the Initial |
7 | * Developer's Public License Version 1.0 (the "License"); |
8 | * you may not use this file except in compliance with the |
9 | * License. You may obtain a copy of the License at |
10 | * http://www.ibphoenix.com/main.nfs?a=ibphoenix&page=ibp_idpl. |
11 | * |
12 | * Software distributed under the License is distributed AS IS, |
13 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. |
14 | * See the License for the specific language governing rights |
15 | * and limitations under the License. |
16 | * |
17 | * The Original Code was created by Alex Peshkov |
18 | * for the Firebird Open Source RDBMS project. |
19 | * |
20 | * Copyright (c) 2010 Alex Peshkov <peshkoff at mail.ru> |
21 | * and all contributors signed below. |
22 | * |
23 | * All Rights Reserved. |
24 | * Contributor(s): ______________________________________. |
25 | * |
26 | * |
27 | */ |
28 | |
29 | #ifndef FB_INCLUDE_INTERFACE |
30 | #define FB_INCLUDE_INTERFACE |
31 | |
32 | #include "ibase.h" |
33 | |
34 | #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) |
35 | # define FB_CARG __cdecl |
36 | #else |
37 | # define FB_CARG |
38 | #endif |
39 | |
40 | namespace Firebird { |
41 | |
42 | // Forward declaration - used to identify client and provider of upgraded interface |
43 | class IPluginModule; |
44 | |
45 | // Versioned interface - base for all FB interfaces |
46 | class IVersioned |
47 | { |
48 | public: |
49 | virtual int FB_CARG getVersion() = 0; |
50 | virtual IPluginModule* FB_CARG getModule() = 0; |
51 | }; |
52 | // If this is changed, types of all interfaces must be changed |
53 | #define FB_VERSIONED_VERSION 2 |
54 | |
55 | // Reference counted interface - base for refCounted FB interfaces |
56 | class IRefCounted : public IVersioned |
57 | { |
58 | public: |
59 | virtual void FB_CARG addRef() = 0; |
60 | virtual int FB_CARG release() = 0; |
61 | }; |
62 | // If this is changed, types of refCounted interfaces must be changed |
63 | #define FB_REFCOUNTED_VERSION (FB_VERSIONED_VERSION + 2) |
64 | |
65 | // Disposable interface - base for disposable FB interfaces |
66 | class IDisposable : public IVersioned |
67 | { |
68 | public: |
69 | virtual void FB_CARG dispose() = 0; |
70 | }; |
71 | // If this is changed, types of disposable interfaces must be changed |
72 | #define FB_DISPOSABLE_VERSION (FB_VERSIONED_VERSION + 1) |
73 | |
74 | // Interface to work with status vector |
75 | // Created by master interface by request |
76 | // Also may be implemented on stack by internal FB code |
77 | class IStatus : public IDisposable |
78 | { |
79 | public: |
80 | virtual void FB_CARG set(unsigned int length, const ISC_STATUS* value) = 0; |
81 | virtual void FB_CARG set(const ISC_STATUS* value) = 0; |
82 | virtual void FB_CARG init() = 0; |
83 | |
84 | virtual const ISC_STATUS* FB_CARG get() const = 0; |
85 | virtual int FB_CARG isSuccess() const = 0; |
86 | }; |
87 | #define FB_STATUS_VERSION (FB_DISPOSABLE_VERSION + 5) |
88 | |
89 | class IProvider; |
90 | class IUtl; |
91 | class IPluginManager; |
92 | class ITimerControl; |
93 | class IAttachment; |
94 | class ITransaction; |
95 | class IDtc; |
96 | class IMetadataBuilder; |
97 | class IDebug; |
98 | class IConfigManager; |
99 | |
100 | struct UpgradeInfo |
101 | { |
102 | void* missingFunctionClass; |
103 | IPluginModule* clientModule; |
104 | }; |
105 | |
106 | // Master interface is used to access almost all other interfaces. |
107 | class IMaster : public IVersioned |
108 | { |
109 | public: |
110 | virtual IStatus* FB_CARG getStatus() = 0; |
111 | virtual IProvider* FB_CARG getDispatcher() = 0; |
112 | virtual IPluginManager* FB_CARG getPluginManager() = 0; |
113 | virtual int FB_CARG upgradeInterface(IVersioned* toUpgrade, int desiredVersion, |
114 | struct UpgradeInfo* upgradeInfo) = 0; |
115 | virtual const char* FB_CARG circularAlloc(const char* s, size_t len, intptr_t thr) = 0; |
116 | virtual ITimerControl* FB_CARG getTimerControl() = 0; |
117 | virtual IDtc* FB_CARG getDtc() = 0; |
118 | virtual IAttachment* FB_CARG registerAttachment(IProvider* provider, IAttachment* attachment) = 0; |
119 | virtual ITransaction* FB_CARG registerTransaction(IAttachment* attachment, ITransaction* transaction) = 0; |
120 | |
121 | // This function is required to compare interfaces based on vtables of them |
122 | virtual int FB_CARG same(IVersioned* first, IVersioned* second) = 0; |
123 | |
124 | virtual IMetadataBuilder* FB_CARG getMetadataBuilder(IStatus* status, unsigned fieldCount) = 0; |
125 | virtual Firebird::IDebug* FB_CARG getDebug() = 0; |
126 | virtual int FB_CARG serverMode(int mode) = 0; |
127 | virtual IUtl* FB_CARG getUtlInterface() = 0; |
128 | virtual IConfigManager* FB_CARG getConfigManager() = 0; |
129 | }; |
130 | #define FB_MASTER_VERSION (FB_VERSIONED_VERSION + 15) |
131 | |
132 | } // namespace Firebird |
133 | |
134 | extern "C" |
135 | { |
136 | // Additional API function. |
137 | // Should be used only in non-plugin modules. |
138 | // All plugins including providers should use passed at init time interface instead. |
139 | Firebird::IMaster* ISC_EXPORT fb_get_master_interface(); |
140 | } |
141 | |
142 | #endif // FB_INCLUDE_INTERFACE |
143 | |