WSF
WsfCommMediumTypeIdentifier.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 2019 Infoscitex, a DCS 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 WSFCOMMMEDIUMTYPEIDENTIFIER_HPP
13#define WSFCOMMMEDIUMTYPEIDENTIFIER_HPP
14
15namespace wsf
16{
17namespace comm
18{
19namespace medium
20{
21
22template<class T>
23struct Role
24{
25 template<class U>
26 struct always_false : std::false_type
27 {
28 };
29 static_assert(
31 "Type has no medium role registered. Use the WSF_COMM_MEDIUM_DECLARE_ROLE_TYPE macro to register the type.");
32};
33
34#define WSF_COMM_MEDIUM_DECLARE_ROLE_TYPE(TYPE, ROLE) \
35 template<> \
36 struct Role<TYPE> : std::integral_constant<int, ROLE> \
37 { \
38 static_assert(std::is_base_of<Medium, TYPE>::value, \
39 "Cannot register medium role for type that does not derive from wsf::comm::medium::Medium"); \
40 static_assert(value > 0, "Medium role must be > 0"); \
41 };
42
43template<class T>
45{
46 constexpr operator int() const noexcept { return Role<T>::value; }
47};
48
55
56} // namespace medium
57} // namespace comm
58} // namespace wsf
59
60#endif
Definition WsfCommMedium.cpp:31
TypeIdentifier
Definition WsfCommMediumTypeIdentifier.hpp:50
@ cUNGUIDED
Definition WsfCommMediumTypeIdentifier.hpp:53
@ cGUIDED
Definition WsfCommMediumTypeIdentifier.hpp:52
@ cNONE
Definition WsfCommMediumTypeIdentifier.hpp:51
Definition WsfComm.cpp:34
Function definitions for those who need run-time access to the version.
Definition WsfComm.cpp:32
Definition WsfCommMediumTypeIdentifier.hpp:27
Definition WsfCommMediumTypeIdentifier.hpp:24
Definition WsfCommMediumTypeIdentifier.hpp:45
Copyrights Multiple, All Rights Reserved