1
//---------------------------------------------------------------------------
3
// Project: OpenWalnut ( http://www.openwalnut.org )
5
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6
// For more information see http://www.openwalnut.org/copying
8
// This file is part of OpenWalnut.
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.
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.
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/>.
23
//---------------------------------------------------------------------------
25
#ifndef WPROPERTYCONSTRAINTNOTEMPTY_H
26
#define WPROPERTYCONSTRAINTNOTEMPTY_H
28
#include "../WPropertyTypes.h"
29
#include "WPropertyConstraintTypes.h"
32
* This class allows constraining properties to be not empty. This is especially useful for strings. This works on all types
33
* providing an empty() member function (as std::string and boost::filesystem::path do).
35
template< typename T >
36
class WPropertyConstraintNotEmpty: public WPropertyVariable< T >::PropertyConstraint
42
explicit WPropertyConstraintNotEmpty();
47
virtual ~WPropertyConstraintNotEmpty();
50
* Checks whether the specified new value is larger or equal to the specified min value.
52
* \param property the property whose new value should be set.
53
* \param value the new value to check
55
* \return true if value >= m_min
57
virtual bool accept( boost::shared_ptr< WPropertyVariable< T > > property, T value );
60
* Allows simple identification of the real constraint type.
64
virtual PROPERTYCONSTRAINT_TYPE getType();
67
* Method to clone the constraint and create a new one with the correct dynamic type.
69
* \return the constraint.
71
virtual boost::shared_ptr< typename WPropertyVariable< T >::PropertyConstraint > clone();
76
template < typename T >
77
WPropertyConstraintNotEmpty< T >::WPropertyConstraintNotEmpty()
81
template < typename T >
82
WPropertyConstraintNotEmpty< T >::~WPropertyConstraintNotEmpty()
86
template < typename T >
87
bool WPropertyConstraintNotEmpty< T >::accept( boost::shared_ptr< WPropertyVariable< T > > /* property */, T value )
89
return !value.empty();
92
template < typename T >
93
PROPERTYCONSTRAINT_TYPE WPropertyConstraintNotEmpty< T >::getType()
98
template < typename T >
99
boost::shared_ptr< typename WPropertyVariable< T >::PropertyConstraint > WPropertyConstraintNotEmpty< T >::clone()
101
return boost::shared_ptr< typename WPropertyVariable< T >::PropertyConstraint >( new WPropertyConstraintNotEmpty< T >( *this ) );
104
#endif // WPROPERTYCONSTRAINTNOTEMPTY_H