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
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -25,6 +25,7 @@ set( headers
     File.h
     File.h
     File_impl.h
     File_impl.h
     FileName.h
     FileName.h
     FileName.hpp
     Object.h
     Object.h
     Logger.h
     Logger.h
     Logger_impl.h
     Logger_impl.h
+17 −23
Original line number Original line Diff line number Diff line
/***************************************************************************
/***************************************************************************
                          mfilename.cpp  -  description
                          FileName.cpp  -  description
                             -------------------
                             -------------------
    begin                : 2007/06/18
    begin                : 2007/06/18
    copyright            : (C) 2007 by Tomas Oberhuber
    copyright            : (C) 2007 by Tomas Oberhuber
@@ -22,6 +22,14 @@ FileName::FileName()
: index( 0 ), digitsCount( 5 )
: 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 )
void FileName::setFileNameBase( const String& fileNameBase )
{
{
@@ -43,38 +51,24 @@ void FileName::setDigitsCount( const int digitsCount )
   this->digitsCount = digitsCount;
   this->digitsCount = digitsCount;
}
}


void FileName::setDistributedSystemNodeId( int nodeId )
{
   this->distributedSystemNodeId = "-";
   this->distributedSystemNodeId += convertToString( nodeId );
}

String FileName::getFileName()
String FileName::getFileName()
{
{
   std::stringstream stream;
   std::stringstream stream;
   stream << this->fileNameBase 
   stream << this->fileNameBase 
          << std::setw( this->digitsCount )
          << std::setw( this->digitsCount )
          << std::setfill( '0' )
          << std::setfill( '0' )
          << index
          << this->index
          << this->distributedSystemNodeId
          << "." << this->extension;
          << "." << this->extension;
   return String( stream.str().data() );
   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 )
String getFileExtension( const String fileName )
{
{
   int size = fileName. getLength();
   int size = fileName. getLength();
+14 −8
Original line number Original line Diff line number Diff line
/***************************************************************************
/***************************************************************************
                          mfilename.h  -  description
                          FileName.h  -  description
                             -------------------
                             -------------------
    begin                : 2007/06/18
    begin                : 2007/06/18
    copyright            : (C) 2007 by Tomas Oberhuber
    copyright            : (C) 2007 by Tomas Oberhuber
@@ -14,12 +14,6 @@


namespace TNL {
namespace TNL {


/*void FileNameBaseNumberEnding( const char* base_name,
                               int number,
                               int index_size,
                               const char* ending,
                               String& file_name );*/

String getFileExtension( const String fileName );
String getFileExtension( const String fileName );


void removeFileExtension( String& file_name );
void removeFileExtension( String& file_name );
@@ -30,6 +24,11 @@ class FileName
      
      
      FileName();
      FileName();
      
      
      FileName( const String& fileNameBase );
      
      FileName( const String& fileNameBase, 
                const String& extension );
      
      void setFileNameBase( const String& fileNameBase );
      void setFileNameBase( const String& fileNameBase );
      
      
      void setExtension( const String& extension );
      void setExtension( const String& extension );
@@ -38,14 +37,21 @@ class FileName
      
      
      void setDigitsCount( const int digitsCount );
      void setDigitsCount( const int digitsCount );
      
      
      void setDistributedSystemNodeId( int nodeId );
      
      template< typename Coordinates >
      void setDistributedSystemNodeId( const Coordinates& nodeId );
      
      String getFileName();
      String getFileName();
      
      
   protected:
   protected:
   
   
      String fileNameBase, extension;
      String fileNameBase, extension, distributedSystemNodeId;
      
      
      int index, digitsCount;
      int index, digitsCount;
   
   
};
};


} // namespace TNL
} // namespace TNL

#include <TNL/FileName.hpp>

src/TNL/FileName.hpp

0 → 100644
+29 −0
Original line number Original line Diff line number Diff line
/***************************************************************************
                          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