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.

166 lines
6.6 KiB

  1. /* /////////////////////////////////////////////////////////////////////////
  2. * File: stlsoft/obsolete/inheritance_disambiguator.hpp
  3. *
  4. * Purpose: Class to disambiguate between parent classes of same type.
  5. *
  6. * Created: 1st September 2002
  7. * Updated: 10th August 2009
  8. *
  9. * Home: http://stlsoft.org/
  10. *
  11. * Copyright (c) 2002-2009, Matthew Wilson and Synesis Software
  12. * All rights reserved.
  13. *
  14. * Redistribution and use in source and binary forms, with or without
  15. * modification, are permitted provided that the following conditions are met:
  16. *
  17. * - Redistributions of source code must retain the above copyright notice, this
  18. * list of conditions and the following disclaimer.
  19. * - Redistributions in binary form must reproduce the above copyright notice,
  20. * this list of conditions and the following disclaimer in the documentation
  21. * and/or other materials provided with the distribution.
  22. * - Neither the name(s) of Matthew Wilson and Synesis Software nor the names of
  23. * any contributors may be used to endorse or promote products derived from
  24. * this software without specific prior written permission.
  25. *
  26. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  27. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  28. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  29. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  30. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  31. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  32. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  33. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  34. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  35. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  36. * POSSIBILITY OF SUCH DAMAGE.
  37. *
  38. * ////////////////////////////////////////////////////////////////////// */
  39. /// \file stlsoft/obsolete/inheritance_disambiguator.hpp
  40. ///
  41. /// Class to disambiguate between parent classes of same type.
  42. #ifndef STLSOFT_INCL_STLSOFT_OBSOLETE_HPP_INHERITANCE_DISAMBIGUATOR
  43. #define STLSOFT_INCL_STLSOFT_OBSOLETE_HPP_INHERITANCE_DISAMBIGUATOR
  44. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  45. # define STLSOFT_VER_STLSOFT_OBSOLETE_HPP_INHERITANCE_DISAMBIGUATOR_MAJOR 3
  46. # define STLSOFT_VER_STLSOFT_OBSOLETE_HPP_INHERITANCE_DISAMBIGUATOR_MINOR 1
  47. # define STLSOFT_VER_STLSOFT_OBSOLETE_HPP_INHERITANCE_DISAMBIGUATOR_REVISION 1
  48. # define STLSOFT_VER_STLSOFT_OBSOLETE_HPP_INHERITANCE_DISAMBIGUATOR_EDIT 25
  49. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  50. /* /////////////////////////////////////////////////////////////////////////
  51. * Includes
  52. */
  53. #ifndef STLSOFT_INCL_STLSOFT_H_STLSOFT
  54. # include <stlsoft/stlsoft.h>
  55. #endif /* !STLSOFT_INCL_STLSOFT_H_STLSOFT */
  56. /* /////////////////////////////////////////////////////////////////////////
  57. * Namespace
  58. */
  59. #ifndef _STLSOFT_NO_NAMESPACE
  60. namespace stlsoft
  61. {
  62. #endif /* _STLSOFT_NO_NAMESPACE */
  63. /* /////////////////////////////////////////////////////////////////////////
  64. * Classes
  65. */
  66. // class inheritance_disambiguator
  67. /** \brief This class is used to disambiguate base classes, thereby faciliating multiple inheritance from the same type
  68. *
  69. * \ingroup group__library__obsolete
  70. *
  71. * \param T The type to disambiguate
  72. * \param N A unique integer index used to disambiguate between the classes
  73. */
  74. template <ss_typename_param_k T, int N>
  75. class inheritance_disambiguator
  76. : public T
  77. {
  78. public:
  79. /// The disambiguated class type
  80. typedef T parent_class_type;
  81. enum { unique = N };
  82. /// The type of the current parameterisation
  83. typedef inheritance_disambiguator<T, N> class_type;
  84. // Construction
  85. public:
  86. #ifdef STLSOFT_CF_MEMBER_TEMPLATE_FUNCTION_SUPPORT
  87. // For compilers that support member templates, the following constructors
  88. // are provided.
  89. /// Default constructor
  90. inheritance_disambiguator()
  91. {}
  92. /// Single parameter constructor
  93. template <ss_typename_param_k N1>
  94. ss_explicit_k inheritance_disambiguator(N1 n1)
  95. : parent_class_type(n1)
  96. {}
  97. /// Two parameter constructor
  98. template <ss_typename_param_k N1, ss_typename_param_k N2>
  99. inheritance_disambiguator(N1 n1, N2 n2)
  100. : parent_class_type(n1, n2)
  101. {}
  102. /// Three parameter constructor
  103. template <ss_typename_param_k N1, ss_typename_param_k N2, ss_typename_param_k N3>
  104. inheritance_disambiguator(N1 n1, N2 n2, N3 n3)
  105. : parent_class_type(n1, n2, n3)
  106. {}
  107. /// Four parameter constructor
  108. template <ss_typename_param_k N1, ss_typename_param_k N2, ss_typename_param_k N3, ss_typename_param_k N4>
  109. inheritance_disambiguator(N1 n1, N2 n2, N3 n3, N4 n4)
  110. : parent_class_type(n1, n2, n3, n4)
  111. {}
  112. /// Five parameter constructor
  113. template <ss_typename_param_k N1, ss_typename_param_k N2, ss_typename_param_k N3, ss_typename_param_k N4, ss_typename_param_k N5>
  114. inheritance_disambiguator(N1 n1, N2 n2, N3 n3, N4 n4, N5 n5)
  115. : parent_class_type(n1, n2, n3, n4, n5)
  116. {}
  117. /// Six parameter constructor
  118. template <ss_typename_param_k N1, ss_typename_param_k N2, ss_typename_param_k N3, ss_typename_param_k N4, ss_typename_param_k N5, ss_typename_param_k N6>
  119. inheritance_disambiguator(N1 n1, N2 n2, N3 n3, N4 n4, N5 n5, N6 n6)
  120. : parent_class_type(n1, n2, n3, n4, n5, n6)
  121. {}
  122. /// Seven parameter constructor
  123. template <ss_typename_param_k N1, ss_typename_param_k N2, ss_typename_param_k N3, ss_typename_param_k N4, ss_typename_param_k N5, ss_typename_param_k N6, ss_typename_param_k N7>
  124. inheritance_disambiguator(N1 n1, N2 n2, N3 n3, N4 n4, N5 n5, N6 n6, N7 n7)
  125. : parent_class_type(n1, n2, n3, n4, n5, n6, n7)
  126. {}
  127. /// Eight parameter constructor
  128. template <ss_typename_param_k N1, ss_typename_param_k N2, ss_typename_param_k N3, ss_typename_param_k N4, ss_typename_param_k N5, ss_typename_param_k N6, ss_typename_param_k N7, ss_typename_param_k N8>
  129. inheritance_disambiguator(N1 n1, N2 n2, N3 n3, N4 n4, N5 n5, N6 n6, N7 n7, N8 n8)
  130. : parent_class_type(n1, n2, n3, n4, n5, n6, n7, n8)
  131. {}
  132. #endif // STLSOFT_CF_MEMBER_TEMPLATE_FUNCTION_SUPPORT
  133. };
  134. /* ////////////////////////////////////////////////////////////////////// */
  135. #ifndef _STLSOFT_NO_NAMESPACE
  136. } // namespace stlsoft
  137. #endif /* _STLSOFT_NO_NAMESPACE */
  138. /* ////////////////////////////////////////////////////////////////////// */
  139. #endif /* !STLSOFT_INCL_STLSOFT_OBSOLETE_HPP_INHERITANCE_DISAMBIGUATOR */
  140. /* ///////////////////////////// end of file //////////////////////////// */