ControlSignatureTagBase.h 2.59 KB
Newer Older
1 2 3 4 5 6 7 8
//============================================================================
//  Copyright (c) Kitware, Inc.
//  All rights reserved.
//  See LICENSE.txt for details.
//  This software is distributed WITHOUT ANY WARRANTY; without even
//  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
//  PURPOSE.  See the above copyright notice for more information.
//
Kenneth Moreland's avatar
Kenneth Moreland committed
9
//  Copyright 2014 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
10
//  Copyright 2014 UT-Battelle, LLC.
11
//  Copyright 2014 Los Alamos National Security.
12
//
Kenneth Moreland's avatar
Kenneth Moreland committed
13
//  Under the terms of Contract DE-NA0003525 with NTESS,
14 15 16 17 18 19 20 21 22
//  the U.S. Government retains certain rights in this software.
//
//  Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
//  Laboratory (LANL), the U.S. Government retains certain rights in
//  this software.
//============================================================================
#ifndef vtk_m_cont_arg_ControlSignatureTagBase_h
#define vtk_m_cont_arg_ControlSignatureTagBase_h

23
#include <vtkm/StaticAssert.h>
24 25
#include <vtkm/internal/ExportMacros.h>

26
#include <type_traits>
27

28 29 30 31 32 33
namespace vtkm
{
namespace cont
{
namespace arg
{
34 35 36 37 38 39 40 41 42 43 44 45

/// \brief The base class for all tags used in a \c ControlSignature.
///
/// If a new \c ControlSignature tag is created, it must be derived from this
/// class in some way. This helps identify \c ControlSignature tags in the \c
/// VTKM_IS_CONTROL_SIGNATURE_TAG macro and allows checking the validity of a
/// \c ControlSignature.
///
/// In addition to inheriting from this base class, a \c ControlSignature tag
/// must define the following three typedefs: \c TypeCheckTag, \c TransportTag
/// and \c FetchTag.
///
46 47 48
struct ControlSignatureTagBase
{
};
49

50 51
namespace internal
{
52

53
template <typename ControlSignatureTag>
54 55
struct ControlSignatureTagCheck
{
56
  static constexpr bool Valid =
57
    std::is_base_of<vtkm::cont::arg::ControlSignatureTagBase, ControlSignatureTag>::value;
58 59 60 61 62 63 64 65 66
};

} // namespace internal

/// Checks that the argument is a proper tag for an \c ControlSignature. This
/// is a handy concept check when modifying tags or dispatching to make sure
/// that a template argument is actually an \c ControlSignature tag. (You can
/// get weird errors elsewhere in the code when a mistake is made.)
///
67 68 69
#define VTKM_IS_CONTROL_SIGNATURE_TAG(tag)                                                         \
  VTKM_STATIC_ASSERT_MSG(::vtkm::cont::arg::internal::ControlSignatureTagCheck<tag>::Valid,        \
                         "Provided a type that is not a valid ControlSignature tag.")
70 71 72 73 74
}
}
} // namespace vtkm::cont::arg

#endif //vtk_m_cont_arg_ControlSignatureTagBase_h