-
Notifications
You must be signed in to change notification settings - Fork 126
/
DbModule.cpp
111 lines (101 loc) · 3.23 KB
/
DbModule.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/*
* Copyright (C) 2010-2015 Nektra S.A., Buenos Aires, Argentina.
* All rights reserved. Contact: http://www.nektra.com
*
*
* This file is part of Deviare
*
*
* Commercial License Usage
* ------------------------
* Licensees holding valid commercial Deviare licenses may use this file
* in accordance with the commercial license agreement provided with the
* Software or, alternatively, in accordance with the terms contained in
* a written agreement between you and Nektra. For licensing terms and
* conditions see http://www.nektra.com/licensing/. Use the contact form
* at http://www.nektra.com/contact/ for further information.
*
*
* GNU General Public License Usage
* --------------------------------
* Alternatively, this file may be used under the terms of the GNU General
* Public License version 3.0 as published by the Free Software Foundation
* and appearing in the file LICENSE.GPL included in the packaging of this
* file. Please visit http://www.gnu.org/copyleft/gpl.html and review the
* information to ensure the GNU General Public License version 3.0
* requirements will be met.
*
**/
#include "StdAfx.h"
#include "DbModule.h"
#include "DbObjectsEnum.h"
//-----------------------------------------------------------
#ifdef NKT_ENABLE_MEMORY_TRACKING
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif //NKT_ENABLE_MEMORY_TRACKING
//-----------------------------------------------------------
// CNktDbModuleImpl
HRESULT CNktDbModuleImpl::get_Id(__deref_out LONG *pVal)
{
HRESULT hRes;
if (pVal == NULL)
return SetupErrorInfoAndReturn(E_POINTER);
//check internal object
get_InterfaceError(&hRes);
if (FAILED(hRes))
{
*pVal = 0;
return SetupPermanentErrorInfoAndReturn();
}
//get count
*pVal = (LONG)(lpIntObj->GetObj()->GetId());
return SetupErrorInfoAndReturn(S_OK);
}
HRESULT CNktDbModuleImpl::get_Name(__deref_out BSTR *pVal)
{
CNktComBStr cComBStr;
HRESULT hRes;
if (pVal == NULL)
return SetupErrorInfoAndReturn(E_POINTER);
//check internal object
get_InterfaceError(&hRes);
if (SUCCEEDED(hRes))
{
//get name
hRes = cComBStr.Set(lpIntObj->GetObj()->GetName());
}
if (FAILED(hRes) && IsFatalHResult(hRes) == FALSE)
{
if (FAILED(cComBStr.Set(L"")))
hRes = E_OUTOFMEMORY;
}
*pVal = cComBStr.Detach();
return SetupErrorInfoAndReturn(hRes);
}
HRESULT CNktDbModuleImpl::DbFunctions(__deref_out INktDbObjectsEnum **ppDbObjsEnum)
{
TNktComPtr<CNktDvDbModuleWrapper> lpIntObj;
TNktComPtr<CNktDvDbObjectsEnumerator> cDbObjsEnum;
TNktComPtr<INktDbObjectsEnum> cIDbObjsEnum;
HRESULT hRes;
if (ppDbObjsEnum == NULL)
return SetupErrorInfoAndReturn(E_POINTER);
//check internal object
get_InterfaceError(&hRes);
if (SUCCEEDED(hRes))
{
//get function return
hRes = lpIntObj->GetObj()->GetFunctions(&cDbObjsEnum);
}
if (SUCCEEDED(hRes))
{
//get outer interface
hRes = GetComLinkHelper<CNktDbObjectsEnumImpl,INktDbObjectsEnum,
CNktDvDbObjectsEnumerator>(&cIDbObjsEnum, cDbObjsEnum,
InterfaceItemGetCookies());
}
//done (don't create dummy interface on error)
*ppDbObjsEnum = cIDbObjsEnum.Detach();
return SetupErrorInfoAndReturn(hRes);
}