]>
git.saurik.com Git - apple/security.git/blob - libsecurity_cdsa_client/lib/multidldb.h
2 * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved.
4 * The contents of this file constitute Original Code as defined in and are
5 * subject to the Apple Public Source License Version 1.2 (the 'License').
6 * You may not use this file except in compliance with the License. Please obtain
7 * a copy of the License at http://www.apple.com/publicsource and read it before
10 * This Original Code and all software distributed under the License are
11 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS
12 * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT
13 * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the
15 * specific language governing rights and limitations under the License.
20 // multidldb interfaces for searching multiple dls or db with a single cursor.
22 #ifndef _H_CDSA_CLIENT_MULTIDLDB
23 #define _H_CDSA_CLIENT_MULTIDLDB 1
25 #include <security_cdsa_client/dlclient.h>
26 #include <security_cdsa_client/DLDBList.h>
35 // The MultiDLDb class.
37 class MultiDLDbImpl
: public ObjectImpl
, public DbCursorMaker
40 struct List
: public vector
<DLDbIdentifier
>, public RefCount
42 List(const vector
<DLDbIdentifier
> &list
) : vector
<DLDbIdentifier
>(list
) {}
45 struct ListRef
: public RefPointer
<List
>
48 ListRef(const vector
<DLDbIdentifier
> &list
) : RefPointer
<List
>(new List(list
)) {}
51 MultiDLDbImpl(const vector
<DLDbIdentifier
> &list
, bool useSecureStorage
, const Cssm
&cssm
);
52 MultiDLDbImpl(const vector
<DLDbIdentifier
> &list
, bool useSecureStorage
);
53 virtual ~MultiDLDbImpl();
55 Cssm
cssm() const { return parent
<Cssm
>(); }
56 Db
database(const DLDbIdentifier
&dlDbIdentifier
);
57 ListRef
listRef() { return mListRef
; }
58 void list(const vector
<DLDbIdentifier
> &list
);
59 const vector
<DLDbIdentifier
> &list() { return *mListRef
; }
62 virtual DbCursorImpl
*newDbCursor(const CSSM_QUERY
&query
, Allocator
&allocator
);
63 virtual DbCursorImpl
*newDbCursor(uint32 capacity
, Allocator
&allocator
);
70 typedef map
<DLDbIdentifier
, Db
> DbMap
;
72 // Lock protecting this object during changes.
76 bool mUseSecureStorage
;
79 class MultiDLDb
: public Object
82 typedef MultiDLDbImpl Impl
;
84 explicit MultiDLDb(Impl
*impl
) : Object(impl
) {}
85 MultiDLDb(const vector
<DLDbIdentifier
> &list
, bool useSecureStorage
, const Cssm
&cssm
)
86 : Object(new Impl(list
, useSecureStorage
, cssm
)) {}
87 MultiDLDb(const vector
<DLDbIdentifier
> &list
, bool useSecureStorage
)
88 : Object(new Impl(list
, useSecureStorage
)) {}
90 Impl
*operator ->() const { return &impl
<Impl
>(); }
91 Impl
&operator *() const { return impl
<Impl
>(); }
93 // Conversion to DbCursorMaker
94 operator DbCursorMaker
&() { return impl
<Impl
>(); }
97 }; // end namespace CssmClient
99 } // end namespace Security
101 #endif // _H_CDSA_CLIENT_MULTIDLDB