COOLFluiD  Release kernel
COOLFluiD is a Collaborative Simulation Environment (CSE) focused on complex MultiPhysics simulations.
utest-static-sub-component.cpp
Go to the documentation of this file.
1 // Copyright (C) 2010-2013 von Karman Institute for Fluid Dynamics, Belgium
2 //
3 // This software is distributed under the terms of the
4 // GNU Lesser General Public License version 3 (LGPLv3).
5 // See doc/lgpl.txt and doc/gpl.txt for the license text.
6 
7 #define BOOST_TEST_DYN_LINK
8 #define BOOST_TEST_MODULE "Test module for static sub-components"
9 
10 #include <boost/test/unit_test.hpp>
11 
12 #include <boost/foreach.hpp>
13 #include <boost/iterator.hpp>
14 
15 #include "common/Log.hpp"
16 #include "common/Component.hpp"
18 #include "common/Group.hpp"
19 #include "common/Link.hpp"
20 
21 using namespace std;
22 using namespace boost;
23 
24 using namespace cf3;
25 using namespace cf3::common;
26 
28 
29 class Part : public Component
30 {
31 
32 public: // functions
33 
34  Part ( const std::string& name ) : Component(name)
35  {
36  }
37 
38  virtual ~Part() {}
39 
40  static std::string type_name () { return std::string("Part"); }
41 
42 }; // HolderT
43 
45 
46 template < typename SubCompT >
47 class HolderT : public Component
48 {
49 public: // functions
50 
51  HolderT ( const std::string& name ) :
52  Component(name),
53  m_subcomp (create_static_component<SubCompT>("subc"))
54  {
55  }
56 
57  virtual ~HolderT() {}
58 
59  static std::string type_name () { return std::string("HolderT_") + SubCompT::type_name(); }
60 
61 private: // data
62 
64 
65 }; // HolderT
66 
68 
69 BOOST_AUTO_TEST_SUITE( StaticSubComponent_TestSuite )
70 
71 
73 BOOST_AUTO_TEST_CASE( add_component )
74 {
75  boost::shared_ptr<Component> root = boost::static_pointer_cast<Component>(allocate_component<Group>("root"));
76 
77  Handle<Component> cp = root->create_component< HolderT<Part> >( "myHolderT_Part" );
78 
79  BOOST_CHECK_EQUAL ( HolderT<Part>::type_name() , "HolderT_Part" );
80 
82 // BOOST_CHECK_NO_THROW ( cp->get_child_ptr("subc").get() );
83 
84  BOOST_CHECK_EQUAL ( cp->name(), std::string("myHolderT_Part"));
85 
86 }
87 
89 
90 BOOST_AUTO_TEST_SUITE_END()
91 
92 
std::string name(ComponentWrapper &self)
external boost library namespace
Part(const std::string &name)
static std::string type_name()
static std::string type_name()
STL namespace.
std::string type_name(const boost::python::api::object &python_object)
Definition: PythonAny.cpp:283
const std::string & name() const
Access the name of the component.
Definition: Component.hpp:146
tuple root
Definition: coolfluid.py:24
Holds the Component class, as well as the ComponentIterator class plus some functions related to comp...
Top-level namespace for coolfluid.
Definition: Action.cpp:18
HolderT(const std::string &name)
Handle< SubCompT > m_subcomp
BOOST_AUTO_TEST_CASE(add_component)
Base class for defining CF components.
Definition: Component.hpp:82
Most basic kernel library.
Definition: Action.cpp:19
Send comments to:
COOLFluiD Web Admin