listlocked_test.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  tag: The SourceWorks Tue Sep 7 00:54:57 CEST 2010 listlocked_test.cpp
3 
4  listlocked_test.cpp - description
5  -------------------
6  begin : Tue September 07 2010
7  copyright : (C) 2010 The SourceWorks
8  email : peter@thesourceworks.com
9 
10  ***************************************************************************
11  * *
12  * This program is free software; you can redistribute it and/or modify *
13  * it under the terms of the GNU General Public License as published by *
14  * the Free Software Foundation; either version 2 of the License, or *
15  * (at your option) any later version. *
16  * *
17  ***************************************************************************/
18 
19 
20 #include "unit.hpp"
21 
22 #include <internal/ListLocked.hpp>
23 #include <boost/bind/protect.hpp>
24 #include <rtt-detail-fwd.hpp>
25 using namespace RTT::detail;
26 
27 using namespace std;
28 using namespace RTT;
29 using namespace boost;
30 
31 void foo(double d)
32 {
33 }
34 
35 
36 struct ListTest
37 {
38  struct Cont : public boost::intrusive::list_base_hook<> {
39  double data;
40  };
41  typedef boost::intrusive::list<Cont> BufferType;
42 
43  BufferType mlist;
44 
45  void mfoo(double d)
46  {}
47 
48  double mcfoo(Cont& c)
49  {
50  return c.data;
51  }
52 
53  template<class Function>
54  static void apply_item(Function func, Cont& c)
55  {
56  //func( c->data );
57  }
58 
59  template<class Function>
60  void apply( Function func )
61  {
62  //std::for_each (mlist.begin(), mlist.end(), boost::bind( &ListTest::apply_item<Function>, boost::protect(func), _1) );
63  for (BufferType::iterator it = mlist.begin(); it != mlist.end(); ++it)
64  func( it->data );
65  }
66 };
67 
69 {
70 }
71 
72 bool iffoo(double d)
73 {
74  return true;
75 }
76 
77 
78 BOOST_FIXTURE_TEST_SUITE( ListTestSuite, ListTest )
79 
80 BOOST_AUTO_TEST_CASE( test_instatiation )
81 {
82 
83  ListLocked<double> lld(10);
84 
85  typedef boost::shared_ptr<double*> dsp;
86 
87  ListLocked<dsp> lldsp(10);
88 }
89 
90 BOOST_AUTO_TEST_CASE( test_apply )
91 {
92 
93  std::for_each (mlist.begin(), mlist.end(), boost::bind( &ListTestSuite::test_apply::mcfoo, this, _1) );
94 
95  //std::for_each (mlist.begin(), mlist.end(), boost::bind( &ListTest::apply_item, this, boost::protect(boost::bind(foo, _1)), _1) );
96  //std::for_each (mlist.begin(), mlist.end(), boost::bind( boost::mem_fn(&ListTestSuite::test_apply::apply_item<void(double)>), this, boost::bind(foo, _1), _1) );
97 
98  Cont c;
99  //boost::bind( &ListTestSuite::test_apply::apply_item, this, boost::protect( boost::bind(foo,_1)), _1)(c);
100 
101  apply( boost::bind(&foo,_1) );
102 
103 #if 1
104  ListLocked<double> lld(10);
105 
106  typedef boost::shared_ptr<double*> dsp;
107 
108  ListLocked<dsp> lldsp(10);
109 
110  lld.apply( boost::bind( foo, _1 ) );
111 #endif
112 
113  lld.clear();
114 
115  lldsp.clear();
116 
117  lld.find_if(&iffoo);
118 }
119 
121 
#define BOOST_FIXTURE_TEST_SUITE(suite_name, F)
BufferType mlist
void cfoo(ListTest::Cont &c)
#define BOOST_AUTO_TEST_SUITE_END()
Definition: mystd.hpp:163
BOOST_AUTO_TEST_CASE(test_instatiation)
void apply(Function func)
Definition: ListLocked.hpp:274
bool iffoo(double d)
value_t find_if(Function func, value_t blank=value_t())
Definition: ListLocked.hpp:288
static void apply_item(Function func, Cont &c)
boost::intrusive::list< Cont > BufferType
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
Definition: Activity.cpp:53
double mcfoo(Cont &c)
void apply(Function func)
void foo(double d)
void mfoo(double d)


rtt
Author(s): RTT Developers
autogenerated on Fri Oct 25 2019 03:59:33