diff --git a/doc/CodingGuidelines b/doc/CodingGuidelines index a78b320334073fcfb3c2dbd0a6fb2b59c62f85ee..bb6677a3d31b9f6cdf58f423c88d4f2ce63c6d79 100644 --- a/doc/CodingGuidelines +++ b/doc/CodingGuidelines @@ -48,7 +48,7 @@ Text style for readability (Coding format setup in Eclipse with Window > Prefere } -5) Brackets: use an extra space for brackets +5) Brackets: use an extra space for brackets. Only one line conditionals can skip having brackets. Do: if( number < 1 ) { @@ -61,10 +61,13 @@ Text style for readability (Coding format setup in Eclipse with Window > Prefere number = 4; ..... .....} + It's ok to omit brackets in one line conditionals: + if( itMap == map.end() ) throw std::invalid_argument( "ERROR: not found in map\n" ); -6) Prefer the keyword "using" over "typedef". Only rename complex types, do not rename standard types (int, double, std::vector) - Don't: typedef std::vector<std::vector<double>> Vector2D; - Do: using std::vector<std::vector<double>> = Vector2D; +6) Prefer the keyword "using" over "typedef". Only rename very complex custom types, + do not rename standard types (int, double, std::vector) + Don't: typedef std::vector<std::vector< std::map<std::string,double> >> MapIn2DVector; + Do: using std::vector<std::vector< std::map<std::string,double> >> = MapIn2DVector; Documentation/Comments diff --git a/examples/hello/fstream.xml b/examples/hello/fstream.xml index b72530ee2db91a0db89b2997ded87a5567878add..bbb26e533ae3c9a388040faa85d6de2ec1ca703b 100644 --- a/examples/hello/fstream.xml +++ b/examples/hello/fstream.xml @@ -2,7 +2,7 @@ <adios-config host-language="C++"> <adios-group name="Vector"> - <var name="Numbers" type="integer"/> + <var name="Numbers" type="Vinteger"/> <attribute name="description" value="1 to 10"/> </adios-group> diff --git a/examples/hello/helloADIOS_nompi.cpp b/examples/hello/helloADIOS_nompi.cpp index 18a4f1c9bf02e9298dc57af4ecf9bd95afcf4d47..c0876a8945ab553ca8ca7aae3f9f136551815106 100644 --- a/examples/hello/helloADIOS_nompi.cpp +++ b/examples/hello/helloADIOS_nompi.cpp @@ -16,7 +16,7 @@ int main( int argc, char* argv [] ) { try { - adios::ADIOS adios( "writer2Groups.xml" ); //testing with CPOSIXNoMPI + adios::ADIOS adios( "writer2Groups.xml", true ); //testing with CPOSIXNoMPI adios.MonitorGroups( std::cout ); std::cout << "Finished initializing ADIOS\n"; } diff --git a/include/core/CTransform.h b/include/core/CTransform.h index 6c8153f693dc4d5cda972dfb76e76bd81b91aeb4..91bb5a7d7eb7ef0e06ae3aa16f2ee2a9dd840bdf 100644 --- a/include/core/CTransform.h +++ b/include/core/CTransform.h @@ -36,9 +36,13 @@ public: * @param method zlib, bzip2, szip * @param variable */ - CTransform( const std::string method, const unsigned int compressionLevel, CVariable& variable ); + CTransform( const std::string method, const unsigned int compressionLevel, CVariable& variable ): + m_Method( method ), + m_CompressionLevel( compressionLevel ), + m_Variable( variable ) + { } - virtual ~CTransform( ); + virtual ~CTransform( ){ }; virtual void Compress( ) const = 0; ///< Compress m_Variable data m_Value diff --git a/include/core/CVariable.h b/include/core/CVariable.h index 2b289e2d38c8219e5c046010d614b4d65b62e5bf..f48e626b20d5e625ec2317d82f4c006dfc1ada8e 100644 --- a/include/core/CVariable.h +++ b/include/core/CVariable.h @@ -28,10 +28,9 @@ public: virtual ~CVariable( ); - //template<class T> const T& Get( ) const; + template<class T> const T* Get( ) const; template<class T> void Set( const void* values ); - //protected: turned off for testing bool m_IsGlobal = false; std::string m_Type = "NONE"; ///< mandatory, double, float, unsigned integer, integer, etc. diff --git a/include/core/CVariableTemplate.h b/include/core/CVariableTemplate.h index de7567e8884c7538c9a18d67f2f86445fd06cb7f..bae7aa7d98030ce0c6337ce75a354f3c9de3644e 100644 --- a/include/core/CVariableTemplate.h +++ b/include/core/CVariableTemplate.h @@ -38,19 +38,22 @@ public: const T* m_Value = nullptr; // pointer or no pointer? - //const T& Get() const { return m_Value; } - - void Set( const void* values ){ m_Value = static_cast<T const*> (values); } + const T* Get() const { return m_Value; } + void Set( const void* values ){ m_Value = static_cast<const T*> (values); } }; +template<class T> const T* CVariable::Get( ) const +{ + return dynamic_cast<CVariableTemplate<T>const & >(*this).Get( ); +} + template<class T> void CVariable::Set( const void* values ) { return dynamic_cast< CVariableTemplate<T>& >( *this ).Set( values ); } - } //end namespace #endif /* CVARIABLETEMPLATE_H_ */ diff --git a/include/public/ADIOS.h b/include/public/ADIOS.h index 2a2438d1290af9c348286741ae659e0c2a5ba676..cc45c2cfeaef8997a4dc237253eabaafee557472 100644 --- a/include/public/ADIOS.h +++ b/include/public/ADIOS.h @@ -121,6 +121,8 @@ private: std::map< std::string, std::unique_ptr<CTransform> > m_Transforms; + + /** * @brief Maximum buffer size in ADIOS write() operation. From buffer max - size - MB in XML file * Note, that if there are two ADIOS outputs going on at the same time, diff --git a/src/core/CGroup.cpp b/src/core/CGroup.cpp index d760230469765b555b15c6ad9a9fe512c45e38fc..ce226c85c2a8cd7ac2875ab0226246c69ae3f035 100644 --- a/src/core/CGroup.cpp +++ b/src/core/CGroup.cpp @@ -61,6 +61,10 @@ void CGroup::SetVariable( const std::string name, const bool isGlobal, const std m_Variables[name] = std::make_shared< CVariableTemplate<float> >( isGlobal, type, dimensionsCSV, transform ); else if( type == "double") m_Variables[name] = std::make_shared< CVariableTemplate<double> >( isGlobal, type, dimensionsCSV, transform ); + else if( type == "Vinteger") + m_Variables[name] = std::make_shared< CVariableTemplate< std::vector<int> > >( isGlobal, type, dimensionsCSV, transform ); + else + throw std::invalid_argument( "ERROR: type " + type + " for variable " + name + "not supported\n" ); }; //Function body start here @@ -131,6 +135,8 @@ void CGroup::Write( const std::string variableName, const void* values ) if( type == "double" ) variable->Set<double>( values ); else if( type == "integer" ) variable->Set<int>( values ); + else if( type == "Vinteger" ) variable->Set<std::vector<int>>( values ); + // else if( type == "unsigned integer" ) variable->Set<unsigned int>( values ); // else if( type == "float" ) variable->Set<float>( values ); diff --git a/src/core/CVariable.cpp b/src/core/CVariable.cpp index f9805afa2ba45ea9b8f5e860f79966b9dd1d232e..f63fae8e6816c0fc87bc9ab4d54386152f97a2f4 100644 --- a/src/core/CVariable.cpp +++ b/src/core/CVariable.cpp @@ -7,8 +7,7 @@ #include "core/CVariable.h" -#include "core/CVariableTemplate.h" //for dynamic_cast - +#include "core/CVariableTemplate.h" namespace adios { diff --git a/src/transport/CFStream.cpp b/src/transport/CFStream.cpp index 3d7a0e092b27ae0be21cc132967176c700d23002..4d6a0e1765023cc6f56e6d0222ca9ea087968dfb 100644 --- a/src/transport/CFStream.cpp +++ b/src/transport/CFStream.cpp @@ -8,6 +8,8 @@ #include <iostream> #include "transport/CFStream.h" +#include "core/CVariableTemplate.h" +#include "core/CVariable.h" namespace adios @@ -31,6 +33,17 @@ void CFStream::Write( const CVariable& variable ) std::cout << "Just saying Hello from CFStream Write from process " << rank << "/" << size << "\n"; std::cout << "My variable type is " << variable.m_Type << "\n"; + + auto var = variable.Get< std::vector<int> >(); + +// std::cout << "Var is empty: " << std::boolalpha << var.empty() << "\n"; + + std::cout << "var " << var->at(0) << "\n"; + + //pointer to vector +// for( unsigned int i = 0; i < 10; ++i ) +// std::cout << "var[" << i << "] = " << var->at(i) << "\n"; + }