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.

194 lines
5.4 KiB

  1. // CV2DataObj.cpp: implementation of the CV2DataObject 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. #include "NoWarning.h"
  10. #include <scuCast.h>
  11. #include "TransactionWrap.h"
  12. #include "V2DataObj.h"
  13. #include "DataObjectInfoRecord.h"
  14. using namespace std;
  15. using namespace cci;
  16. /////////////////////////// LOCAL/HELPER /////////////////////////////////
  17. /////////////////////////// PUBLIC /////////////////////////////////
  18. // Types
  19. // C'tors/D'tors
  20. CV2DataObject::CV2DataObject(CV2Card const &rv2card,
  21. ObjectAccess oa)
  22. : CAbstractDataObject(rv2card, oa),
  23. m_sidHandle(0),
  24. m_apcir()
  25. {
  26. // Allocate new entry in object info file
  27. m_sidHandle =
  28. rv2card.ObjectInfoFile(oa).AddObject(otDataObjectObject,
  29. DataInfoRecordSize);
  30. Setup(rv2card);
  31. m_apcir->Clear();
  32. m_apcir->Write();
  33. }
  34. CV2DataObject::CV2DataObject(CV2Card const &rv2card,
  35. SymbolID sidHandle,
  36. ObjectAccess oa)
  37. : CAbstractDataObject(rv2card, oa),
  38. m_sidHandle(sidHandle),
  39. m_apcir()
  40. {
  41. Setup(rv2card);
  42. }
  43. CV2DataObject::~CV2DataObject() throw()
  44. {}
  45. // Operators
  46. // Operations
  47. void
  48. CV2DataObject::Application(std::string const &rstr)
  49. {
  50. m_apcir->Symbol(&m_apcir->m_bApplication, rstr);
  51. }
  52. void
  53. CV2DataObject::Label(string const &rstrLabel)
  54. {
  55. m_apcir->Symbol(&m_apcir->m_bLabel, rstrLabel);
  56. }
  57. void
  58. CV2DataObject::Modifiable(bool flag)
  59. {
  60. m_apcir->Flag(DataModifiableFlag,flag);
  61. }
  62. CV2DataObject *
  63. CV2DataObject::Make(CV2Card const &rv2card,
  64. SymbolID sidHandle,
  65. ObjectAccess oa)
  66. {
  67. return new CV2DataObject(rv2card, sidHandle, oa);
  68. }
  69. // Access
  70. string
  71. CV2DataObject::Application()
  72. {
  73. return m_apcir->Symbol(&m_apcir->m_bApplication);
  74. }
  75. SymbolID
  76. CV2DataObject::Handle()
  77. {
  78. return m_sidHandle;
  79. }
  80. string
  81. CV2DataObject::Label()
  82. {
  83. return m_apcir->Symbol(&m_apcir->m_bLabel);
  84. }
  85. bool
  86. CV2DataObject::Modifiable()
  87. {
  88. return m_apcir->Flag(DataModifiableFlag);
  89. }
  90. bool
  91. CV2DataObject::Private()
  92. {
  93. return m_apcir->Private();
  94. }
  95. // Predicates
  96. // Static Variables
  97. /////////////////////////// PROTECTED /////////////////////////////////
  98. // C'tors/D'tors
  99. // Operators
  100. // Operations
  101. void
  102. CV2DataObject::DoDelete()
  103. {
  104. CV2Card &rv2card = scu::DownCast<CV2Card &, CAbstractCard &>(*Card());
  105. CObjectInfoFile &roif = rv2card.ObjectInfoFile(m_oa);
  106. m_apcir->Read();
  107. if (m_apcir->m_bLabel)
  108. roif.RemoveSymbol(m_apcir->m_bLabel);
  109. if (m_apcir->m_bApplication)
  110. roif.RemoveSymbol(m_apcir->m_bApplication);
  111. if (m_apcir->m_bValue)
  112. roif.RemoveSymbol(m_apcir->m_bValue);
  113. roif.RemoveObject(otDataObjectObject, m_sidHandle);
  114. }
  115. void
  116. CV2DataObject::DoValue(ZipCapsule const &rzc)
  117. {
  118. m_apcir->Read();
  119. m_apcir->m_bCompressAlg = rzc.IsCompressed();
  120. m_apcir->Symbol(&m_apcir->m_bValue, rzc.Data());
  121. m_apcir->Write();
  122. }
  123. // Access
  124. CV2DataObject::ZipCapsule
  125. CV2DataObject::DoValue()
  126. {
  127. m_apcir->Read();
  128. return ZipCapsule(m_apcir->Symbol(&m_apcir->m_bValue),
  129. ((0 != m_apcir->m_bValue) && // nils are not compressed
  130. (1 == m_apcir->m_bCompressAlg)));
  131. }
  132. // Predicates
  133. bool
  134. CV2DataObject::DoEquals(CAbstractDataObject const &rhs) const
  135. {
  136. CV2DataObject const &rv2rhs =
  137. scu::DownCast<CV2DataObject const &, CAbstractDataObject const &>(rhs);
  138. return rv2rhs.m_sidHandle == m_sidHandle;
  139. }
  140. // Static Variables
  141. /////////////////////////// PRIVATE /////////////////////////////////
  142. // C'tors/D'tors
  143. // Operators
  144. // Operations
  145. void
  146. CV2DataObject::Setup(CV2Card const &rv2card)
  147. {
  148. m_apcir =
  149. auto_ptr<CDataObjectInfoRecord>(new CDataObjectInfoRecord(rv2card,
  150. m_sidHandle,
  151. m_oa));
  152. }
  153. // Access
  154. // Predicates
  155. // Static Variables