OpenWalnut
1.2.5
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
All
Classes
Namespaces
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
src
core
common
constraints
WPropertyConstraintSelectOnlyOne.h
1
//---------------------------------------------------------------------------
2
//
3
// Project: OpenWalnut ( http://www.openwalnut.org )
4
//
5
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6
// For more information see http://www.openwalnut.org/copying
7
//
8
// This file is part of OpenWalnut.
9
//
10
// OpenWalnut is free software: you can redistribute it and/or modify
11
// it under the terms of the GNU Lesser General Public License as published by
12
// the Free Software Foundation, either version 3 of the License, or
13
// (at your option) any later version.
14
//
15
// OpenWalnut is distributed in the hope that it will be useful,
16
// but WITHOUT ANY WARRANTY; without even the implied warranty of
17
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
// GNU Lesser General Public License for more details.
19
//
20
// You should have received a copy of the GNU Lesser General Public License
21
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22
//
23
//---------------------------------------------------------------------------
24
25
#ifndef WPROPERTYCONSTRAINTSELECTONLYONE_H
26
#define WPROPERTYCONSTRAINTSELECTONLYONE_H
27
28
#include "../WPropertyTypes.h"
29
#include "WPropertyConstraintTypes.h"
30
31
/**
32
* This class allows constraining selection properties to not allow selection of multiple items.
33
*/
34
template
<
typename
T >
35
class
WPropertyConstraintSelectOnlyOne
:
public
WPropertyVariable
< T >
::PropertyConstraint
36
{
37
public
:
38
/**
39
* Constructor.
40
*/
41
explicit
WPropertyConstraintSelectOnlyOne
();
42
43
/**
44
* Destructor.
45
*/
46
virtual
~WPropertyConstraintSelectOnlyOne
();
47
48
/**
49
* Checks whether the specified value is a directory or not.
50
*
51
* \param property the property whose new value should be set.
52
* \param value the new value to check
53
*
54
* \return true if the file/path is a directory
55
*/
56
virtual
bool
accept
( boost::shared_ptr<
WPropertyVariable< T >
> property, T value );
57
58
/**
59
* Allows simple identification of the real constraint type.
60
*
61
* \return the type
62
*/
63
virtual
PROPERTYCONSTRAINT_TYPE
getType
();
64
65
/**
66
* Method to clone the constraint and create a new one with the correct dynamic type.
67
*
68
* \return the constraint.
69
*/
70
virtual
boost::shared_ptr< typename WPropertyVariable< T >::PropertyConstraint >
clone
();
71
72
private
:
73
};
74
75
template
<
typename
T >
76
WPropertyConstraintSelectOnlyOne< T >::WPropertyConstraintSelectOnlyOne
()
77
{
78
}
79
80
template
<
typename
T >
81
WPropertyConstraintSelectOnlyOne< T >::~WPropertyConstraintSelectOnlyOne
()
82
{
83
}
84
85
template
<
typename
T >
86
bool
WPropertyConstraintSelectOnlyOne< T >::accept
( boost::shared_ptr<
WPropertyVariable< T >
>
/* property */
, T value )
87
{
88
return
( value.size() <= 1 );
89
}
90
91
template
<
typename
T >
92
PROPERTYCONSTRAINT_TYPE
WPropertyConstraintSelectOnlyOne< T >::getType
()
93
{
94
return
PC_SELECTONLYONE;
95
}
96
97
template
<
typename
T >
98
boost::shared_ptr< typename WPropertyVariable< T >::PropertyConstraint >
WPropertyConstraintSelectOnlyOne< T >::clone
()
99
{
100
return
boost::shared_ptr< typename WPropertyVariable< T >::PropertyConstraint >(
new
WPropertyConstraintSelectOnlyOne< T >
( *this ) );
101
}
102
103
#endif // WPROPERTYCONSTRAINTSELECTONLYONE_H
104
Generated by
1.8.1.2