OpenWalnut  1.5.0dev
WColumnPropertyHandler.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 WCOLUMNPROPERTYHANDLER_H
26 #define WCOLUMNPROPERTYHANDLER_H
27 
28 #include <list>
29 #include <map>
30 #include <memory>
31 #include <string>
32 #include <tuple>
33 #include <vector>
34 
35 #include <boost/function.hpp>
36 
37 #include "../WDataType.h"
38 #include "../WProtonData.h"
39 #include "../WSingleSelectorName.h"
40 #include "core/common/WItemSelectionItemTyped.h"
41 
42 
43 
44 /**
45  * Creates, updates and handles the column properties.
46  */
48 {
49 public:
50  /**
51  * tuple with 3 string as value
52  * 1. Name of single-selector,
53  * 2. Desciption of single-selector,
54  * 3. Value that is searched for in the csv header
55  */
56  typedef std::tuple< std::string, std::string, std::string, std::list< std::string > > NameDescriptionSearchTyp;
57 
58  /**
59  * Function variables for updating the data
60  */
61  typedef boost::function< void( ) > CallbackPtr;
62 
63  /**
64  * shared_ptr that points to itself
65  */
66  typedef std::shared_ptr< WColumnPropertyHandler > SPtr;
67 
68  /**
69  * constructor
70  *
71  * \param protonData Pointer to the content and header of the CSV
72  * \param properties A property variable that is generated by the WModul
73  * \param dataUpdate A function variable that reinitializes the WDataSets
74  */
75  explicit WColumnPropertyHandler( WProtonData::SPtr protonData,
76  WPropertyGroup::SPtr properties,
78 
79  /**
80  * creates the group property and the subproperty
81  */
82  void createProperties();
83 
84  /**
85  * update current group property and subproperty
86  */
87  void updateProperty();
88 
89  /**
90  * setter to use a external function
91  * \param externEventMethod A void function variable that can be use outside
92  */
94 
95 private:
96  /**
97  * A map between WPropSelection items and column names as strings
98  */
99  std::map< WPropSelection, std::string > mapPropSelectionsToString;
100 
101  /**
102  * Pointer to the content and header of the CSV
103  */
105 
106  /**
107  * A property variable that is generated by the WModul
108  */
110 
111  /**
112  * A function variable that reinitializes the WDataSets
113  */
115 
116  /**
117  * A void function variable that can be use outside
118  */
120 
121  /**
122  * Creates the individual WItemSelection
123  * \param ndst ( n = Name, d = Description, s = Search, t = Typ )
124  * \param notifier The notifier for the property
125  * \return WPropSelection The created selection
126  */
129 
130  /**
131  * Event function when WItemSelection is triggered
132  * \param property The changed property
133  */
134  void propertyNotifier( WPropertyBase::SPtr property );
135 
136  /**
137  * Property group for column selection
138  */
140 
141  /**
142  * represents the item type for item-selection
143  */
145 
146  /**
147  * Reresents an entry in a < WPropSelection, string > map
148  */
149  typedef std::map< WPropSelection, std::string >::iterator PropMapEntry;
150 
151  /**
152  * creates the content (options) of the WItemSelection
153  * \param typeName Type of column.
154  * \return content of WItemSelection
155  */
156  std::shared_ptr< WItemSelection > initializeSelectionItem( std::list< std::string > typeName );
157 
158  /**
159  * converts the index to the filtered index
160  * \param index index to search.
161  * \param typeName List of column types.
162  * \return filterd index
163  */
164  int getFilterIndex( int index, std::list< std::string > typeName );
165 };
166 
167 #endif // WCOLUMNPROPERTYHANDLER_H
Creates, updates and handles the column properties.
void propertyNotifier(WPropertyBase::SPtr property)
Event function when WItemSelection is triggered.
std::tuple< std::string, std::string, std::string, std::list< std::string > > NameDescriptionSearchTyp
tuple with 3 string as value
std::map< WPropSelection, std::string >::iterator PropMapEntry
Reresents an entry in a < WPropSelection, string > map.
WPropertyGroup::SPtr m_properties
A property variable that is generated by the WModul.
std::shared_ptr< WColumnPropertyHandler > SPtr
shared_ptr that points to itself
WPropSelection addHeaderProperty(WColumnPropertyHandler::NameDescriptionSearchTyp ndst, WPropertyBase::PropertyChangeNotifierType notifier)
Creates the individual WItemSelection.
std::shared_ptr< WItemSelection > initializeSelectionItem(std::list< std::string > typeName)
creates the content (options) of the WItemSelection
void updateProperty()
update current group property and subproperty
WPropGroup m_columnSelectionGroup
Property group for column selection.
WColumnPropertyHandler::CallbackPtr m_externEventMethod
A void function variable that can be use outside.
WColumnPropertyHandler::CallbackPtr m_dataUpdate
A function variable that reinitializes the WDataSets.
WItemSelectionItemTyped< std::string > ItemType
represents the item type for item-selection
void createProperties()
creates the group property and the subproperty
std::map< WPropSelection, std::string > mapPropSelectionsToString
A map between WPropSelection items and column names as strings.
void setSelectionEventMethod(WColumnPropertyHandler::CallbackPtr externEventMethod)
setter to use a external function
WColumnPropertyHandler(WProtonData::SPtr protonData, WPropertyGroup::SPtr properties, WColumnPropertyHandler::CallbackPtr dataUpdate)
constructor
boost::function< void() > CallbackPtr
Function variables for updating the data.
int getFilterIndex(int index, std::list< std::string > typeName)
converts the index to the filtered index
WProtonData::SPtr m_protonData
Pointer to the content and header of the CSV.
A derivation of WItemSelection which can store a value of any type.
boost::function< void(std::shared_ptr< WPropertyBase >)> PropertyChangeNotifierType
Signal signature emitted during set operations.
std::shared_ptr< WPropertyBase > SPtr
Convenience typedef for a std::shared_ptr< WPropertyBase >
Definition: WPropertyBase.h:53
std::shared_ptr< WPropertyGroup > SPtr
shared pointer to object of this type
std::shared_ptr< WProtonData > SPtr
shared_ptr that points to itself
Definition: WProtonData.h:52