COOLFluiD  Release kernel
COOLFluiD is a Collaborative Simulation Environment (CSE) focused on complex MultiPhysics simulations.
ComponentWrapper.hpp
Go to the documentation of this file.
1 // Copyright (C) 2010-2011 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 
8 #ifndef cf3_solver_actions_Proto_ComponentWrapper_hpp
9 #define cf3_solver_actions_Proto_ComponentWrapper_hpp
10 
11 #include <boost/proto/core.hpp>
12 
13 #include "common/Log.hpp"
15 #include "common/Signal.hpp"
16 
19 
20 namespace cf3 {
21 namespace solver {
22 namespace actions {
23 namespace Proto {
24 
29 template<typename ComponentT, typename TagT>
31 {
32 public:
33 
34  typedef TagT tag_type;
35 
39  m_component( new Handle<ComponentT>(component.template handle<ComponentT>()) )
40  {
42  }
43 
45  ComponentWrapperImpl(common::Option& component_option) :
46  m_component( new Handle<ComponentT>() )
47  {
48  component_option.link_to(m_component.get()).attach_trigger(boost::bind(&ComponentWrapperImpl::trigger_component, this));
50  }
51 
53  ComponentT& component()
54  {
55 // if(is_null(m_component))
56 // throw common::SetupError(FromHere(), "ComponentWrapperImpl points to a null component");
58  return *m_cached_component;
59  }
60 
61 private:
64  boost::shared_ptr< Handle<ComponentT> > m_component;
65  ComponentT* m_cached_component;
66 
68  {
69  m_cached_component = m_component->get();
70  }
71 };
72 
74 template<typename ComponentT, typename TagT>
76  public boost::proto::extends< boost::proto::literal< ComponentWrapperImpl<ComponentT, TagT>& >, ComponentWrapper<ComponentT, TagT> >
77 {
78 public:
79 
80  typedef boost::proto::extends< boost::proto::literal< ComponentWrapperImpl<ComponentT, TagT>& >, ComponentWrapper<ComponentT, TagT> > base_type;
81 
84  ComponentWrapper(ComponentT& component) :
85  m_component_wrapper(component),
86  base_type(m_component_wrapper)
87  {
88  }
89 
91  ComponentWrapper(common::Option& component_option) :
92  m_component_wrapper(component_option),
93  base_type(m_component_wrapper)
94  {
95  }
96 
97 private:
100 };
101 
102 } // namespace Proto
103 } // namespace actions
104 } // namespace solver
105 } // namespace cf3
106 
107 #endif // cf3_solver_actions_Proto_ComponentWrapper_hpp
Adds fonctionnalities to Property class.
Definition: Option.hpp:76
Option & link_to(TYPE *par)
Definition: Option.hpp:192
Safe pointer to an object. This is the supported method for referring to components.
Definition: Handle.hpp:39
ComponentWrapper(common::Option &component_option)
Construction using an option that will point to the actual component.
ComponentWrapperImpl(common::Option &component_option)
Construction using an option that will point to the actual component.
#define cf3_assert(a)
Definition: Assertions.hpp:93
boost::proto::extends< boost::proto::literal< ComponentWrapperImpl< ComponentT, TagT > & >, ComponentWrapper< ComponentT, TagT > > base_type
boost::shared_ptr< Handle< ComponentT > > m_component
Top-level namespace for coolfluid.
Definition: Action.cpp:18
ComponentT & component()
Return the wrapped component.
Proto-ready terminal type for wrapping a component.
ComponentWrapperImpl< ComponentT, TagT > m_component_wrapper
Points to the wrapped component, if any.
bool is_not_null(T ptr)
predicate for comparison to nullptr
Definition: CF.hpp:147
Send comments to:
COOLFluiD Web Admin