oid_t.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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: oid_t.h /main/6 1996/08/21 15:52:31 drk $
  25. *
  26. * Copyright (c) 1992 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. #ifndef _oid_t_h
  50. #define _oid_t_h 1
  51. #ifdef C_API
  52. #include "utility/c_stringstream.h"
  53. #else
  54. #include <sstream>
  55. #endif
  56. #include "utility/funcs.h"
  57. #include "utility/buffer.h"
  58. typedef unsigned short e_code_t;
  59. typedef unsigned short c_code_t;
  60. typedef mmdb_pos_t i_code_t;
  61. #define OID_T_SZ (sizeof(i_code_t))
  62. /*************************************
  63. // class code root
  64. **************************************/
  65. class oid_t
  66. {
  67. public:
  68. oid_t() : v_c_code(0), v_i_code(0), v_e_code(0) {};
  69. oid_t(c_code_t c, i_code_t i) : v_c_code(c), v_i_code(i), v_e_code(0) {};
  70. oid_t(const char* source, Boolean ascii_format, Boolean swap_order);
  71. oid_t(const oid_t& x) :
  72. v_c_code(x.v_c_code), v_i_code(x.v_i_code), v_e_code(x.v_e_code) {};
  73. ~oid_t() {};
  74. // oid_t equal and less test
  75. Boolean eq(const oid_t&) const;
  76. Boolean ls(const oid_t&) const;
  77. bool operator==(const oid_t& arg) const { return eq(arg); };
  78. // class code, oid type and instance code export functions
  79. const c_code_t ccode() const { return v_c_code; } ;
  80. const i_code_t& icode() const { return v_i_code; } ;
  81. static unsigned hash(const oid_t&);
  82. // in/out functions
  83. io_status asciiIn(istream&) ;
  84. io_status asciiOut(ostream&) const;
  85. io_status _asciiIn(istream&) ; // a version of asciiIn that does not
  86. // eat the trailing '\n'
  87. friend ostream& operator<<(ostream&, const oid_t&) ;
  88. // compacted disk representation In and Out functions
  89. int cdr_sizeof();
  90. io_status cdrOut(buffer&);
  91. io_status cdrIn(buffer&, c_code_t c_code_to_use = 0);
  92. // out to char strings
  93. void to_char_string(char* sink, Boolean swap_order) const;
  94. friend class root;
  95. friend class oid;
  96. friend class desc;
  97. friend class dl_list_cell;
  98. friend class dl_list;
  99. friend class compressed_pstring;
  100. friend class service_mgr_t;
  101. friend class storage_mgr_t;
  102. friend class handler;
  103. friend class smart_ptr;
  104. friend class template_mgr_t;
  105. protected:
  106. void become(const oid_t& x) {
  107. v_e_code = x.v_e_code;
  108. v_c_code = x.v_c_code;
  109. v_i_code = x.v_i_code;
  110. };
  111. void set_c_code(c_code_t c) {
  112. v_c_code = c;
  113. }
  114. void set_i_code(i_code_t i) {
  115. v_i_code = i;
  116. }
  117. void set_e_code(e_code_t e) {
  118. v_e_code = e;
  119. }
  120. protected:
  121. c_code_t v_c_code; // class code
  122. i_code_t v_i_code; // instance code
  123. e_code_t v_e_code; // extended code. Not used within this class.
  124. // for using extra space purpose.
  125. };
  126. typedef oid_t* oid_tPtr;
  127. #ifdef C_API
  128. extern oid_t* ground_ptr;
  129. #define ground (*ground_ptr)
  130. #else
  131. extern oid_t ground;
  132. #endif
  133. #endif