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.

244 lines
7.8 KiB

  1. /* /////////////////////////////////////////////////////////////////////////
  2. * File: pantheios/backends/bec.test.h
  3. *
  4. * Purpose: Declaration of the be.test library.
  5. *
  6. * Created: 1st November 2006
  7. * Updated: 22nd March 2010
  8. *
  9. * Home: http://www.pantheios.org/
  10. *
  11. * Copyright (c) 2006-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
  16. * met:
  17. *
  18. * - Redistributions of source code must retain the above copyright notice,
  19. * this list of conditions and the following disclaimer.
  20. * - Redistributions in binary form must reproduce the above copyright
  21. * notice, this list of conditions and the following disclaimer in the
  22. * documentation and/or other materials provided with the distribution.
  23. * - Neither the name(s) of Matthew Wilson and Synesis Software nor the
  24. * names of any contributors may be used to endorse or promote products
  25. * derived from this software without specific prior written permission.
  26. *
  27. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
  28. * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  29. * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  30. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  31. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  32. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  33. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  34. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  35. * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  36. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  37. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  38. *
  39. * ////////////////////////////////////////////////////////////////////// */
  40. /** \file pantheios/backends/bec.test.h
  41. *
  42. * \brief [C, C++] Declaration of the be.test library
  43. */
  44. #ifndef PANTHEIOS_INCL_BACKENDS_H_BEC_TEST
  45. #define PANTHEIOS_INCL_BACKENDS_H_BEC_TEST
  46. /* /////////////////////////////////////////////////////////////////////////
  47. * Version information
  48. */
  49. #ifndef PANTHEIOS_DOCUMENTATION_SKIP_SECTION
  50. # define PANTHEIOS_VER_BACKENDS_H_BEC_TEST_MAJOR 2
  51. # define PANTHEIOS_VER_BACKENDS_H_BEC_TEST_MINOR 2
  52. # define PANTHEIOS_VER_BACKENDS_H_BEC_TEST_REVISION 1
  53. # define PANTHEIOS_VER_BACKENDS_H_BEC_TEST_EDIT 24
  54. #endif /* !PANTHEIOS_DOCUMENTATION_SKIP_SECTION */
  55. /* /////////////////////////////////////////////////////////////////////////
  56. * Includes
  57. */
  58. #ifndef PANTHEIOS_INCL_PANTHEIOS_H_PANTHEIOS
  59. # include <pantheios/pantheios.h>
  60. #endif /* !PANTHEIOS_INCL_PANTHEIOS_H_PANTHEIOS */
  61. #ifndef STLSOFT_INCL_STLSOFT_H_STLSOFT
  62. # include <stlsoft/stlsoft.h>
  63. #endif /* !STLSOFT_INCL_STLSOFT_H_STLSOFT */
  64. #ifdef __cplusplus
  65. /* We include threading.h to prevent the definition of _REENTRANT via
  66. * <string> on some UNIX operating systems from confusing the feature
  67. * discrimination in UNIXSTL and having it think that we're multithreading
  68. * when we're not.
  69. */
  70. # include <pantheios/internal/threading.h>
  71. # include <string>
  72. #endif /* __cplusplus */
  73. /* /////////////////////////////////////////////////////////////////////////
  74. * API
  75. */
  76. /** \defgroup group__backend__stock_backends__test Pantheios Test Stock Back-end
  77. * \ingroup group__backend__stock_backends
  78. * Stub back-end library that does no emission.
  79. *
  80. * This library is useful for conducting performance tests.
  81. */
  82. /** Implements the functionality for pantheios_be_init() over the Test API.
  83. * \ingroup group__backend__stock_backends__test
  84. */
  85. PANTHEIOS_CALL(int) pantheios_be_test_init(
  86. PAN_CHAR_T const* processIdentity
  87. , int id
  88. , void* unused
  89. , void* reserved
  90. , void** ptoken
  91. );
  92. /** Implements the functionality for pantheios_be_uninit() over the Test API.
  93. * \ingroup group__backend__stock_backends__test
  94. */
  95. PANTHEIOS_CALL(void) pantheios_be_test_uninit(
  96. void* token
  97. );
  98. /** Implements the functionality for pantheios_be_logEntry() over the Test API.
  99. * \ingroup group__backend__stock_backends__test
  100. */
  101. PANTHEIOS_CALL(int) pantheios_be_test_logEntry(
  102. void* feToken
  103. , void* beToken
  104. , int severity
  105. , PAN_CHAR_T const* entry
  106. , size_t cchEntry
  107. );
  108. /** \def pantheios_be_test_parseArgs
  109. *
  110. * Parses the be.test back-end flags
  111. *
  112. * \ingroup group__backend
  113. *
  114. * There are currently no arguments whatsoever for be.test, hence
  115. * pantheios_be_test_parseArgs is actually a \#define for
  116. * <code>NULL</code>. At such time as back-end specific arguments
  117. * are required, it will become a first-class function.
  118. */
  119. #define pantheios_be_test_parseArgs NULL
  120. /* /////////////////////////////////////////////////////////////////////////
  121. * Namespace
  122. */
  123. #ifdef __cplusplus
  124. namespace pantheios
  125. {
  126. namespace be
  127. {
  128. namespace test
  129. {
  130. /** Represents a date/time epoch.
  131. *
  132. * \note Currently implemented as a no-op class. Will be fleshed out in
  133. * a future version of Pantheios.
  134. */
  135. class Time
  136. {
  137. public:
  138. /** Creates an instance representing the current time. */
  139. static Time now();
  140. };
  141. /** Represents an entry in the statement history
  142. */
  143. struct Entry
  144. {
  145. public: /* Member Types */
  146. /** The string type */
  147. typedef std::basic_string<pan_char_t> string_type;
  148. public: /* Member Variables */
  149. /* const */ Time time; /*!< The time the entry was logged. */
  150. /* const */ int severity; /*!< The entry's severity. */
  151. /* const */ string_type statement; /*!< The entry's contents. */
  152. public: /* Construction */
  153. /** Creates an instance with the given characteristics */
  154. Entry(int severity, pan_char_t const* entry, size_t cchEntry);
  155. };
  156. /** Represents the collection of entries since the last call
  157. * to reset()
  158. */
  159. class Results
  160. {
  161. public: /* Member Types */
  162. /** The type of this class */
  163. typedef Results class_type;
  164. /** The value type */
  165. typedef Entry value_type;
  166. protected:
  167. # if defined(STLSOFT_COMPILER_IS_DMC)
  168. public:
  169. # endif /* compiler */
  170. /** Pimpl class */
  171. struct ResultsImpl;
  172. protected: /* Construction */
  173. # ifndef PANTHEIOS_DOCUMENTATION_SKIP_SECTION
  174. Results(ResultsImpl* impl);
  175. # endif /* !PANTHEIOS_DOCUMENTATION_SKIP_SECTION */
  176. public:
  177. /** Copies the contents */
  178. Results(class_type const& rhs);
  179. /** Destroys the instance */
  180. ~Results() stlsoft_throw_0();
  181. public: /* Accessors */
  182. /** Indicates whether the container is empty */
  183. bool empty() const;
  184. /** Indicates the number of results in the container */
  185. size_t size() const;
  186. /** Requests an element from the container
  187. *
  188. * \param index The index of the element. Must be less than the value returned by size()
  189. */
  190. value_type const& operator [](size_t index) const;
  191. private: /* Implementation */
  192. ResultsImpl* const m_impl;
  193. private: /* Not to be implemented */
  194. class_type& operator= (class_type const& rhs);
  195. };
  196. /** Resets all results */
  197. void reset();
  198. /** Obtain a copy of the current test results */
  199. Results results();
  200. /* /////////////////////////////////////////////////////////////////////////
  201. * Namespace
  202. */
  203. } /* namespace test */
  204. } /* namespace be */
  205. } /* namespace pantheios */
  206. #endif /* __cplusplus */
  207. /* ////////////////////////////////////////////////////////////////////// */
  208. #endif /* PANTHEIOS_INCL_BACKENDS_H_BEC_TEST */
  209. /* ///////////////////////////// end of file //////////////////////////// */