diff --git a/src/phasicFlow/containers/Vector/stdVectorHelper.hpp b/src/phasicFlow/containers/Vector/stdVectorHelper.hpp index 210ea048..da92af10 100644 --- a/src/phasicFlow/containers/Vector/stdVectorHelper.hpp +++ b/src/phasicFlow/containers/Vector/stdVectorHelper.hpp @@ -28,7 +28,7 @@ Licence: #include "span.hpp" #include "iOstream.hpp" #include "iIstream.hpp" -#include "createDataIO.hpp" +#include "dataIO.hpp" #include "pFlowProcessors.hpp" namespace pFlow @@ -82,8 +82,8 @@ bool writeSpan( const IOPattern& iop) { - auto ioPtr = createDataIO(pFlowProcessors().localRunTypeName(), iop); - + auto ioPtr = dataIO::create(iop); + if(!ioPtr) { fatalErrorInFunction; @@ -141,8 +141,8 @@ bool readStdVector const IOPattern& iop ) { - auto ioPtr = createDataIO(pFlowProcessors().localRunTypeName(), iop); - + auto ioPtr = dataIO::create(iop); + if(!ioPtr) { fatalErrorInFunction; diff --git a/src/phasicFlow/streams/dataIO/createDataIO.hpp b/src/phasicFlow/streams/dataIO/createDataIO-old.hpp similarity index 100% rename from src/phasicFlow/streams/dataIO/createDataIO.hpp rename to src/phasicFlow/streams/dataIO/createDataIO-old.hpp diff --git a/src/phasicFlow/streams/dataIO/dataIOTemplate.cpp b/src/phasicFlow/streams/dataIO/dataIO.cpp similarity index 90% rename from src/phasicFlow/streams/dataIO/dataIOTemplate.cpp rename to src/phasicFlow/streams/dataIO/dataIO.cpp index 74efd812..f1b0974d 100644 --- a/src/phasicFlow/streams/dataIO/dataIOTemplate.cpp +++ b/src/phasicFlow/streams/dataIO/dataIO.cpp @@ -258,3 +258,32 @@ bool pFlow::dataIO::readData } } +template +pFlow::uniquePtr> + pFlow::dataIO::create(const IOPattern& iop) +{ + + word dataIOType = angleBracketsNames2( + "dataIO", + getTypeName(), + pFlowProcessors().localRunTypeName()); + + if(IOPatternvCtorSelector_.search(dataIOType)) + { + return IOPatternvCtorSelector_[dataIOType](iop); + } + else + { + printKeys + ( + fatalError << "Ctor Selector "<< dataIOType << " does not exist. \n" + <<"Avaiable ones are: \n\n" + , + IOPatternvCtorSelector_ + ); + fatalExit; + } + + return nullptr; +} + diff --git a/src/phasicFlow/streams/dataIO/dataIO.hpp b/src/phasicFlow/streams/dataIO/dataIO.hpp index 5f378953..04f28c79 100644 --- a/src/phasicFlow/streams/dataIO/dataIO.hpp +++ b/src/phasicFlow/streams/dataIO/dataIO.hpp @@ -28,6 +28,8 @@ Licence: #include "IOPattern.hpp" #include "iOstream.hpp" #include "iIstream.hpp" +#include "virtualConstructor.hpp" +#include "pFlowProcessors.hpp" @@ -98,6 +100,14 @@ public: virtual ~dataIO() = default; + create_vCtor + ( + dataIO, + IOPattern, + (const IOPattern& iop), + (iop) + ); + /// Write data to the end of file from all processors. /// This method should be called from all processors. bool writeData(iOstream& os, span data); @@ -106,6 +116,9 @@ public: iIstream& is, std::vector& data); + static + uniquePtr create(const IOPattern& iop); + }; template @@ -123,6 +136,6 @@ iOstream& operator<<(iOstream& os, const span& s) } -#include "dataIOTemplate.cpp" +#include "dataIO.cpp" #endif diff --git a/src/phasicFlow/streams/dataIO/dataIORegular.hpp b/src/phasicFlow/streams/dataIO/dataIORegular.hpp index faebc715..6773277a 100644 --- a/src/phasicFlow/streams/dataIO/dataIORegular.hpp +++ b/src/phasicFlow/streams/dataIO/dataIORegular.hpp @@ -30,6 +30,12 @@ class dataIORegular : public dataIO { +public: + + using DataIORegularType = dataIORegular; + + using DataIOType = dataIO; + protected: bool gatherData(span data ) override @@ -41,7 +47,7 @@ protected: public: - TypeInfo("dataIO"); + TypeInfoTemplate111("dataIO",T,"regular"); dataIORegular(const IOPattern& iop) : @@ -57,6 +63,13 @@ public: dataIORegular& operator=(dataIORegular&&) = default; ~dataIORegular() = default; + + add_vCtor + ( + DataIOType, + DataIORegularType, + IOPattern + ); }; diff --git a/src/phasicFlow/streams/dataIO/dataIORegulars.cpp b/src/phasicFlow/streams/dataIO/dataIORegulars.cpp new file mode 100644 index 00000000..740c0401 --- /dev/null +++ b/src/phasicFlow/streams/dataIO/dataIORegulars.cpp @@ -0,0 +1,38 @@ + + +#include "types.hpp" +#include "dataIO.hpp" +#include "dataIORegular.hpp" + +template class pFlow::dataIO; +template class pFlow::dataIORegular; + +template class pFlow::dataIO; +template class pFlow::dataIORegular; + +template class pFlow::dataIO; +template class pFlow::dataIORegular; + +template class pFlow::dataIO; +template class pFlow::dataIORegular; + +template class pFlow::dataIO; +template class pFlow::dataIORegular; + +template class pFlow::dataIO; +template class pFlow::dataIORegular; + +template class pFlow::dataIO; +template class pFlow::dataIORegular; + +template class pFlow::dataIO; +template class pFlow::dataIORegular; + +template class pFlow::dataIO; +template class pFlow::dataIORegular; + +template class pFlow::dataIO; +template class pFlow::dataIORegular; + +/*template class pFlow::dataIO; +template class pFlow::dataIORegular;*/