]>
git.saurik.com Git - apple/security.git/blob - OSX/libsecurity_utilities/lib/adornments.cpp
2 * Copyright (c) 2000-2001,2003-2004,2011,2014 Apple Inc. All Rights Reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
26 // adornment - generic attached-storage facility
28 #include "adornments.h"
29 #include <security_utilities/utilities.h>
30 #include <security_utilities/debugging.h>
37 // Adornment needs a virtual destructor for safe deletion.
39 Adornment::~Adornment()
44 // Adornable deletes all pointed-to objects when it dies.
46 Adornable::~Adornable()
53 // Primitive (non-template) adornment operations
55 Adornment
*Adornable::getAdornment(Key key
) const
58 AdornmentMap::const_iterator it
= mAdornments
->find(key
);
59 return (it
== mAdornments
->end()) ? NULL
: it
->second
;
64 void Adornable::setAdornment(Key key
, Adornment
*ad
)
66 Adornment
*&slot
= adornmentSlot(key
);
71 Adornment
*Adornable::swapAdornment(Key key
, Adornment
*ad
)
73 std::swap(ad
, adornmentSlot(key
));
77 Adornment
*&Adornable::adornmentSlot(Key key
)
80 mAdornments
= new AdornmentMap
;
81 return (*mAdornments
)[key
];
84 void Adornable::clearAdornments()
87 for_each_map_delete(mAdornments
->begin(), mAdornments
->end());
93 } // end namespace Security