Leaked source code of windows server 2003
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.

70 lines
1.5 KiB

  1. // ArchivedValue.h: interface for the CArchivedValue class.
  2. //
  3. // (c) Copyright Schlumberger Technology Corp., unpublished work, created
  4. // 1999. This computer program includes Confidential, Proprietary
  5. // Information and is a Trade Secret of Schlumberger Technology Corp. All
  6. // use, disclosure, and/or reproduction is prohibited unless authorized
  7. // in writing. All Rights Reserved.
  8. //////////////////////////////////////////////////////////////////////
  9. #if !defined(CCI_ARCHIVED_VALUE_H)
  10. #define CCI_ARCHIVED_VALUE_H
  11. #include "cciExc.h"
  12. namespace cci
  13. {
  14. template<class T>
  15. class CArchivedValue
  16. {
  17. public:
  18. CArchivedValue() : m_fIsCached(false) {};
  19. virtual ~CArchivedValue() {};
  20. bool IsCached() const
  21. {
  22. return m_fIsCached;
  23. };
  24. void Value(T const &rhs)
  25. {
  26. m_Value = rhs;
  27. m_fIsCached = true;
  28. };
  29. T Value()
  30. {
  31. if (!m_fIsCached)
  32. throw Exception(ccValueNotCached);
  33. return m_Value;
  34. };
  35. void Dirty()
  36. {
  37. m_fIsCached = false;
  38. }
  39. bool
  40. operator==(CArchivedValue<T> const &rhs) const
  41. {
  42. return (m_fIsCached == rhs.m_fIsCached) &&
  43. (m_Value == rhs.m_Value);
  44. }
  45. bool
  46. operator!=(CArchivedValue<T> const &rhs) const
  47. {
  48. return !(rhs == *this);
  49. }
  50. private:
  51. bool m_fIsCached;
  52. T m_Value;
  53. };
  54. } // namespace cci
  55. #endif // !defined(CCI_ARCHIVED_VALUE_H)