fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / include / tools / unqidx.hxx
blob3a3ba979d0927053e2d9f667881ee4d86a855c08
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef _UNQIDX_HXX
20 #define _UNQIDX_HXX
22 #include "tools/toolsdllapi.h"
23 #include <tools/solar.h>
24 #include <tools/contnr.hxx>
25 #include <map>
27 #define UNIQUEINDEX_ENTRY_NOTFOUND CONTAINER_ENTRY_NOTFOUND
29 class TOOLS_DLLPUBLIC SAL_WARN_UNUSED UniqueIndexImpl : public std::map<sal_uInt32, void*>
31 private:
32 sal_uIntPtr nStartIndex;
33 sal_uIntPtr nUniqIndex;
34 sal_uIntPtr nCount;
36 public:
37 UniqueIndexImpl( sal_uIntPtr _nStartIndex = 0 )
38 : std::map<sal_uInt32, void*>(),
39 nStartIndex(_nStartIndex), nUniqIndex(_nStartIndex), nCount(0) {}
41 sal_uIntPtr Insert( void* p );
42 // insert value with key, replacing existing entry if necessary
43 void Insert( sal_uIntPtr aIndex, void* p );
44 void* Remove( sal_uIntPtr aIndex );
45 void* Get( sal_uIntPtr aIndex ) const;
47 sal_uIntPtr GetIndexOf( void* p ) const;
48 sal_uIntPtr FirstIndex() const;
49 sal_uIntPtr LastIndex() const;
50 sal_uIntPtr NextIndex( sal_uIntPtr aCurrIndex ) const;
53 template<typename T>
54 class UniqueIndex : private UniqueIndexImpl
56 public:
57 UniqueIndex<T>( sal_uIntPtr _nStartIndex = 0 ) : UniqueIndexImpl(_nStartIndex) {}
59 sal_uIntPtr Insert(T* p) { return UniqueIndexImpl::Insert(p); }
60 void Insert(sal_uIntPtr aIdx, T* p) { return UniqueIndexImpl::Insert(aIdx, p); }
61 T* Get(sal_uIntPtr idx) const { return static_cast<T*>( UniqueIndexImpl::Get(idx) ); }
62 T* Remove(sal_uIntPtr idx) { return static_cast<T*>( UniqueIndexImpl::Remove(idx) ); }
63 sal_uIntPtr Count() const { return UniqueIndexImpl::size(); }
64 sal_uIntPtr GetIndexOf(T* p) const { return UniqueIndexImpl::GetIndexOf(p); }
66 using UniqueIndexImpl::FirstIndex;
67 using UniqueIndexImpl::LastIndex;
68 using UniqueIndexImpl::NextIndex;
71 #endif
73 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */