LibreOffice Module dbaccess (master) 1
odbcconfig.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#pragma once
21
22#if defined(_WIN32) || (defined (UNX) && !defined(ANDROID) && !defined(IOS))
23#define HAVE_ODBC_SUPPORT
24#endif
25
26#if defined(_WIN32) && defined(HAVE_ODBC_SUPPORT)
27#define HAVE_ODBC_ADMINISTRATION
28#endif
29
30#include <rtl/ustring.hxx>
31#include <tools/link.hxx>
32#include <osl/module.h>
33
34#include <memory>
35#include <set>
36
37namespace dbaui
38{
39
40// OOdbcEnumeration
41struct OdbcTypesImpl;
43{
44 oslModule m_pOdbcLib; // the library handle
45 OUString m_sLibPath; // the path to the library
46
47#ifdef HAVE_ODBC_SUPPORT
48 // entry points for ODBC administration
49 oslGenericFunction m_pAllocHandle;
50 oslGenericFunction m_pFreeHandle;
51 oslGenericFunction m_pSetEnvAttr;
52 oslGenericFunction m_pDataSources;
53
54#endif
55 std::unique_ptr<OdbcTypesImpl> m_pImpl;
56 // needed because we can't have a member of type SQLHANDLE: this would require us to include the respective
57 // ODBC file, which would lead to a lot of conflicts with other includes
58
59public:
62
63#ifdef HAVE_ODBC_SUPPORT
64 bool isLoaded() const { return nullptr != m_pOdbcLib; }
65#else
66 bool isLoaded() const { return false; }
67#endif
68 const OUString& getLibraryName() const { return m_sLibPath; }
69
70 void getDatasourceNames(std::set<OUString>& _rNames);
71
72private:
73 oslGenericFunction loadSymbol(const char* _pFunctionName);
74
76 bool load(const char* _pLibPath);
78 void unload();
80 bool allocEnv();
82 void freeEnv();
83};
84
85// OOdbcManagement
86#ifdef HAVE_ODBC_ADMINISTRATION
87class ProcessTerminationWait;
88class OOdbcManagement
89{
90 std::unique_ptr< ProcessTerminationWait > m_pProcessWait;
91 Link<void*,void> m_aAsyncFinishCallback;
92
93public:
94 explicit OOdbcManagement( const Link<void*,void>& _rAsyncFinishCallback );
95 ~OOdbcManagement();
96
97 bool manageDataSources_async();
98 bool isRunning() const;
99 void disableCallback();
100 void receivedCallback();
101};
102#endif
103
104} // namespace dbaui
105
106/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void freeEnv()
free any allocated ODBC environment
Definition: odbcconfig.cxx:175
void unload()
unload the lib
Definition: odbcconfig.cxx:80
std::unique_ptr< OdbcTypesImpl > m_pImpl
Definition: odbcconfig.hxx:55
const OUString & getLibraryName() const
Definition: odbcconfig.hxx:68
void getDatasourceNames(std::set< OUString > &_rNames)
Definition: odbcconfig.cxx:184
oslGenericFunction loadSymbol(const char *_pFunctionName)
Definition: odbcconfig.cxx:91
oslGenericFunction m_pDataSources
Definition: odbcconfig.hxx:52
bool allocEnv()
ensure that an ODBC environment is allocated
Definition: odbcconfig.cxx:153
oslGenericFunction m_pFreeHandle
Definition: odbcconfig.hxx:50
bool load(const char *_pLibPath)
load the lib
Definition: odbcconfig.cxx:68
oslGenericFunction m_pAllocHandle
Definition: odbcconfig.hxx:49
oslGenericFunction m_pSetEnvAttr
Definition: odbcconfig.hxx:51