NAVTOR SDK  v.3.0
Software Development Kit for fast and efficient development of ECDIS, ECS and generic marine applications
sdk_component_interface.h
Go to the documentation of this file.
1 #ifndef SDK_BASE_SDK_OBJECT_INTERFACE_H_
11 #define SDK_BASE_SDK_OBJECT_INTERFACE_H_
12 
13 #include <string.h>
14 #include <base/inc/platform.h>
15 #include <base/inc/base_types.h>
17 #include <base/inc/sdk_ref_ptr.h>
18 #include <base/inc/sdk_uuid.h>
19 
20 SDK_BEGIN_NAMESPACE
21 
22 #ifndef FWD_DECL_INTERFACE
23 #define FWD_DECL_INTERFACE(class_name) \
24  class class_name; \
25  typedef SDK_NAMESPACE::SDKRefPtr< class_name > class_name##SP; \
26  typedef SDK_NAMESPACE::SDKRefPtr< const class_name > class_name##SCP;
27 #endif
28 
35 
37 
42 {
43 public:
45  virtual SDKAtomicRefCount SDK_CALLTYPE AddRef() const throw() = 0;
47  virtual SDKAtomicRefCount SDK_CALLTYPE Release() const throw() = 0;
49  virtual SDKResult SDK_CALLTYPE GetInterface(
50  const InterfaceId& id, void** obj_ptr) throw() = 0;
51 
53  template <typename _Itf>
54  inline SDKResult GetInterface(_Itf **obj_ptr) throw() {
55  return this->GetInterface(_Itf::IID(), (void**)obj_ptr);
56  }
57 
58  SDK_IMPLEMENT_IID(ISDKComponent)
59  SDK_END_INTERFACE(ISDKComponent)
60 };
61 SDK_DECLARE_IID(ISDKComponent)
62 
63 
69 {
70 public:
72  virtual SDKResult SDK_CALLTYPE CreateInstance(
73  SDK_NAMESPACE::SDKComponentSP& obj_instance) const throw() = 0;
75  virtual SDKResult SDK_CALLTYPE LockServer(bool lock) throw() = 0;
76 
77  SDK_IMPLEMENT_IID(ISDKClassFactory)
78  SDK_END_INTERFACE(ISDKClassFactory)
79 };
80 SDK_DECLARE_IID(ISDKClassFactory)
81 
82 /* \internal */
83 
84 template<class T>
85 inline SDK_NAMESPACE::SDKRefPtr<T> GetInterfaceT(void* in) {
86  SDK_NAMESPACE::SDKRefPtr<T> out;
87  if (in) {
88  static_cast<SDK_NAMESPACE::ISDKComponent*>(in)->GetInterface(T::IID(),
89  reinterpret_cast<void**>(&out));
90  }
91  return out;
92 }
93 
94 /* \endinternal */
95 
96 SDK_END_NAMESPACE
97 
98 #endif // SDK_BASE_SDK_OBJECT_INTERFACE_H_
base_types.h
SDK base types.
sdk_ref_ptr.h
Interfaces wrapper with reference count control.
InterfaceId
Uuid InterfaceId
Definition of interface UUID.
Definition: sdk_uuid.h:45
ISDKComponent::GetInterface
SDKResult GetInterface(_Itf **obj_ptr)
Returns pointers to the supported interfaces on a component.
Definition: sdk_component_interface.h:54
ISDKComponent::GetInterface
virtual SDKResult SDK_CALLTYPE GetInterface(const InterfaceId &id, void **obj_ptr)=0
Returns pointers to the supported interfaces on a component.
SDKResult
SDKInt32 SDKResult
Type of all error or return codes which SDK functions can end with.
Definition: sdk_results.h:17
SDKRefPtr
A smart pointer class for managing SDK components interface pointers.
Definition: sdk_ref_ptr.h:23
platform.h
Describes the platform constants.
ISDKComponent
Base interface for all SDK interfaces.
Definition: sdk_component_interface.h:41
ISDKComponent::AddRef
virtual SDKAtomicRefCount SDK_CALLTYPE AddRef() const =0
Increments the reference count for an interface on a component.
sdk_results_enum.h
SDK return values synonyms in the sdk namespace.
FWD_DECL_INTERFACE
FWD_DECL_INTERFACE(ILWEParserWrapper)
Provides a wrapper around the message parser to get, add or remove the.
sdk_uuid.h
Definition of the Universal Unique Identifier.
ISDKComponent::Release
virtual SDKAtomicRefCount SDK_CALLTYPE Release() const =0
Decrements the reference count for an interface on a component.
ISDKClassFactory
Describes the interface that creates a class of components.
Definition: sdk_component_interface.h:68