COOLFluiD  Release kernel
COOLFluiD is a Collaborative Simulation Environment (CSE) focused on complex MultiPhysics simulations.
utest-cbuilder.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 component factory"
9 
10 #include <boost/test/unit_test.hpp>
11 
12 #include "common/Core.hpp"
13 #include "common/Builder.hpp"
14 #include "common/LibCommon.hpp"
15 
16 
17 using namespace std;
18 using namespace boost;
19 using namespace cf3;
20 using namespace cf3::common;
21 
22 //------------------------------------------------------------------------------------------
23 
25 {
30 };
31 
32 //------------------------------------------------------------------------------------------
33 
34 class CAbstract : public Component
35 {
36 public:
37 
38  CAbstract ( const std::string& name ) : Component(name) {}
39  virtual ~CAbstract() {}
40  static std::string type_name () { return "CAbstract"; }
41 
42 };
43 
44 class CConcrete1 : public CAbstract
45 {
46 public:
47 
48  CConcrete1 ( const std::string& name ) : CAbstract(name) {}
49  virtual ~CConcrete1() {}
50  static std::string type_name () { return "CConcrete1"; }
51 
52 };
53 
55 
56 BOOST_FIXTURE_TEST_SUITE( FactoryTest, Builder_fixture )
57 
58 
60 BOOST_AUTO_TEST_CASE( registration )
61 {
63 
64  boost::shared_ptr<CAbstract> ptr = build_component_abstract_type< CAbstract >("cf3.common.CConcrete1","acomp");
65 
66  BOOST_CHECK( is_not_null(ptr) );
67 
68  Core::instance().root().add_component(ptr);
69 
70  Handle<CConcrete1> ptr2 = Core::instance().root().create_component<CConcrete1>("cconc");
71 
72  BOOST_CHECK( ptr2 );
73 
74  Handle<CAbstract> cabs(ptr2);
75  BOOST_CHECK( cabs );
76 }
77 
79 
80 BOOST_AUTO_TEST_SUITE_END()
81 
82 
std::string name(ComponentWrapper &self)
~Builder_fixture()
common tear-down for each test case
external boost library namespace
Helper class to create the Builder and place it in the factory.
Definition: Builder.hpp:212
STL namespace.
CAbstract(const std::string &name)
static std::string type_name()
virtual ~CAbstract()
virtual ~CConcrete1()
Top-level namespace for coolfluid.
Definition: Action.cpp:18
BOOST_AUTO_TEST_CASE(registration)
Builder_fixture()
common setup for each test case
CConcrete1(const std::string &name)
Base class for defining CF components.
Definition: Component.hpp:82
Most basic kernel library.
Definition: Action.cpp:19
bool is_not_null(T ptr)
predicate for comparison to nullptr
Definition: CF.hpp:147
static std::string type_name()
Send comments to:
COOLFluiD Web Admin