1// Licensed to the .NET Foundation under one or more agreements.
2// The .NET Foundation licenses this file to you under the MIT license.
3// See the LICENSE file in the project root for more information.
4// ============================================================
5//
6// FailureCache.hpp
7//
8
9
10//
11// Defines the FailureCache class
12//
13// ============================================================
14
15#ifndef __BINDER__FAILURE_CACHE_HASH_TRAITS_HPP__
16#define __BINDER__FAILURE_CACHE_HASH_TRAITS_HPP__
17
18#include "bindertypes.hpp"
19#include "utils.hpp"
20#include "sstring.h"
21#include "shash.h"
22
23namespace BINDER_SPACE
24{
25 class FailureCacheEntry
26 {
27 public:
28 inline FailureCacheEntry()
29 {
30 m_hrBindingResult = S_OK;
31 }
32 inline ~FailureCacheEntry()
33 {
34 // Nothing to do here
35 }
36
37 // Getters/Setters
38 inline SString &GetAssemblyNameOrPath()
39 {
40 return m_assemblyNameOrPath;
41 }
42 inline HRESULT GetBindingResult()
43 {
44 return m_hrBindingResult;
45 }
46 inline void SetBindingResult(HRESULT hrBindingResult)
47 {
48 m_hrBindingResult = hrBindingResult;
49 }
50
51 protected:
52 SString m_assemblyNameOrPath;
53 HRESULT m_hrBindingResult;
54 };
55
56 class FailureCacheHashTraits : public DefaultSHashTraits<FailureCacheEntry *>
57 {
58 public:
59 typedef SString& key_t;
60
61 // GetKey, Equals, and Hash can throw due to SString
62 static const bool s_NoThrow = false;
63
64 static key_t GetKey(element_t pFailureCacheEntry)
65 {
66 return pFailureCacheEntry->GetAssemblyNameOrPath();
67 }
68 static BOOL Equals(key_t pAssemblyNameOrPath1, key_t pAssemblyNameOrPath2)
69 {
70 return EqualsCaseInsensitive(pAssemblyNameOrPath1, pAssemblyNameOrPath2);
71 }
72 static count_t Hash(key_t pAssemblyNameOrPath)
73 {
74 return HashCaseInsensitive(pAssemblyNameOrPath);
75 }
76 static element_t Null()
77 {
78 return NULL;
79 }
80 static bool IsNull(const element_t &propertyEntry)
81 {
82 return (propertyEntry == NULL);
83 }
84
85 };
86};
87
88#endif
89