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.

1032 lines
41 KiB

  1. /* /////////////////////////////////////////////////////////////////////////
  2. * File: acestl/collections/message_queue_sequence.hpp
  3. *
  4. * Purpose: Sequence class for adapting ACE_Message_Queue to an STL sequence.
  5. *
  6. * Created: 15th September 2004
  7. * Updated: 25th March 2010
  8. *
  9. * Home: http://stlsoft.org/
  10. *
  11. * Copyright (c) 2004-2010, 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 acestl/collections/message_queue_sequence.hpp
  40. *
  41. * \brief [C++ only] Definition of the acestl::message_queue_sequence
  42. * collection class template
  43. * (\ref group__library__collections "Collections" Library).
  44. */
  45. #ifndef ACESTL_INCL_ACESTL_COLLECTIONS_HPP_MESSAGE_QUEUE_SEQUENCE
  46. #define ACESTL_INCL_ACESTL_COLLECTIONS_HPP_MESSAGE_QUEUE_SEQUENCE
  47. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  48. # define ACESTL_VER_ACESTL_COLLECTIONS_HPP_MESSAGE_QUEUE_SEQUENCE_MAJOR 2
  49. # define ACESTL_VER_ACESTL_COLLECTIONS_HPP_MESSAGE_QUEUE_SEQUENCE_MINOR 1
  50. # define ACESTL_VER_ACESTL_COLLECTIONS_HPP_MESSAGE_QUEUE_SEQUENCE_REVISION 8
  51. # define ACESTL_VER_ACESTL_COLLECTIONS_HPP_MESSAGE_QUEUE_SEQUENCE_EDIT 58
  52. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  53. /* /////////////////////////////////////////////////////////////////////////
  54. * Includes
  55. */
  56. #ifndef ACESTL_INCL_ACESTL_HPP_ACESTL
  57. # include <acestl/acestl.hpp>
  58. #endif /* !ACESTL_INCL_ACESTL_HPP_ACESTL */
  59. #ifndef STLSOFT_INCL_STLSOFT_UTIL_STD_HPP_ITERATOR_HELPER
  60. # include <stlsoft/util/std/iterator_helper.hpp>
  61. #endif /* !STLSOFT_INCL_STLSOFT_UTIL_STD_HPP_ITERATOR_HELPER */
  62. #ifndef STLSOFT_INCL_STLSOFT_COLLECTIONS_UTIL_HPP_COLLECTIONS
  63. # include <stlsoft/collections/util/collections.hpp>
  64. #endif /* !STLSOFT_INCL_STLSOFT_COLLECTIONS_UTIL_HPP_COLLECTIONS */
  65. #ifndef STLSOFT_INCL_STLSOFT_CONVERSION_HPP_SAP_CAST
  66. # include <stlsoft/conversion/sap_cast.hpp>
  67. #endif /* !STLSOFT_INCL_STLSOFT_CONVERSION_HPP_SAP_CAST */
  68. #ifndef STLSOFT_INCL_STLSOFT_ALGORITHMS_HPP_BOUNDED
  69. # include <stlsoft/algorithms/bounded.hpp> // for stlsoft::copy_n()
  70. #endif /* !STLSOFT_INCL_STLSOFT_ALGORITHMS_HPP_BOUNDED */
  71. #if ACESTL_ACE_VERSION >= 0x00050004
  72. // This stinks, but appears to be necessary in ACE versions later than 5.3
  73. #ifndef STLSOFT_INCL_ACE_H_CONDITION_THREAD_MUTEX
  74. # define STLSOFT_INCL_ACE_H_CONDITION_THREAD_MUTEX
  75. # include <ace/Condition_Thread_Mutex.h>
  76. #endif /* !STLSOFT_INCL_ACE_H_CONDITION_THREAD_MUTEX */
  77. #ifndef STLSOFT_INCL_ACE_H_GUARD_T
  78. # define STLSOFT_INCL_ACE_H_GUARD_T
  79. # include <ace/Guard_T.h>
  80. #endif /* !STLSOFT_INCL_ACE_H_GUARD_T */
  81. #ifndef STLSOFT_INCL_ACE_H_NULL_CONDITION
  82. # define STLSOFT_INCL_ACE_H_NULL_CONDITION
  83. # include <ace/Null_Condition.h>
  84. #endif /* !STLSOFT_INCL_ACE_H_NULL_CONDITION */
  85. #ifndef STLSOFT_INCL_ACE_H_NULL_MUTEX
  86. # define STLSOFT_INCL_ACE_H_NULL_MUTEX
  87. # include <ace/Null_Mutex.h>
  88. #endif /* !STLSOFT_INCL_ACE_H_NULL_MUTEX */
  89. #ifndef STLSOFT_INCL_ACE_H_THREAD_MUTEX
  90. # define STLSOFT_INCL_ACE_H_THREAD_MUTEX
  91. # include <ace/Thread_Mutex.h>
  92. #endif /* !STLSOFT_INCL_ACE_H_THREAD_MUTEX */
  93. #endif /* ACESTL_ACE_VERSION */
  94. #ifndef STLSOFT_INCL_ACE_H_MESSAGE_QUEUE_T
  95. # define STLSOFT_INCL_ACE_H_MESSAGE_QUEUE_T
  96. # include <ace/Message_Queue_T.h>
  97. #endif /* !STLSOFT_INCL_ACE_H_MESSAGE_QUEUE_T */
  98. #ifndef STLSOFT_INCL_ALGORITHM
  99. # define STLSOFT_INCL_ALGORITHM
  100. # include <algorithm> // for std::copy
  101. #endif /* !STLSOFT_INCL_ALGORITHM */
  102. #ifdef STLSOFT_UNITTEST
  103. # include <acestl/memory/message_block_functions.hpp>
  104. #endif /* STLSOFT_UNITTEST */
  105. /* /////////////////////////////////////////////////////////////////////////
  106. * Namespace
  107. */
  108. #ifndef _ACESTL_NO_NAMESPACE
  109. # if defined(_STLSOFT_NO_NAMESPACE) || \
  110. defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
  111. /* There is no stlsoft namespace, so must define ::acestl */
  112. namespace acestl
  113. {
  114. # else
  115. /* Define stlsoft::acestl_project */
  116. namespace stlsoft
  117. {
  118. namespace acestl_project
  119. {
  120. # endif /* _STLSOFT_NO_NAMESPACE */
  121. #endif /* !_ACESTL_NO_NAMESPACE */
  122. /* /////////////////////////////////////////////////////////////////////////
  123. * Classes
  124. */
  125. /** An \ref group__pattern__instance_adaptor "instance adaptor" that
  126. * adapts an instance of \c ACE_Message_Queue to provide an STL
  127. * input-sequence interface.
  128. *
  129. * \ingroup group__library__collections
  130. *
  131. * It is used as follows:
  132. \code
  133. using acestl::message_queue_sequence;
  134. using stlsoft::auto_buffer;
  135. ACE_Message_Queue<ACE_NULL_SYNCH> &mq = . . .
  136. // Adapt the message queue into the sequence
  137. message_queue_sequence<ACE_NULL_SYNCH> mqs(mq);
  138. // Allocate a contiguous buffer, using stlsoft::auto_buffer
  139. auto_buffer<char> buff(mqs.size());
  140. // Block copy into the buffer
  141. std::copy(&buff[0], &buff[0] + (buff.size()), mqs.begin());
  142. \endcode
  143. *
  144. * \note Although this class provides <i>Input Iterator</i>s, it
  145. * uses customisations of \c std algorithms to effect very favourable
  146. * performance, as described in chapter 31 of
  147. * \ref section__publishing__books__xstlv1.
  148. */
  149. // [[synesis:class:collection: acestl::message_queue_sequence<T<S>>]]
  150. template <ACE_SYNCH_DECL>
  151. class message_queue_sequence
  152. : public stlsoft_ns_qual(stl_collection_tag)
  153. {
  154. /// \name Types
  155. /// @{
  156. public:
  157. /// The value type
  158. typedef char value_type;
  159. /// The sequence type
  160. typedef ACE_Message_Queue<ACE_SYNCH_USE> sequence_type;
  161. /// The current parameterisation of the type
  162. typedef message_queue_sequence<ACE_SYNCH_USE> class_type;
  163. /// The size type
  164. typedef ss_size_t size_type;
  165. /** Iterator type for the message_queue_sequence class template
  166. *
  167. * \note Although this iterator class is an <i>Input Iterator</i>, it
  168. * uses customisations of \c std algorithms to effect very favourable
  169. * performance, as described in chapter 31 of <b>Extended STL,
  170. * volume 1</b> (published by Addison-Wesley, June 2007).
  171. */
  172. class iterator
  173. : public stlsoft_ns_qual(iterator_base)<acestl_ns_qual_std(input_iterator_tag)
  174. , char
  175. , ss_ptrdiff_t
  176. , char*
  177. , char&
  178. >
  179. {
  180. private:
  181. friend class message_queue_sequence<ACE_SYNCH_USE>;
  182. typedef ACE_Message_Queue_Iterator<ACE_SYNCH_USE> mq_iterator_type;
  183. private:
  184. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  185. struct shared_handle
  186. {
  187. public:
  188. typedef shared_handle class_type;
  189. // Members
  190. public:
  191. mq_iterator_type m_mqi;
  192. ACE_Message_Block* m_entry;
  193. as_size_t m_entryLength;
  194. as_size_t m_entryIndex;
  195. private:
  196. ss_sint32_t m_refCount;
  197. /// Construction
  198. public:
  199. ss_explicit_k shared_handle(sequence_type &mq)
  200. : m_mqi(mq)
  201. , m_entry(NULL)
  202. , m_entryLength(0)
  203. , m_entryIndex(0)
  204. , m_refCount(1)
  205. {
  206. if(m_mqi.next(m_entry))
  207. {
  208. for(;;)
  209. {
  210. if(0 != (m_entryLength = m_entry->length()))
  211. {
  212. break;
  213. }
  214. else if(NULL == (m_entry = nextEntry()))
  215. {
  216. break;
  217. }
  218. }
  219. }
  220. }
  221. # if defined(STLSOFT_CF_COMPILER_WARNS_NO_PUBLIC_DTOR)
  222. protected:
  223. # else /* ? STLSOFT_CF_COMPILER_WARNS_NO_PUBLIC_DTOR */
  224. private:
  225. # endif /* STLSOFT_CF_COMPILER_WARNS_NO_PUBLIC_DTOR */
  226. ~shared_handle() stlsoft_throw_0()
  227. {
  228. ACESTL_MESSAGE_ASSERT("Shared search handle being destroyed with outstanding references!", 0 == m_refCount);
  229. }
  230. /// Accessors
  231. public:
  232. ss_bool_t is_end_point() const
  233. {
  234. return m_entryIndex == m_entryLength;
  235. }
  236. char &current()
  237. {
  238. ACESTL_ASSERT(NULL != m_entry);
  239. ACESTL_ASSERT(m_entryIndex != m_entryLength);
  240. return m_entryIndex[m_entry->rd_ptr()];
  241. }
  242. char current() const
  243. {
  244. ACESTL_ASSERT(NULL != m_entry);
  245. ACESTL_ASSERT(m_entryIndex != m_entryLength);
  246. return m_entryIndex[m_entry->rd_ptr()];
  247. }
  248. ss_bool_t advance()
  249. {
  250. ACESTL_MESSAGE_ASSERT("Invalid index", m_entryIndex < m_entryLength);
  251. if(++m_entryIndex == m_entryLength)
  252. {
  253. m_entryIndex = 0;
  254. for(;;)
  255. {
  256. if(NULL == (m_entry = nextEntry()))
  257. {
  258. return false;
  259. }
  260. else if(0 != (m_entryLength = m_entry->length()))
  261. {
  262. break;
  263. }
  264. }
  265. }
  266. return true;
  267. }
  268. /// Operations
  269. public:
  270. ss_sint32_t AddRef()
  271. {
  272. return ++m_refCount;
  273. }
  274. ss_sint32_t Release()
  275. {
  276. ss_sint32_t rc = --m_refCount;
  277. if(0 == rc)
  278. {
  279. delete this;
  280. }
  281. return rc;
  282. }
  283. void fast_copy(char const* f, char const* l, size_type n)
  284. {
  285. ACESTL_ASSERT(0 != n);
  286. ACESTL_ASSERT(f != l);
  287. if(0 != n)
  288. {
  289. size_type n1 = m_entryLength - m_entryIndex;
  290. if(n <= n1)
  291. {
  292. // Terminal case
  293. ::memcpy(&m_entryIndex[m_entry->rd_ptr()], f, n);
  294. ACESTL_ASSERT(n <= m_entryLength - m_entryIndex);
  295. m_entryIndex += n;
  296. ACESTL_ASSERT(m_entryIndex <= m_entryLength);
  297. }
  298. else
  299. {
  300. // Recursive case
  301. ::memcpy(&m_entryIndex[m_entry->rd_ptr()], f, n1);
  302. f += n1;
  303. m_entry = nextEntry();
  304. ACESTL_MESSAGE_ASSERT("Attempt to walk off end of iterator's range", NULL != m_entry);
  305. m_entryIndex = 0;
  306. m_entryLength = m_entry->length();
  307. fast_copy(f, l, n - n1);
  308. }
  309. }
  310. }
  311. void fast_copy(class_type const* l, char* o)
  312. {
  313. size_type n1 = m_entryLength - m_entryIndex;
  314. if( NULL != l &&
  315. m_entry == l->m_entry)
  316. {
  317. // Terminal case
  318. ::memcpy(o, &m_entryIndex[m_entry->rd_ptr()], n1);
  319. }
  320. else
  321. {
  322. // Recursive case
  323. ::memcpy(o, &m_entryIndex[m_entry->rd_ptr()], n1);
  324. o += n1;
  325. m_entry = nextEntry();
  326. if(NULL != m_entry)
  327. {
  328. m_entryIndex = 0;
  329. m_entryLength = m_entry->length();
  330. fast_copy(l, o);
  331. }
  332. }
  333. }
  334. void fast_copy(size_type n, char* o)
  335. {
  336. size_type n1 = m_entryLength - m_entryIndex;
  337. if(n <= n1)
  338. {
  339. // Asking for less than (or equal to) the capacity
  340. // of the current entry.
  341. //
  342. // Advance the m_entryIndex member.
  343. //
  344. // This is the terminating case.
  345. ::memcpy(o, &m_entryIndex[m_entry->rd_ptr()], n);
  346. ACESTL_ASSERT(n <= m_entryLength - m_entryIndex);
  347. m_entryIndex += n;
  348. ACESTL_ASSERT(m_entryIndex <= m_entryLength);
  349. }
  350. else
  351. {
  352. ::memcpy(o, &m_entryIndex[m_entry->rd_ptr()], n1);
  353. o += n1;
  354. m_entry = nextEntry();
  355. ACESTL_MESSAGE_ASSERT("Attempt to walk off end of iterator's range", (0 == n || NULL != m_entry));
  356. if(NULL != m_entry)
  357. {
  358. m_entryIndex = 0;
  359. m_entryLength = m_entry->length();
  360. fast_copy(n - n1, o);
  361. }
  362. }
  363. }
  364. // Implementation
  365. private:
  366. ACE_Message_Block* nextEntry()
  367. {
  368. ACE_Message_Block* entry = NULL;
  369. return m_mqi.advance() ? (m_mqi.next(entry), entry) : NULL;
  370. }
  371. // Not to be implemented
  372. private:
  373. shared_handle(class_type const&);
  374. class_type& operator =(class_type const&);
  375. };
  376. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  377. public:
  378. typedef iterator class_type;
  379. /// The value type
  380. typedef char value_type;
  381. private:
  382. iterator(sequence_type &mq)
  383. : m_handle(new shared_handle(mq))
  384. {}
  385. public:
  386. iterator()
  387. : m_handle(NULL)
  388. {}
  389. iterator(class_type const& rhs)
  390. : m_handle(rhs.m_handle)
  391. {
  392. if(NULL != m_handle)
  393. {
  394. m_handle->AddRef();
  395. }
  396. }
  397. ~iterator() stlsoft_throw_0()
  398. {
  399. if(NULL != m_handle)
  400. {
  401. m_handle->Release();
  402. }
  403. }
  404. class_type& operator =(class_type const& rhs)
  405. {
  406. shared_handle* this_handle = m_handle;
  407. m_handle = rhs.m_handle;
  408. if(NULL != m_handle)
  409. {
  410. m_handle->AddRef();
  411. }
  412. if(NULL != this_handle)
  413. {
  414. this_handle->Release();
  415. }
  416. return *this;
  417. }
  418. public:
  419. class_type& operator ++()
  420. {
  421. ACESTL_ASSERT(NULL != m_handle);
  422. if(!m_handle->advance())
  423. {
  424. m_handle->Release();
  425. m_handle = NULL;
  426. }
  427. return *this;
  428. }
  429. class_type operator ++(int)
  430. {
  431. class_type ret(*this);
  432. operator ++();
  433. return ret;
  434. }
  435. value_type& operator *()
  436. {
  437. ACESTL_ASSERT(NULL != m_handle);
  438. return m_handle->current();
  439. }
  440. value_type operator *() const
  441. {
  442. ACESTL_ASSERT(NULL != m_handle);
  443. return m_handle->current();
  444. }
  445. public:
  446. ss_bool_t equal(class_type const& rhs) const
  447. {
  448. return class_type::equal_(*this, rhs, iterator_category());
  449. }
  450. ss_bool_t operator ==(class_type const& rhs) const
  451. {
  452. return equal(rhs);
  453. }
  454. ss_bool_t operator !=(class_type const& rhs) const
  455. {
  456. return !equal(rhs);
  457. }
  458. private:
  459. static ss_bool_t equal_(class_type const& lhs, class_type const& rhs, stlsoft_ns_qual_std(input_iterator_tag))
  460. {
  461. // Input iterator
  462. return lhs.is_end_point() == rhs.is_end_point();
  463. }
  464. #if 0
  465. static ss_bool_t equal_(class_type const& lhs, class_type const& rhs, stlsoft_ns_qual_std(forward_iterator_tag));
  466. // Forward or above
  467. if(is_end_point())
  468. {
  469. return rhs.is_end_point();
  470. }
  471. else
  472. {
  473. if(rhs.is_end_point())
  474. {
  475. return false;
  476. }
  477. else
  478. {
  479. ACESTL_ASSERT(NULL != m_handle);
  480. ACESTL_ASSERT(NULL != rhs.m_handle);
  481. }
  482. }
  483. #endif /* 0 */
  484. private:
  485. ss_bool_t is_end_point() const
  486. {
  487. return NULL == m_handle || m_handle->is_end_point();
  488. }
  489. private:
  490. void fast_copy(char const* f, char const* l)
  491. {
  492. if(f != l)
  493. {
  494. ACESTL_ASSERT(NULL != m_handle);
  495. m_handle->fast_copy(f, l, static_cast<size_type>(l - f));
  496. }
  497. }
  498. void fast_copy(class_type const& l, char* o)
  499. {
  500. if(*this != l)
  501. {
  502. ACESTL_ASSERT(NULL != m_handle);
  503. m_handle->fast_copy(l.m_handle, o);
  504. }
  505. }
  506. void fast_copy(size_type n, char* o)
  507. {
  508. if(0 != n)
  509. {
  510. ACESTL_ASSERT(NULL != m_handle);
  511. m_handle->fast_copy(n, o);
  512. }
  513. }
  514. private:
  515. shared_handle* m_handle;
  516. };
  517. /// @}
  518. // Construction
  519. public:
  520. /// Create an instance representing the given environment variable
  521. ss_explicit_k message_queue_sequence(sequence_type &mq)
  522. : m_mq(mq)
  523. {}
  524. /// \name Iteration
  525. /// @{
  526. public:
  527. /// Begins the iteration
  528. ///
  529. /// \return An iterator representing the start of the sequence
  530. iterator begin()
  531. {
  532. return iterator(m_mq);
  533. }
  534. /// Ends the iteration
  535. ///
  536. /// \return An iterator representing the end of the sequence
  537. iterator end()
  538. {
  539. return iterator();
  540. }
  541. /// @}
  542. /// \name Attributes
  543. /// @{
  544. public:
  545. /// Returns the number of bytes in the message queue
  546. size_type size() const
  547. {
  548. return m_mq.message_length() /* - 1 */;
  549. }
  550. /// Indicates whethere there are any bytes in the message queue
  551. as_bool_t empty() const
  552. {
  553. return const_cast<sequence_type&>(m_mq).is_empty();
  554. }
  555. /// @}
  556. /// \name Operations
  557. /// @{
  558. public:
  559. static char* fast_copy(iterator f, iterator l, char* o)
  560. {
  561. #if defined(ACESTL_MQS_NO_FAST_COPY_TO)
  562. for(; f != l; ++f, ++o)
  563. {
  564. *o = *f;
  565. }
  566. #else /* ? ACESTL_MQS_NO_FAST_COPY_TO */
  567. f.fast_copy(l, o);
  568. #endif /* ACESTL_MQS_NO_FAST_COPY_TO */
  569. return o;
  570. }
  571. static char* fast_copy(iterator f, size_type n, char* o)
  572. {
  573. #if defined(ACESTL_MQS_NO_FAST_COPY_TO)
  574. for(; 0 != n; ++f, ++o, --n)
  575. {
  576. *o = *f;
  577. }
  578. #else /* ? ACESTL_MQS_NO_FAST_COPY_TO */
  579. f.fast_copy(n, o);
  580. #endif /* ACESTL_MQS_NO_FAST_COPY_TO */
  581. return o;
  582. }
  583. static iterator fast_copy(char const* f, char const* l, iterator o)
  584. {
  585. #if defined(ACESTL_MQS_NO_FAST_COPY_FROM)
  586. for(; f != l; ++f, ++o)
  587. {
  588. *o = *f;
  589. }
  590. #else /* ? ACESTL_MQS_NO_FAST_COPY_FROM */
  591. o.fast_copy(f, l);
  592. #endif /* ACESTL_MQS_NO_FAST_COPY_FROM */
  593. return o;
  594. }
  595. /// @}
  596. /// \name Members
  597. /// @{
  598. private:
  599. sequence_type &m_mq;
  600. /// @}
  601. /// \name Not to be implemented
  602. /// @{
  603. private:
  604. message_queue_sequence(class_type const&);
  605. class_type& operator =(class_type const&);
  606. /// @}
  607. };
  608. ////////////////////////////////////////////////////////////////////////////
  609. // Unit-testing
  610. #ifdef STLSOFT_UNITTEST
  611. # include "./unittest/message_queue_sequence_unittest_.h"
  612. #endif /* STLSOFT_UNITTEST */
  613. /* ////////////////////////////////////////////////////////////////////// */
  614. #ifndef _ACESTL_NO_NAMESPACE
  615. # if defined(_STLSOFT_NO_NAMESPACE) || \
  616. defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
  617. } // namespace acestl
  618. # else
  619. } // namespace acestl_project
  620. } // namespace stlsoft
  621. # endif /* _STLSOFT_NO_NAMESPACE */
  622. #endif /* !_ACESTL_NO_NAMESPACE */
  623. // Define specialisations in the std namespace
  624. #ifdef STLSOFT_CF_std_NAMESPACE
  625. namespace std
  626. {
  627. #endif /* STLSOFT_CF_std_NAMESPACE */
  628. STLSOFT_TEMPLATE_SPECIALISATION
  629. inline char* copy( acestl_ns_qual(message_queue_sequence)<ACE_NULL_SYNCH>::iterator f
  630. , acestl_ns_qual(message_queue_sequence)<ACE_NULL_SYNCH>::iterator l
  631. , char* o)
  632. {
  633. return acestl_ns_qual(message_queue_sequence)<ACE_NULL_SYNCH>::fast_copy(f, l, o);
  634. }
  635. STLSOFT_TEMPLATE_SPECIALISATION
  636. inline char* copy( acestl_ns_qual(message_queue_sequence)<ACE_MT_SYNCH>::iterator f
  637. , acestl_ns_qual(message_queue_sequence)<ACE_MT_SYNCH>::iterator l
  638. , char* o)
  639. {
  640. return acestl_ns_qual(message_queue_sequence)<ACE_MT_SYNCH>::fast_copy(f, l, o);
  641. }
  642. STLSOFT_TEMPLATE_SPECIALISATION
  643. inline signed char* copy( acestl_ns_qual(message_queue_sequence)<ACE_NULL_SYNCH>::iterator f
  644. , acestl_ns_qual(message_queue_sequence)<ACE_NULL_SYNCH>::iterator l
  645. , signed char* o)
  646. {
  647. return reinterpret_cast<signed char*>(acestl_ns_qual(message_queue_sequence)<ACE_NULL_SYNCH>::fast_copy(f, l, reinterpret_cast<char*>(o)));
  648. }
  649. STLSOFT_TEMPLATE_SPECIALISATION
  650. inline signed char* copy( acestl_ns_qual(message_queue_sequence)<ACE_MT_SYNCH>::iterator f
  651. , acestl_ns_qual(message_queue_sequence)<ACE_MT_SYNCH>::iterator l
  652. , signed char* o)
  653. {
  654. return reinterpret_cast<signed char*>(acestl_ns_qual(message_queue_sequence)<ACE_MT_SYNCH>::fast_copy(f, l, reinterpret_cast<char*>(o)));
  655. }
  656. STLSOFT_TEMPLATE_SPECIALISATION
  657. inline unsigned char* copy( acestl_ns_qual(message_queue_sequence)<ACE_NULL_SYNCH>::iterator f
  658. , acestl_ns_qual(message_queue_sequence)<ACE_NULL_SYNCH>::iterator l
  659. , unsigned char* o)
  660. {
  661. return reinterpret_cast<unsigned char*>(acestl_ns_qual(message_queue_sequence)<ACE_NULL_SYNCH>::fast_copy(f, l, reinterpret_cast<char*>(o)));
  662. }
  663. STLSOFT_TEMPLATE_SPECIALISATION
  664. inline unsigned char* copy( acestl_ns_qual(message_queue_sequence)<ACE_MT_SYNCH>::iterator f
  665. , acestl_ns_qual(message_queue_sequence)<ACE_MT_SYNCH>::iterator l
  666. , unsigned char* o)
  667. {
  668. return reinterpret_cast<unsigned char*>(acestl_ns_qual(message_queue_sequence)<ACE_MT_SYNCH>::fast_copy(f, l, reinterpret_cast<char*>(o)));
  669. }
  670. STLSOFT_TEMPLATE_SPECIALISATION
  671. inline acestl_ns_qual(message_queue_sequence)<ACE_NULL_SYNCH>::iterator copy( char* f
  672. , char* l
  673. , acestl_ns_qual(message_queue_sequence)<ACE_NULL_SYNCH>::iterator o)
  674. {
  675. return acestl_ns_qual(message_queue_sequence)<ACE_NULL_SYNCH>::fast_copy(f, l, o);
  676. }
  677. STLSOFT_TEMPLATE_SPECIALISATION
  678. inline acestl_ns_qual(message_queue_sequence)<ACE_MT_SYNCH>::iterator copy( char* f
  679. , char* l
  680. , acestl_ns_qual(message_queue_sequence)<ACE_MT_SYNCH>::iterator o)
  681. {
  682. return acestl_ns_qual(message_queue_sequence)<ACE_MT_SYNCH>::fast_copy(f, l, o);
  683. }
  684. STLSOFT_TEMPLATE_SPECIALISATION
  685. inline acestl_ns_qual(message_queue_sequence)<ACE_NULL_SYNCH>::iterator copy( signed char* f
  686. , signed char* l
  687. , acestl_ns_qual(message_queue_sequence)<ACE_NULL_SYNCH>::iterator o)
  688. {
  689. return acestl_ns_qual(message_queue_sequence)<ACE_NULL_SYNCH>::fast_copy(stlsoft_ns_qual(sap_cast)<char const*>(f), stlsoft_ns_qual(sap_cast)<char const*>(l), o);
  690. }
  691. STLSOFT_TEMPLATE_SPECIALISATION
  692. inline acestl_ns_qual(message_queue_sequence)<ACE_MT_SYNCH>::iterator copy( signed char* f
  693. , signed char* l
  694. , acestl_ns_qual(message_queue_sequence)<ACE_MT_SYNCH>::iterator o)
  695. {
  696. return acestl_ns_qual(message_queue_sequence)<ACE_MT_SYNCH>::fast_copy(stlsoft_ns_qual(sap_cast)<char const*>(f), stlsoft_ns_qual(sap_cast)<char const*>(l), o);
  697. }
  698. STLSOFT_TEMPLATE_SPECIALISATION
  699. inline acestl_ns_qual(message_queue_sequence)<ACE_NULL_SYNCH>::iterator copy( unsigned char* f
  700. , unsigned char* l
  701. , acestl_ns_qual(message_queue_sequence)<ACE_NULL_SYNCH>::iterator o)
  702. {
  703. return acestl_ns_qual(message_queue_sequence)<ACE_NULL_SYNCH>::fast_copy(stlsoft_ns_qual(sap_cast)<char const*>(f), stlsoft_ns_qual(sap_cast)<char const*>(l), o);
  704. }
  705. STLSOFT_TEMPLATE_SPECIALISATION
  706. inline acestl_ns_qual(message_queue_sequence)<ACE_MT_SYNCH>::iterator copy( unsigned char* f
  707. , unsigned char* l
  708. , acestl_ns_qual(message_queue_sequence)<ACE_MT_SYNCH>::iterator o)
  709. {
  710. return acestl_ns_qual(message_queue_sequence)<ACE_MT_SYNCH>::fast_copy(stlsoft_ns_qual(sap_cast)<char const*>(f), stlsoft_ns_qual(sap_cast)<char const*>(l), o);
  711. }
  712. STLSOFT_TEMPLATE_SPECIALISATION
  713. inline acestl_ns_qual(message_queue_sequence)<ACE_NULL_SYNCH>::iterator copy( char const* f
  714. , char const* l
  715. , acestl_ns_qual(message_queue_sequence)<ACE_NULL_SYNCH>::iterator o)
  716. {
  717. return acestl_ns_qual(message_queue_sequence)<ACE_NULL_SYNCH>::fast_copy(f, l, o);
  718. }
  719. STLSOFT_TEMPLATE_SPECIALISATION
  720. inline acestl_ns_qual(message_queue_sequence)<ACE_MT_SYNCH>::iterator copy( char const* f
  721. , char const* l
  722. , acestl_ns_qual(message_queue_sequence)<ACE_MT_SYNCH>::iterator o)
  723. {
  724. return acestl_ns_qual(message_queue_sequence)<ACE_MT_SYNCH>::fast_copy(f, l, o);
  725. }
  726. STLSOFT_TEMPLATE_SPECIALISATION
  727. inline acestl_ns_qual(message_queue_sequence)<ACE_NULL_SYNCH>::iterator copy( signed char const* f
  728. , signed char const* l
  729. , acestl_ns_qual(message_queue_sequence)<ACE_NULL_SYNCH>::iterator o)
  730. {
  731. return acestl_ns_qual(message_queue_sequence)<ACE_NULL_SYNCH>::fast_copy(stlsoft_ns_qual(sap_cast)<char const*>(f), stlsoft_ns_qual(sap_cast)<char const*>(l), o);
  732. }
  733. STLSOFT_TEMPLATE_SPECIALISATION
  734. inline acestl_ns_qual(message_queue_sequence)<ACE_MT_SYNCH>::iterator copy( signed char const* f
  735. , signed char const* l
  736. , acestl_ns_qual(message_queue_sequence)<ACE_MT_SYNCH>::iterator o)
  737. {
  738. return acestl_ns_qual(message_queue_sequence)<ACE_MT_SYNCH>::fast_copy(stlsoft_ns_qual(sap_cast)<char const*>(f), stlsoft_ns_qual(sap_cast)<char const*>(l), o);
  739. }
  740. STLSOFT_TEMPLATE_SPECIALISATION
  741. inline acestl_ns_qual(message_queue_sequence)<ACE_NULL_SYNCH>::iterator copy( unsigned char const* f
  742. , unsigned char const* l
  743. , acestl_ns_qual(message_queue_sequence)<ACE_NULL_SYNCH>::iterator o)
  744. {
  745. return acestl_ns_qual(message_queue_sequence)<ACE_NULL_SYNCH>::fast_copy(stlsoft_ns_qual(sap_cast)<char const*>(f), stlsoft_ns_qual(sap_cast)<char const*>(l), o);
  746. }
  747. STLSOFT_TEMPLATE_SPECIALISATION
  748. inline acestl_ns_qual(message_queue_sequence)<ACE_MT_SYNCH>::iterator copy( unsigned char const* f
  749. , unsigned char const* l
  750. , acestl_ns_qual(message_queue_sequence)<ACE_MT_SYNCH>::iterator o)
  751. {
  752. return acestl_ns_qual(message_queue_sequence)<ACE_MT_SYNCH>::fast_copy(stlsoft_ns_qual(sap_cast)<char const*>(f), stlsoft_ns_qual(sap_cast)<char const*>(l), o);
  753. }
  754. #ifdef STLSOFT_CF_std_NAMESPACE
  755. } // namespace std
  756. #endif /* STLSOFT_CF_std_NAMESPACE */
  757. // Define specialisations in the stlsoft namespace
  758. #ifndef _STLSOFT_NO_NAMESPACE
  759. namespace stlsoft
  760. {
  761. #endif /* !_STLSOFT_NO_NAMESPACE */
  762. STLSOFT_TEMPLATE_SPECIALISATION
  763. inline char* copy_n(acestl_ns_qual(message_queue_sequence)<ACE_NULL_SYNCH>::iterator f
  764. , ss_size_t n
  765. , char* o)
  766. {
  767. return acestl_ns_qual(message_queue_sequence)<ACE_NULL_SYNCH>::fast_copy(f, n, o);
  768. }
  769. STLSOFT_TEMPLATE_SPECIALISATION
  770. inline char* copy_n(acestl_ns_qual(message_queue_sequence)<ACE_MT_SYNCH>::iterator f
  771. , ss_size_t n
  772. , char* o)
  773. {
  774. return acestl_ns_qual(message_queue_sequence)<ACE_MT_SYNCH>::fast_copy(f, n, o);
  775. }
  776. STLSOFT_TEMPLATE_SPECIALISATION
  777. inline signed char* copy_n( acestl_ns_qual(message_queue_sequence)<ACE_NULL_SYNCH>::iterator f
  778. , ss_size_t n
  779. , signed char* o)
  780. {
  781. return reinterpret_cast<signed char*>(acestl_ns_qual(message_queue_sequence)<ACE_NULL_SYNCH>::fast_copy(f, n, reinterpret_cast<char*>(o)));
  782. }
  783. STLSOFT_TEMPLATE_SPECIALISATION
  784. inline signed char* copy_n( acestl_ns_qual(message_queue_sequence)<ACE_MT_SYNCH>::iterator f
  785. , ss_size_t n
  786. , signed char* o)
  787. {
  788. return reinterpret_cast<signed char*>(acestl_ns_qual(message_queue_sequence)<ACE_MT_SYNCH>::fast_copy(f, n, reinterpret_cast<char*>(o)));
  789. }
  790. STLSOFT_TEMPLATE_SPECIALISATION
  791. inline unsigned char* copy_n( acestl_ns_qual(message_queue_sequence)<ACE_NULL_SYNCH>::iterator f
  792. , ss_size_t n
  793. , unsigned char* o)
  794. {
  795. return reinterpret_cast<unsigned char*>(acestl_ns_qual(message_queue_sequence)<ACE_NULL_SYNCH>::fast_copy(f, n, reinterpret_cast<char*>(o)));
  796. }
  797. STLSOFT_TEMPLATE_SPECIALISATION
  798. inline unsigned char* copy_n( acestl_ns_qual(message_queue_sequence)<ACE_MT_SYNCH>::iterator f
  799. , ss_size_t n
  800. , unsigned char* o)
  801. {
  802. return reinterpret_cast<unsigned char*>(acestl_ns_qual(message_queue_sequence)<ACE_MT_SYNCH>::fast_copy(f, n, reinterpret_cast<char*>(o)));
  803. }
  804. STLSOFT_TEMPLATE_SPECIALISATION
  805. inline acestl_ns_qual(message_queue_sequence)<ACE_NULL_SYNCH>::iterator copy_n( char* f
  806. , ss_size_t n
  807. , acestl_ns_qual(message_queue_sequence)<ACE_NULL_SYNCH>::iterator o)
  808. {
  809. return acestl_ns_qual(message_queue_sequence)<ACE_NULL_SYNCH>::fast_copy(f, f + n, o);
  810. }
  811. STLSOFT_TEMPLATE_SPECIALISATION
  812. inline acestl_ns_qual(message_queue_sequence)<ACE_MT_SYNCH>::iterator copy_n( char* f
  813. , ss_size_t n
  814. , acestl_ns_qual(message_queue_sequence)<ACE_MT_SYNCH>::iterator o)
  815. {
  816. return acestl_ns_qual(message_queue_sequence)<ACE_MT_SYNCH>::fast_copy(f, f + n, o);
  817. }
  818. STLSOFT_TEMPLATE_SPECIALISATION
  819. inline acestl_ns_qual(message_queue_sequence)<ACE_NULL_SYNCH>::iterator copy_n( signed char* f
  820. , ss_size_t n
  821. , acestl_ns_qual(message_queue_sequence)<ACE_NULL_SYNCH>::iterator o)
  822. {
  823. return acestl_ns_qual(message_queue_sequence)<ACE_NULL_SYNCH>::fast_copy(stlsoft_ns_qual(sap_cast)<char const*>(f), stlsoft_ns_qual(sap_cast)<char const*>(f) + n, o);
  824. }
  825. STLSOFT_TEMPLATE_SPECIALISATION
  826. inline acestl_ns_qual(message_queue_sequence)<ACE_MT_SYNCH>::iterator copy_n( signed char* f
  827. , ss_size_t n
  828. , acestl_ns_qual(message_queue_sequence)<ACE_MT_SYNCH>::iterator o)
  829. {
  830. return acestl_ns_qual(message_queue_sequence)<ACE_MT_SYNCH>::fast_copy(stlsoft_ns_qual(sap_cast)<char const*>(f), stlsoft_ns_qual(sap_cast)<char const*>(f) + n, o);
  831. }
  832. STLSOFT_TEMPLATE_SPECIALISATION
  833. inline acestl_ns_qual(message_queue_sequence)<ACE_NULL_SYNCH>::iterator copy_n( unsigned char* f
  834. , ss_size_t n
  835. , acestl_ns_qual(message_queue_sequence)<ACE_NULL_SYNCH>::iterator o)
  836. {
  837. return acestl_ns_qual(message_queue_sequence)<ACE_NULL_SYNCH>::fast_copy(stlsoft_ns_qual(sap_cast)<char const*>(f), stlsoft_ns_qual(sap_cast)<char const*>(f) + n, o);
  838. }
  839. STLSOFT_TEMPLATE_SPECIALISATION
  840. inline acestl_ns_qual(message_queue_sequence)<ACE_MT_SYNCH>::iterator copy_n( unsigned char* f
  841. , ss_size_t n
  842. , acestl_ns_qual(message_queue_sequence)<ACE_MT_SYNCH>::iterator o)
  843. {
  844. return acestl_ns_qual(message_queue_sequence)<ACE_MT_SYNCH>::fast_copy(stlsoft_ns_qual(sap_cast)<char const*>(f), stlsoft_ns_qual(sap_cast)<char const*>(f) + n, o);
  845. }
  846. STLSOFT_TEMPLATE_SPECIALISATION
  847. inline acestl_ns_qual(message_queue_sequence)<ACE_NULL_SYNCH>::iterator copy_n( char const* f
  848. , ss_size_t n
  849. , acestl_ns_qual(message_queue_sequence)<ACE_NULL_SYNCH>::iterator o)
  850. {
  851. return acestl_ns_qual(message_queue_sequence)<ACE_NULL_SYNCH>::fast_copy(f, f + n, o);
  852. }
  853. STLSOFT_TEMPLATE_SPECIALISATION
  854. inline acestl_ns_qual(message_queue_sequence)<ACE_MT_SYNCH>::iterator copy_n( char const* f
  855. , ss_size_t n
  856. , acestl_ns_qual(message_queue_sequence)<ACE_MT_SYNCH>::iterator o)
  857. {
  858. return acestl_ns_qual(message_queue_sequence)<ACE_MT_SYNCH>::fast_copy(f, f + n, o);
  859. }
  860. STLSOFT_TEMPLATE_SPECIALISATION
  861. inline acestl_ns_qual(message_queue_sequence)<ACE_NULL_SYNCH>::iterator copy_n( signed char const* f
  862. , ss_size_t n
  863. , acestl_ns_qual(message_queue_sequence)<ACE_NULL_SYNCH>::iterator o)
  864. {
  865. return acestl_ns_qual(message_queue_sequence)<ACE_NULL_SYNCH>::fast_copy(stlsoft_ns_qual(sap_cast)<char const*>(f), stlsoft_ns_qual(sap_cast)<char const*>(f) + n, o);
  866. }
  867. STLSOFT_TEMPLATE_SPECIALISATION
  868. inline acestl_ns_qual(message_queue_sequence)<ACE_MT_SYNCH>::iterator copy_n( signed char const* f
  869. , ss_size_t n
  870. , acestl_ns_qual(message_queue_sequence)<ACE_MT_SYNCH>::iterator o)
  871. {
  872. return acestl_ns_qual(message_queue_sequence)<ACE_MT_SYNCH>::fast_copy(stlsoft_ns_qual(sap_cast)<char const*>(f), stlsoft_ns_qual(sap_cast)<char const*>(f) + n, o);
  873. }
  874. STLSOFT_TEMPLATE_SPECIALISATION
  875. inline acestl_ns_qual(message_queue_sequence)<ACE_NULL_SYNCH>::iterator copy_n( unsigned char const* f
  876. , ss_size_t n
  877. , acestl_ns_qual(message_queue_sequence)<ACE_NULL_SYNCH>::iterator o)
  878. {
  879. return acestl_ns_qual(message_queue_sequence)<ACE_NULL_SYNCH>::fast_copy(stlsoft_ns_qual(sap_cast)<char const*>(f), stlsoft_ns_qual(sap_cast)<char const*>(f) + n, o);
  880. }
  881. STLSOFT_TEMPLATE_SPECIALISATION
  882. inline acestl_ns_qual(message_queue_sequence)<ACE_MT_SYNCH>::iterator copy_n( unsigned char const* f
  883. , ss_size_t n
  884. , acestl_ns_qual(message_queue_sequence)<ACE_MT_SYNCH>::iterator o)
  885. {
  886. return acestl_ns_qual(message_queue_sequence)<ACE_MT_SYNCH>::fast_copy(stlsoft_ns_qual(sap_cast)<char const*>(f), stlsoft_ns_qual(sap_cast)<char const*>(f) + n, o);
  887. }
  888. #ifndef _STLSOFT_NO_NAMESPACE
  889. } // namespace stlsoft
  890. #endif /* !_STLSOFT_NO_NAMESPACE */
  891. /* ////////////////////////////////////////////////////////////////////// */
  892. #endif /* ACESTL_INCL_ACESTL_COLLECTIONS_HPP_MESSAGE_QUEUE_SEQUENCE */
  893. /* ///////////////////////////// end of file //////////////////////////// */