Loading src/core/CMakeLists.txt +1 −0 Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ set (headers tnlAssert.h tnlCuda.h tnlDataElement.h tnlDevice.h tnlDynamicTypeTag.h tnlFeature.h tnlFile.h tnlFlopsCounter.h Loading src/core/arrays/tnlArrayOperations.h +1 −0 Original line number Diff line number Diff line Loading @@ -69,6 +69,7 @@ class tnlArrayOperations< tnlHost > static bool compareMemory( const Element1* destination, const Element2* source, const Index size ); }; template<> Loading src/core/tnlDynamicTypeTag.h 0 → 100644 +28 −0 Original line number Diff line number Diff line /*************************************************************************** tnlDynamicTypeTag.h - description ------------------- begin : Mar 13, 2014 copyright : (C) 2014 by Tomas Oberhuber email : tomas.oberhuber@fjfi.cvut.cz ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #ifndef TNLDYNAMICTYPETAG_H_ #define TNLDYNAMICTYPETAG_H_ template< typename Element > struct tnlDynamicTypeTag { enum { value = false }; }; #endif /* TNLDYNAMICTYPETAG_H_ */ src/implementation/core/arrays/tnlArrayIO.h 0 → 100644 +82 −0 Original line number Diff line number Diff line /*************************************************************************** tnlArrayIO.h - description ------------------- begin : Mar 13, 2014 copyright : (C) 2014 by Tomas Oberhuber email : tomas.oberhuber@fjfi.cvut.cz ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #ifndef TNLARRAYIO_H_ #define TNLARRAYIO_H_ #include<core/tnlDynamicTypeTag.h> #include<core/tnlFile.h> template< typename Element, typename Device, typename Index, bool DynamicType = tnlDynamicTypeTag< Element >::value > class tnlArrayIO {}; template< typename Element, typename Device, typename Index > class tnlArrayIO< Element, Device, Index, true > { public: static bool save( tnlFile& file, const Element* data, const Index elements ) { for( Index i = 0; i < elements; i++ ) if( ! data[ i ].save( file ) ) return false; return true; } static bool load( tnlFile& file, Element* data, const Index elements ) { for( Index i = 0; i < elements; i++ ) if( ! data[ i ].load( file ) ) return false; return true; } }; template< typename Element typename Device, typename Index > class tnlArrayIO< Element, Device, Index, false > { public: static bool save( tnlFile& file, const Element* data, const Index elements ) { return file.write< Element, Device, Index >( data, elements ); } static bool load( tnlFile& file, Element* data, const Index elements ) { return file.read< Element, Device, Index >( data, elements ); } }; #endif /* TNLARRAYIO_H_ */ src/implementation/core/arrays/tnlArray_impl.h +3 −3 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ #include <core/mfuncs.h> #include <core/param-types.h> #include <core/arrays/tnlArrayOperations.h> #include <implementation/core/arrays/tnlArrayIO.h> using namespace std; Loading Loading @@ -332,7 +333,7 @@ bool tnlArray< Element, Device, Index > :: save( tnlFile& file ) const if( ! file. write( &this -> size ) ) return false; #endif if( this -> size != 0 && ! file. write< Element, Device, Index >( this -> data, this -> size ) ) if( this -> size != 0 && ! tnlArrayIO< Element, Device, Index >::save( file, this -> data, this -> size ) ) { cerr << "I was not able to save " << this->getType() << " " << this -> getName() Loading Loading @@ -365,7 +366,7 @@ bool tnlArray< Element, Device, Index > :: load( tnlFile& file ) if( _size ) { setSize( _size ); if( ! file. read< Element, Device, Index >( this -> data, this -> size ) ) if( ! tnlArrayIO< Element, Device, Index >::load( file, this -> data, this -> size ) ) { cerr << "I was not able to load " << this->getType() << " " << this -> getName() Loading @@ -392,7 +393,6 @@ bool tnlArray< Element, Device, Index > :: load( const tnlString& fileName ) return tnlObject :: load( fileName ); } template< typename Element, typename Device, typename Index > Loading Loading
src/core/CMakeLists.txt +1 −0 Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ set (headers tnlAssert.h tnlCuda.h tnlDataElement.h tnlDevice.h tnlDynamicTypeTag.h tnlFeature.h tnlFile.h tnlFlopsCounter.h Loading
src/core/arrays/tnlArrayOperations.h +1 −0 Original line number Diff line number Diff line Loading @@ -69,6 +69,7 @@ class tnlArrayOperations< tnlHost > static bool compareMemory( const Element1* destination, const Element2* source, const Index size ); }; template<> Loading
src/core/tnlDynamicTypeTag.h 0 → 100644 +28 −0 Original line number Diff line number Diff line /*************************************************************************** tnlDynamicTypeTag.h - description ------------------- begin : Mar 13, 2014 copyright : (C) 2014 by Tomas Oberhuber email : tomas.oberhuber@fjfi.cvut.cz ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #ifndef TNLDYNAMICTYPETAG_H_ #define TNLDYNAMICTYPETAG_H_ template< typename Element > struct tnlDynamicTypeTag { enum { value = false }; }; #endif /* TNLDYNAMICTYPETAG_H_ */
src/implementation/core/arrays/tnlArrayIO.h 0 → 100644 +82 −0 Original line number Diff line number Diff line /*************************************************************************** tnlArrayIO.h - description ------------------- begin : Mar 13, 2014 copyright : (C) 2014 by Tomas Oberhuber email : tomas.oberhuber@fjfi.cvut.cz ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #ifndef TNLARRAYIO_H_ #define TNLARRAYIO_H_ #include<core/tnlDynamicTypeTag.h> #include<core/tnlFile.h> template< typename Element, typename Device, typename Index, bool DynamicType = tnlDynamicTypeTag< Element >::value > class tnlArrayIO {}; template< typename Element, typename Device, typename Index > class tnlArrayIO< Element, Device, Index, true > { public: static bool save( tnlFile& file, const Element* data, const Index elements ) { for( Index i = 0; i < elements; i++ ) if( ! data[ i ].save( file ) ) return false; return true; } static bool load( tnlFile& file, Element* data, const Index elements ) { for( Index i = 0; i < elements; i++ ) if( ! data[ i ].load( file ) ) return false; return true; } }; template< typename Element typename Device, typename Index > class tnlArrayIO< Element, Device, Index, false > { public: static bool save( tnlFile& file, const Element* data, const Index elements ) { return file.write< Element, Device, Index >( data, elements ); } static bool load( tnlFile& file, Element* data, const Index elements ) { return file.read< Element, Device, Index >( data, elements ); } }; #endif /* TNLARRAYIO_H_ */
src/implementation/core/arrays/tnlArray_impl.h +3 −3 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ #include <core/mfuncs.h> #include <core/param-types.h> #include <core/arrays/tnlArrayOperations.h> #include <implementation/core/arrays/tnlArrayIO.h> using namespace std; Loading Loading @@ -332,7 +333,7 @@ bool tnlArray< Element, Device, Index > :: save( tnlFile& file ) const if( ! file. write( &this -> size ) ) return false; #endif if( this -> size != 0 && ! file. write< Element, Device, Index >( this -> data, this -> size ) ) if( this -> size != 0 && ! tnlArrayIO< Element, Device, Index >::save( file, this -> data, this -> size ) ) { cerr << "I was not able to save " << this->getType() << " " << this -> getName() Loading Loading @@ -365,7 +366,7 @@ bool tnlArray< Element, Device, Index > :: load( tnlFile& file ) if( _size ) { setSize( _size ); if( ! file. read< Element, Device, Index >( this -> data, this -> size ) ) if( ! tnlArrayIO< Element, Device, Index >::load( file, this -> data, this -> size ) ) { cerr << "I was not able to load " << this->getType() << " " << this -> getName() Loading @@ -392,7 +393,6 @@ bool tnlArray< Element, Device, Index > :: load( const tnlString& fileName ) return tnlObject :: load( fileName ); } template< typename Element, typename Device, typename Index > Loading