OpenWalnut  1.3.1
WPropertyConstraintIsDirectory.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 WPROPERTYCONSTRAINTISDIRECTORY_H
26 #define WPROPERTYCONSTRAINTISDIRECTORY_H
27 
28 #include "../WPropertyTypes.h"
29 #include "WPropertyConstraintTypes.h"
30 
31 /**
32  * This class allows constraining properties to be existing filenames. This is especially useful for WPropFilename.
33  */
34 template < typename T >
36 {
37 public:
38  /**
39  * Constructor.
40  */
42 
43  /**
44  * Destructor.
45  */
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, const 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 >
77 {
78 }
79 
80 template < typename T >
82 {
83 }
84 
85 template < typename T >
86 bool WPropertyConstraintIsDirectory< T >::accept( boost::shared_ptr< WPropertyVariable< T > > /* property */, const T& value )
87 {
88  return boost::filesystem::is_directory( value );
89 }
90 
91 template < typename T >
93 {
94  return PC_ISDIRECTORY;
95 }
96 
97 template < typename T >
98 boost::shared_ptr< typename WPropertyVariable< T >::PropertyConstraint > WPropertyConstraintIsDirectory< T >::clone()
99 {
100  return boost::shared_ptr< typename WPropertyVariable< T >::PropertyConstraint >( new WPropertyConstraintIsDirectory< T >( *this ) );
101 }
102 
103 
104 #endif // WPROPERTYCONSTRAINTISDIRECTORY_H
105