33 #include "WMDataTypeConversion.h"
34 #include "WMDataTypeConversion.xpm"
35 #include "core/common/WAssert.h"
36 #include "core/common/WProgress.h"
37 #include "core/common/WStringUtils.h"
38 #include "core/dataHandler/WDataHandlerEnums.h"
39 #include "core/dataHandler/WDataSetScalar.h"
40 #include "core/dataHandler/WGridRegular3D.h"
41 #include "core/kernel/WKernel.h"
66 return datatypeconversion_xpm;
71 return "Data Type Conversion";
76 return "This module is intended for development use only. Modules for general use should not depend on it.<br><br> "
77 "Allows one to change the data type of the provided WDataSetSingle to another type. "
78 "E.g., double to float.";
84 template<
class TargetType >
85 class VisitorVSet:
public boost::static_visitor< std::shared_ptr< WValueSetBase > >
92 boost::static_visitor< result_type >()
104 template <
typename T >
107 std::shared_ptr< std::vector< TargetType > > newVals(
new std::vector< TargetType >( vals->size() ) );
108 for(
size_t i = 0; i < newVals->size(); ++i )
110 ( *newVals )[i] =
static_cast< TargetType
>( vals->getScalar( i ) );
113 std::shared_ptr< WValueSet< TargetType > > valueSet(
143 debugLog() <<
"Waiting for data ...";
148 std::shared_ptr< WValueSetBase > valueSet;
151 if( dataTypeName ==
"UINT8" )
154 valueSet =
m_dataSet->getValueSet()->applyFunction( visitor );
156 else if( dataTypeName ==
"UINT16" )
159 valueSet =
m_dataSet->getValueSet()->applyFunction( visitor );
161 else if( dataTypeName ==
"UINT32" )
164 valueSet =
m_dataSet->getValueSet()->applyFunction( visitor );
166 else if( dataTypeName ==
"UINT64" )
169 valueSet =
m_dataSet->getValueSet()->applyFunction( visitor );
171 else if( dataTypeName ==
"INT8" )
174 valueSet =
m_dataSet->getValueSet()->applyFunction( visitor );
176 else if( dataTypeName ==
"INT16" )
179 valueSet =
m_dataSet->getValueSet()->applyFunction( visitor );
181 else if( dataTypeName ==
"INT32" )
184 valueSet =
m_dataSet->getValueSet()->applyFunction( visitor );
186 else if( dataTypeName ==
"INT64" )
189 valueSet =
m_dataSet->getValueSet()->applyFunction( visitor );
191 else if( dataTypeName ==
"FLOAT" )
194 valueSet =
m_dataSet->getValueSet()->applyFunction( visitor );
196 else if( dataTypeName ==
"DOUBLE" )
199 valueSet =
m_dataSet->getValueSet()->applyFunction( visitor );
201 else if( dataTypeName ==
"FLOAT128" )
204 valueSet =
m_dataSet->getValueSet()->applyFunction( visitor );
208 throw WException(
"Not supported data type while reading raw data." );
220 m_input = std::shared_ptr<WModuleInputData<WDataSetSingle> >(
222 "The dataset whose values' type should be converted." ) );
228 m_output = std::shared_ptr<WModuleOutputData<WDataSetSingle> >(
230 "The converted dataset." ) );
Visitor for discriminating the type of the first valueset.
VisitorVSet()
Create visitor instance and convert it to the given input type.
result_type operator()(const WValueSet< T > *const &vals) const
Called by boost::varying during static visiting.
virtual void wait() const
Wait for the condition.
virtual void add(std::shared_ptr< WCondition > condition)
Adds another condition to the set of conditions to wait for.
Class to encapsulate boost::condition_variable_any.
This data set type contains scalars as values.
A class containing a list of named items.
Provides a new field with the approximately the same data, but with another data type.
WPropSelection m_dataTypeSelection
Selection.
std::shared_ptr< WModuleOutputData< WDataSetSingle > > m_output
The only output of this filter module.
std::shared_ptr< WItemSelection > m_dataTypeSelectionsList
A list of file type selection types.
~WMDataTypeConversion()
Destructor.
virtual const std::string getName() const
Gives back the name of this module.
virtual void moduleMain()
Entry point after loading the module.
virtual void properties()
Initialize the properties for this module.
virtual const char ** getXPMIcon() const
Get the icon for this module in XPM format.
WMDataTypeConversion()
Standard constructor.
virtual std::shared_ptr< WModule > factory() const
Due to the prototype design pattern used to build modules, this method returns a new instance of this...
virtual const std::string getDescription() const
Gives back a description of this module.
std::shared_ptr< WDataSetSingle > m_dataSet
Pointer providing access to the treated data set in the whole module.
virtual void connectors()
Initialize the connectors this module is using.
std::shared_ptr< WCondition > m_propCondition
A condition used to notify about changes in several properties.
std::shared_ptr< WModuleInputData< WDataSetSingle > > m_input
Input connector required by this module.
Class representing a single module of OpenWalnut.
virtual void properties()
Initialize properties in this function.
wlog::WStreamedLogger debugLog() const
Logger instance for comfortable debug logging.
void removeConnectors()
Removes all connectors properly.
void addConnector(std::shared_ptr< WModuleInputConnector > con)
Adds the specified connector to the list of inputs.
std::shared_ptr< WProperties > m_properties
The property object for the module.
void ready()
Call this whenever your module is ready and can react on property changes.
WConditionSet m_moduleState
The internal state of the module.
virtual void connectors()
Initialize connectors in this function.
WBoolFlag m_shutdownFlag
Condition getting fired whenever the thread should quit.
Base Class for all value set types.
void addTo(WPropSelection prop)
Add the PC_SELECTONLYONE constraint to the property.
An object that knows an appropriate dataType flag for the typename T.