Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

117 lines
4.1 KiB

  1. // ACntrKey.cpp -- Adaptive CoNTaineR Key class implementation
  2. // (c) Copyright Schlumberger Technology Corp., unpublished work, created
  3. // 1999. This computer program includes Confidential, Proprietary
  4. // Information and is a Trade Secret of Schlumberger Technology Corp. All
  5. // use, disclosure, and/or reproduction is prohibited unless authorized
  6. // in writing. All Rights Reserved.
  7. #include "NoWarning.h"
  8. #include "ForceLib.h"
  9. #include "ACntrKey.h"
  10. using namespace std;
  11. /////////////////////////// LOCAL/HELPER /////////////////////////////////
  12. /////////////////////////// PUBLIC /////////////////////////////////
  13. // Types
  14. // C'tors/D'tors
  15. HAdaptiveContainerKey::HAdaptiveContainerKey(AdaptiveContainerKey *pcntrk)
  16. : slbRefCnt::RCPtr<AdaptiveContainerKey>(pcntrk)
  17. {}
  18. // Types
  19. // C'tors/D'tors
  20. // Types
  21. // C'tors/D'tors
  22. AdaptiveContainerKey::AdaptiveContainerKey(HCardContext const &rhcardctx,
  23. string const &rsContainerName)
  24. : m_hcardctx(rhcardctx),
  25. m_sContainerName(rsContainerName)
  26. {}
  27. AdaptiveContainerKey::~AdaptiveContainerKey()
  28. {}
  29. // Operators
  30. bool
  31. AdaptiveContainerKey::operator==(AdaptiveContainerKey const &rhs) const
  32. {
  33. int iComparison = m_sContainerName.compare(rhs.m_sContainerName);
  34. if (0 == iComparison)
  35. {
  36. if(m_hcardctx && rhs.m_hcardctx)
  37. iComparison =
  38. m_hcardctx->Card()->ReaderName().compare(rhs.m_hcardctx->Card()->ReaderName());
  39. else if(m_hcardctx != rhs.m_hcardctx)
  40. iComparison = -1;
  41. }
  42. return iComparison == 0;
  43. }
  44. bool
  45. AdaptiveContainerKey::operator<(AdaptiveContainerKey const &rhs) const
  46. {
  47. int iComparison = m_sContainerName.compare(rhs.m_sContainerName);
  48. if (0 == iComparison)
  49. {
  50. if(m_hcardctx && rhs.m_hcardctx)
  51. iComparison =
  52. m_hcardctx->Card()->ReaderName().compare(rhs.m_hcardctx->Card()->ReaderName());
  53. //We are comparing keys of expired containers, i.e.
  54. //keys with null CardCtx. Such keys exist when a card gets
  55. //removed from the reader. They are maintained to enable the
  56. //reconnect logic. In cases like this we must preserve the
  57. //ordering of the elements in the collection: a key with null
  58. //card context is less than a key with defined context.
  59. else if(!m_hcardctx && rhs.m_hcardctx)
  60. iComparison = -1;
  61. }
  62. return iComparison < 0;
  63. }
  64. // Operations
  65. // Access
  66. HCardContext
  67. AdaptiveContainerKey::CardContext() const
  68. {
  69. return m_hcardctx;
  70. }
  71. void
  72. AdaptiveContainerKey::ClearCardContext()
  73. {
  74. m_hcardctx = 0;
  75. }
  76. std::string
  77. AdaptiveContainerKey::ContainerName() const
  78. {
  79. return m_sContainerName;
  80. }
  81. // Predicates
  82. // Static Variables
  83. /////////////////////////// PROTECTED /////////////////////////////////
  84. // C'tors/D'tors
  85. // Operators
  86. // Operations
  87. // Access
  88. // Predicates
  89. // Static Variables
  90. /////////////////////////// PRIVATE /////////////////////////////////
  91. // C'tors/D'tors
  92. // Operators
  93. // Operations
  94. // Access
  95. // Predicates
  96. // Static Variables