Skip to content
Snippets Groups Projects
Commit d437af27 authored by Tomáš Oberhuber's avatar Tomáš Oberhuber Committed by Jakub Klinkovský
Browse files

Added new constructor and distributed node ID to FileName.

parent 4ca5c976
No related branches found
No related tags found
1 merge request!10Periodic BC in distributed grid
This commit is part of merge request !10. Comments created here will be created in the context of that merge request.
......@@ -25,6 +25,7 @@ set( headers
File.h
File_impl.h
FileName.h
FileName.hpp
Object.h
Logger.h
Logger_impl.h
......
/***************************************************************************
mfilename.cpp - description
FileName.cpp - description
-------------------
begin : 2007/06/18
copyright : (C) 2007 by Tomas Oberhuber
......@@ -22,6 +22,14 @@ FileName::FileName()
: index( 0 ), digitsCount( 5 )
{
}
FileName::FileName( const String& fileNameBase,
const String& extension )
: fileNameBase( fileNameBase ),
extension( extension ),
index( 0 ),
digitsCount( 5 )
{
}
void FileName::setFileNameBase( const String& fileNameBase )
{
......@@ -43,38 +51,24 @@ void FileName::setDigitsCount( const int digitsCount )
this->digitsCount = digitsCount;
}
void FileName::setDistributedSystemNodeId( int nodeId )
{
this->distributedSystemNodeId = "-";
this->distributedSystemNodeId += convertToString( nodeId );
}
String FileName::getFileName()
{
std::stringstream stream;
stream << this->fileNameBase
<< std::setw( this->digitsCount )
<< std::setfill( '0' )
<< index
<< this->index
<< this->distributedSystemNodeId
<< "." << this->extension;
return String( stream.str().data() );
}
/*void FileNameBaseNumberEnding( const char* base_name,
int number,
int index_size,
const char* ending,
String& file_name )
{
file_name. setString( base_name );
char snumber[ 1024 ], zeros[ 1024 ];;
sprintf( snumber, "%d", number );
int len = strlen( snumber );
const int k = min( 1024, index_size );
int i;
for( i = len; i < k ; i ++ )
zeros[ i - len ] = '0';
zeros[ k - len ] = 0;
file_name += zeros;
file_name += snumber;
file_name += ending;
}*/
String getFileExtension( const String fileName )
{
int size = fileName. getLength();
......
/***************************************************************************
mfilename.h - description
FileName.h - description
-------------------
begin : 2007/06/18
copyright : (C) 2007 by Tomas Oberhuber
......@@ -14,12 +14,6 @@
namespace TNL {
/*void FileNameBaseNumberEnding( const char* base_name,
int number,
int index_size,
const char* ending,
String& file_name );*/
String getFileExtension( const String fileName );
void removeFileExtension( String& file_name );
......@@ -30,6 +24,11 @@ class FileName
FileName();
FileName( const String& fileNameBase );
FileName( const String& fileNameBase,
const String& extension );
void setFileNameBase( const String& fileNameBase );
void setExtension( const String& extension );
......@@ -38,14 +37,21 @@ class FileName
void setDigitsCount( const int digitsCount );
void setDistributedSystemNodeId( int nodeId );
template< typename Coordinates >
void setDistributedSystemNodeId( const Coordinates& nodeId );
String getFileName();
protected:
String fileNameBase, extension;
String fileNameBase, extension, distributedSystemNodeId;
int index, digitsCount;
};
} // namespace TNL
#include <TNL/FileName.hpp>
/***************************************************************************
FileName.hpp - description
-------------------
begin : Sep 28, 2018
copyright : (C) 2018 by Tomas Oberhuber
email : tomas.oberhuber@fjfi.cvut.cz
***************************************************************************/
/* See Copyright Notice in tnl/Copyright */
#include <TNL/FileName.h>
namespace TNL {
template< typename Coordinates >
void
FileName::
setDistributedSystemNodeId( const Coordinates& nodeId )
{
this->distributedSystemNodeId = "-";
this->distributedSystemNodeId += convertToString( nodeId[ 0 ] );
for( int i = 1; i < nodeId.getSize(); i++ )
{
this->distributedSystemNodeId += "-";
this->distributedSystemNodeId += convertToString( nodeId[ i ] );
}
}
} // namespace TNL
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment