WSF
WsfComponentListDefines.hpp
Go to the documentation of this file.
1// ****************************************************************************
2// CUI
3//
4// The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
5//
6// Copyright 2003-2015 The Boeing Company. All rights reserved.
7//
8// The use, dissemination or disclosure of data in this file is subject to
9// limitation or restriction. See accompanying README and LICENSE for details.
10// ****************************************************************************
11
12#ifndef WSFCOMPONENTLISTDEFINES_HPP
13#define WSFCOMPONENTLISTDEFINES_HPP
14
15// Some objects (WsfComm, WsfProcessor, and WsfSensor in particular, but there are a few others)
16// contain a component list that provides a mechanism to extend the object in an abstract way.
17// At strategic places in the object code has to be placed to invoke methods on registered
18// components. While the code is not complex, it is laborious to repeat the code in all the
19// places. Therefore, these macros are provided to do the work in a common and efficient manner.
20//
21// The are two assumptions that are made in these macros:
22//
23// 1) The component list member is visible and is accessible by the name 'mComponents'.
24// 2) A typedef exists that defines 'ComponentList' as the type of the component list.
25//
26// A lot of this could have been done with C++ function templates, but the invocation syntax
27// would have been UGLY.
28//
29// NOTE: All of these perform a HasComponents check for efficiency. This avoid creating the
30// component list iterator for an empty component list.
31
34#define WSF_CALL_VOID_COMPONENTS(METHOD, ARG) \
35 if (mComponents.HasComponents()) \
36 { \
37 for (auto component : mComponents) \
38 { \
39 component->METHOD(ARG); \
40 } \
41 }
42
43#endif
Copyrights Multiple, All Rights Reserved