SMTK
@SMTK_VERSION@
Simulation Modeling Tool Kit
smtk
resource
query
DerivedFrom.h
1
//=========================================================================
2
// Copyright (c) Kitware, Inc.
3
// All rights reserved.
4
// See LICENSE.txt for details.
5
//
6
// This software is distributed WITHOUT ANY WARRANTY; without even
7
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
8
// PURPOSE. See the above copyright notice for more information.
9
//=========================================================================
10
#ifndef smtk_resource_query_DerivedFrom_h
11
#define smtk_resource_query_DerivedFrom_h
12
13
#include "smtk/CoreExports.h"
14
15
#include "smtk/resource/query/Query.h"
16
17
#include <typeindex>
18
19
namespace
smtk
20
{
21
namespace
resource
22
{
23
namespace
query
24
{
25
33
template
<
typename
SelfType,
typename
ParentType>
34
class
SMTK_ALWAYS_EXPORT
DerivedFrom
:
public
ParentType
35
{
36
static_assert(
37
std::is_base_of<Query, ParentType>::value,
38
"Queries must inherit from smtk::resource::query::Query or its children"
);
39
40
friend
class
Metadata
;
41
42
public
:
43
static
std::size_t typeIndex() {
return
typeid
(SelfType).hash_code(); }
44
45
protected
:
46
typedef
ParentType Parent;
47
51
static
int
numberOfGenerationsFromType
(
const
std::size_t index)
52
{
53
return
(
54
DerivedFrom<SelfType, Parent>::typeIndex
() == index
55
? 0
56
: 1 + Parent::numberOfGenerationsFromType(index));
57
}
58
};
59
}
// namespace query
60
}
// namespace resource
61
}
// namespace smtk
62
63
#endif
smtk
The main namespace for the Simulation Modeling Tool Kit (SMTK).
Definition:
doc.h:33
smtk::resource::query::Metadata
A structure to hold type and construction information about a Query type.
Definition:
Metadata.h:28
smtk::resource::query::DerivedFrom
Query functors can be registered to Resources as the implementation of a base (and often abstract) Qu...
Definition:
DerivedFrom.h:34
smtk::resource::query::DerivedFrom::numberOfGenerationsFromType
static int numberOfGenerationsFromType(const std::size_t index)
Return the number of generations from this instance to the type index of a parent,...
Definition:
DerivedFrom.h:51
Generated by
1.8.17