comparison deps/Platinum/ThirdParty/Neptune/Source/Core/NptInterfaces.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 | Neptune - Interfaces
4 |
5 | Copyright (c) 2002-2008, Axiomatic Systems, LLC.
6 | All rights reserved.
7 |
8 | Redistribution and use in source and binary forms, with or without
9 | modification, are permitted provided that the following conditions are met:
10 | * Redistributions of source code must retain the above copyright
11 | notice, this list of conditions and the following disclaimer.
12 | * Redistributions in binary form must reproduce the above copyright
13 | notice, this list of conditions and the following disclaimer in the
14 | documentation and/or other materials provided with the distribution.
15 | * Neither the name of Axiomatic Systems nor the
16 | names of its contributors may be used to endorse or promote products
17 | derived from this software without specific prior written permission.
18 |
19 | THIS SOFTWARE IS PROVIDED BY AXIOMATIC SYSTEMS ''AS IS'' AND ANY
20 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 | DISCLAIMED. IN NO EVENT SHALL AXIOMATIC SYSTEMS BE LIABLE FOR ANY
23 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 |
30 ****************************************************************/
31
32 #ifndef _NPT_INTERFACES_H_
33 #define _NPT_INTERFACES_H_
34
35 /*----------------------------------------------------------------------
36 | includes
37 +---------------------------------------------------------------------*/
38 #include "NptTypes.h"
39 #include "NptCommon.h"
40 #include "NptResults.h"
41
42 /*----------------------------------------------------------------------
43 | constants
44 +---------------------------------------------------------------------*/
45 const int NPT_ERROR_NO_SUCH_INTERFACE = NPT_ERROR_BASE_INTERFACES - 0;
46
47 #if 0 // disabled, use NPT_Reference instead
48 /*----------------------------------------------------------------------
49 | macros
50 +---------------------------------------------------------------------*/
51 #define NPT_RELEASE(o) do { if (o) (o)->Release(); (o) = NULL; } while (0)
52 #define NPT_ADD_REFERENCE(o) do { if (o) (o)->AddReference(); } while (0)
53
54 /*----------------------------------------------------------------------
55 | NPT_Referenceable
56 +---------------------------------------------------------------------*/
57 class NPT_Referenceable
58 {
59 public:
60 // methods
61 virtual void AddReference() = 0;
62 virtual void Release() = 0;
63
64 protected:
65 // constructors and destructor
66 NPT_Referenceable() {}
67 virtual ~NPT_Referenceable() {}
68 };
69 #endif
70
71 /*----------------------------------------------------------------------
72 | NPT_InterfaceId
73 +---------------------------------------------------------------------*/
74 class NPT_InterfaceId
75 {
76 public:
77 // methods
78 bool operator==(const NPT_InterfaceId& id) const {
79 return ((id.m_Id == m_Id) && (id.m_Version == m_Version));
80 }
81
82 // members
83 unsigned long m_Id;
84 unsigned long m_Version;
85 };
86
87 /*----------------------------------------------------------------------
88 | NPT_Polymorphic
89 +---------------------------------------------------------------------*/
90 class NPT_Polymorphic
91 {
92 public:
93 // destructor
94 virtual ~NPT_Polymorphic() {}
95
96 // methods
97 virtual NPT_Result GetInterface(const NPT_InterfaceId& id,
98 NPT_Interface*& iface) = 0;
99 };
100
101 /*----------------------------------------------------------------------
102 | NPT_Interruptible
103 +---------------------------------------------------------------------*/
104 class NPT_Interruptible
105 {
106 public:
107 // destructor
108 virtual ~NPT_Interruptible() {}
109
110 // methods
111 virtual NPT_Result Interrupt() = 0;
112 };
113
114 /*----------------------------------------------------------------------
115 | NPT_Configurable
116 +---------------------------------------------------------------------*/
117 class NPT_Configurable
118 {
119 public:
120 // destructor
121 virtual ~NPT_Configurable() {}
122
123 // methods
124 virtual NPT_Result SetProperty(const char* /*name*/,
125 const char* /*value*/) {
126 return NPT_ERROR_NO_SUCH_PROPERTY;
127 }
128 virtual NPT_Result SetProperty(const char* /*name*/,
129 int /*value*/) {
130 return NPT_ERROR_NO_SUCH_PROPERTY;
131 }
132 virtual NPT_Result GetProperty(const char* /*name*/,
133 NPT_PropertyValue& /*value*/) {
134 return NPT_ERROR_NO_SUCH_PROPERTY;
135 }
136 };
137
138 #endif // _NPT_INTERFACES_H_