composite.C 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. /*
  2. * CDE - Common Desktop Environment
  3. *
  4. * Copyright (c) 1993-2012, The Open Group. All rights reserved.
  5. *
  6. * These libraries and programs are free software; you can
  7. * redistribute them and/or modify them under the terms of the GNU
  8. * Lesser General Public License as published by the Free Software
  9. * Foundation; either version 2 of the License, or (at your option)
  10. * any later version.
  11. *
  12. * These libraries and programs are distributed in the hope that
  13. * they will be useful, but WITHOUT ANY WARRANTY; without even the
  14. * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  15. * PURPOSE. See the GNU Lesser General Public License for more
  16. * details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with these libraries and programs; if not, write
  20. * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
  21. * Floor, Boston, MA 02110-1301 USA
  22. */
  23. /*
  24. * $XConsortium: composite.cc /main/5 1996/07/18 14:40:37 drk $
  25. *
  26. * Copyright (c) 1993 HAL Computer Systems International, Ltd.
  27. * All rights reserved. Unpublished -- rights reserved under
  28. * the Copyright Laws of the United States. USE OF A COPYRIGHT
  29. * NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
  30. * OR DISCLOSURE.
  31. *
  32. * THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
  33. * SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
  34. * DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
  35. * PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
  36. * INTERNATIONAL, LTD.
  37. *
  38. * RESTRICTED RIGHTS LEGEND
  39. * Use, duplication, or disclosure by the Government is subject
  40. * to the restrictions as set forth in subparagraph (c)(l)(ii)
  41. * of the Rights in Technical Data and Computer Software clause
  42. * at DFARS 252.227-7013.
  43. *
  44. * HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
  45. * 1315 Dell Avenue
  46. * Campbell, CA 95008
  47. *
  48. */
  49. #include "object/composite.h"
  50. composite::composite(c_code_t c_id) : root(c_id)
  51. {
  52. //init_persistent_info();
  53. v_sz = 0;
  54. }
  55. composite::composite(const composite& x) : root(x)
  56. {
  57. //init_persistent_info();
  58. v_sz = x.v_sz;
  59. }
  60. int composite::first() const
  61. {
  62. if ( v_sz == 0 )
  63. return 0;
  64. else
  65. return 1;
  66. }
  67. void composite::next(int& index) const
  68. {
  69. if INRANGE( index, 1, (int) v_sz - 1 )
  70. index ++;
  71. else
  72. index = 0;
  73. }
  74. handler* composite::get_component(int)
  75. {
  76. throw(stringException("composite::get_component() can't be called"));
  77. return 0;
  78. }
  79. void composite::set_mode(obj_mode_t mode, Boolean option)
  80. {
  81. root::set_mode(mode, option);
  82. }
  83. Boolean composite::test_io_mode(int mode)
  84. {
  85. if ( storage_ptr )
  86. return storage_ptr -> io_mode(mode);
  87. else
  88. return false;
  89. }
  90. int composite::cdr_sizeof()
  91. {
  92. return root::cdr_sizeof() + sizeof(v_sz);
  93. }
  94. io_status composite::cdrOut(buffer& buf)
  95. {
  96. root::cdrOut(buf);
  97. buf.put(v_sz);
  98. return done;
  99. }
  100. io_status composite::cdrIn(buffer& buf)
  101. {
  102. root::cdrIn(buf);
  103. buf.get(v_sz);
  104. return done;
  105. }
  106. MMDB_BODIES(composite)
  107. NEW_AND_DELETE_BODIES(composite)
  108. composite_handler::composite_handler(const oid_t& v_oid, storagePtr _store):
  109. handler(v_oid, _store)
  110. {
  111. }
  112. composite_handler::~composite_handler()
  113. {
  114. }
  115. composite* composite_handler::operator ->()
  116. {
  117. return (composite*)handler::operator->();
  118. }
  119. handler* composite_handler::_get_component(int i)
  120. {
  121. handler* x = 0;
  122. if ( i == THIS )
  123. x = this;
  124. else {
  125. x = ((composite*)handler::operator->()) -> get_component(i);
  126. }
  127. if ( x == 0 )
  128. throw(stringException("NULL component handler ptr"));
  129. return x;
  130. }