1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef nsHashPropertyBag_h___
8 #define nsHashPropertyBag_h___
10 #include "nsIVariant.h"
11 #include "nsIWritablePropertyBag.h"
12 #include "nsIWritablePropertyBag2.h"
14 #include "nsCycleCollectionParticipant.h"
15 #include "nsInterfaceHashtable.h"
17 class nsHashPropertyBagBase
: public nsIWritablePropertyBag
,
18 public nsIWritablePropertyBag2
{
20 nsHashPropertyBagBase() = default;
22 void CopyFrom(const nsHashPropertyBagBase
* aOther
);
23 void CopyFrom(nsIPropertyBag
* aOther
);
24 static void CopyFrom(nsIWritablePropertyBag
* aTo
, nsIPropertyBag
* aFrom
);
26 NS_DECL_NSIPROPERTYBAG
27 NS_DECL_NSIPROPERTYBAG2
29 NS_DECL_NSIWRITABLEPROPERTYBAG
30 NS_DECL_NSIWRITABLEPROPERTYBAG2
33 // a hash table of string -> nsIVariant
34 nsInterfaceHashtable
<nsStringHashKey
, nsIVariant
> mPropertyHash
;
37 class nsHashPropertyBag
: public nsHashPropertyBagBase
{
39 nsHashPropertyBag() = default;
40 NS_DECL_THREADSAFE_ISUPPORTS
43 virtual ~nsHashPropertyBag();
46 /* A cycle collected nsHashPropertyBag for main-thread-only use. */
47 class nsHashPropertyBagCC final
: public nsHashPropertyBagBase
{
49 nsHashPropertyBagCC() = default;
50 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
51 NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsHashPropertyBagCC
,
52 nsIWritablePropertyBag
)
54 virtual ~nsHashPropertyBagCC() = default;
57 inline nsISupports
* ToSupports(nsHashPropertyBagBase
* aPropertyBag
) {
58 return static_cast<nsIWritablePropertyBag
*>(aPropertyBag
);
61 #endif /* nsHashPropertyBag_h___ */