Commit 189eca71 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum

[STYLE #147] renamed all API functions to filename (small written n).

parent 9a234999
......@@ -76,11 +76,16 @@ void writeStringIntoFile( const boost::filesystem::path& path, const std::string
}
boost::filesystem::path tempFileName()
{
return tempFilename();
}
boost::filesystem::path tempFilename()
{
// REGARDING THE COMPILER WARNING
// 1. mkstemp is only available for POSIX systems
// 2. reason: the warning generated here is due to a race condition
// while tmpnam invents the fileName it may be created by another process
// while tmpnam invents the filename it may be created by another process
// 3. file names like "/tmp/pansen" or "C:\pansen" are platform dependent
return boost::filesystem::path( std::string( std::tmpnam( NULL ) ) );
}
......
......@@ -32,7 +32,7 @@
#include <boost/filesystem.hpp>
#include "WDefines.h"
#include "WAssert.h"
/**
......@@ -118,9 +118,17 @@ inline bool fileExists( const std::string& name )
/**
* Generate a file name with full path for a temp file.
* \deprecated use tempFilename instead
* \return The file name.
*/
OW_API_DEPRECATED boost::filesystem::path tempFileName();
/**
* Generate a file name with full path for a temp file.
*
* \return The file name.
*/
boost::filesystem::path tempFileName();
boost::filesystem::path tempFilename();
/**
* Get the contens of a file as a string.
......
......@@ -102,7 +102,7 @@ public:
void testWriteStringIntoFile( void )
{
std::string content = "Hello Pansen!\r\n";
boost::filesystem::path fpath = tempFileName();
boost::filesystem::path fpath = tempFilename();
writeStringIntoFile( fpath, content );
std::ifstream input( fpath.string().c_str() );
......
......@@ -39,20 +39,30 @@ WDataSet::WDataSet()
: WTransferable(),
m_properties( boost::shared_ptr< WProperties >( new WProperties( "Data-Set Properties", "Properties of a data-set" ) ) ),
m_infoProperties( boost::shared_ptr< WProperties >( new WProperties( "Data-Set Info Properties", "Data-set's information properties" ) ) ),
m_fileName( "" )
m_filename( "" )
{
m_infoProperties->setPurpose( PV_PURPOSE_INFORMATION );
}
void WDataSet::setFileName( const std::string fileName )
void WDataSet::setFileName( const std::string filename )
{
WAssert( fileName != "", "No filename set for data set." );
m_fileName = fileName;
setFilename( filename );
}
std::string WDataSet::getFileName() const
{
return m_fileName;
return getFilename();
}
void WDataSet::setFilename( const std::string filename )
{
WAssert( filename != "", "No filename set for data set." );
m_filename = filename;
}
std::string WDataSet::getFilename() const
{
return m_filename;
}
bool WDataSet::isTexture() const
......
......@@ -53,7 +53,7 @@ class WDataSet: public WTransferable, public boost::enable_shared_from_this< WDa
public:
/**
* This constructor should be used if a dataSet does not stem from a file.
* It presets the its correpsonding fileName as empty string.
* It presets the its correpsonding filename as empty string.
*/
WDataSet();
......@@ -67,16 +67,34 @@ public:
/**
* Set the name of the file that this data set stems from.
* \param fileName the string representing the name
*
* \param filename the string representing the name
*/
void setFilename( const std::string filename );
/**
* Get the name of the file that this data set stems from.
*
* \return the filename.
*/
std::string getFilename() const;
/**
* Set the name of the file that this data set stems from.
*
* \param filename the string representing the name
*
* \deprecated use setFilename instead
*/
void setFileName( const std::string fileName );
OW_API_DEPRECATED void setFileName( const std::string filename );
/**
* Get the name of the file that this data set stems from.
*
* \deprecated use getFilename instead
* \return the filename.
*/
std::string getFileName() const;
OW_API_DEPRECATED std::string getFileName() const;
/**
* Determines whether this dataset can be used as a texture.
......@@ -160,7 +178,7 @@ private:
* may allow hollowing data sets later. DataSets that were not loaded
* from a file should have the empty string stored here.
*/
std::string m_fileName;
std::string m_filename;
};
#endif // WDATASET_H
......
......@@ -56,9 +56,9 @@ WDataSetFiberVector::WDataSetFiberVector( boost::shared_ptr< const WDataSetFiber
return;
}
if( fiberDS->getFileName() != "" )
if( fiberDS->getFilename() != "" )
{
setFileName( fiberDS->getFileName() );
setFilename( fiberDS->getFilename() );
}
size_t numLines = fiberDS->size();
const std::vector< size_t >& lineLengths = *fiberDS->getLineLengths();
......
......@@ -180,7 +180,7 @@ boost::shared_ptr< WDataSetScalar const > WDataSetTimeSeries::calcDataSetAtTime(
break;
}
boost::shared_ptr< WDataSetScalar > ds( new WDataSetScalar( vs, m_dataSets.front().first->getGrid() ) );
ds->setFileName( name );
ds->setFilename( name );
return ds;
}
......
......@@ -71,7 +71,7 @@ WEEG2::WEEG2( boost::shared_ptr< WPagerEEG > pager, boost::shared_ptr< WEEGPosit
throw WDHException( std::string( "Couldn't construct new EEG: invalid sampling rate" ) );
}
setFileName( pager->getFileName() );
setFilename( pager->getFilename() );
m_segments.reserve( nbSegments );
for( std::size_t segmentID = 0; segmentID < nbSegments; ++segmentID )
......
......@@ -35,14 +35,19 @@ WPagerEEG::~WPagerEEG()
std::string WPagerEEG::getFileName() const
{
return m_fileName;
return getFilename();
}
WPagerEEG::WPagerEEG( std::string fileName )
: m_fileName( fileName )
std::string WPagerEEG::getFilename() const
{
if( !fileExists( m_fileName ) )
return m_filename;
}
WPagerEEG::WPagerEEG( std::string filename )
: m_filename( filename )
{
if( !fileExists( m_filename ) )
{
throw WDHNoSuchFile( m_fileName + " doesn't exist" );
throw WDHNoSuchFile( m_filename + " doesn't exist" );
}
}
......@@ -32,8 +32,7 @@
#include <boost/shared_ptr.hpp>
#include "../WEEGValueMatrix.h"
#include "../../common/WDefines.h"
/**
* Abstract class to load an EEG file and keep it open to support paging.
......@@ -52,7 +51,15 @@ public:
*
* \return name of file
*/
std::string getFileName() const;
std::string getFilename() const;
/**
* Get the name of the loaded file.
*
* \return name of file
* \deprecated use getFilename instead
*/
OW_API_DEPRECATED std::string getFileName() const;
/**
* Get the number of segments this EEG consists of.
......@@ -113,13 +120,11 @@ protected:
/**
* Constructor
*
* \param fileName path and filename to the file to load
* \param filename path and filename to the file to load
*/
explicit WPagerEEG( std::string fileName );
std::string m_fileName; //!< name of the loaded file
explicit WPagerEEG( std::string filename );
private:
std::string m_filename; //!< name of the loaded file
};
#endif // WPAGEREEG_H
......@@ -30,10 +30,15 @@
WReader::WReader( std::string fname ) throw( WDHNoSuchFile )
{
setFileName( fname ); // not in constructor list since fileExcsits check
setFilename( fname ); // not in constructor list since fileExcsits check
}
void WReader::setFileName( std::string fname ) throw( WDHNoSuchFile )
{
setFilename( fname );
}
void WReader::setFilename( std::string fname ) throw( WDHNoSuchFile )
{
m_fname = fname;
if( !fileExists( m_fname ) )
......
......@@ -28,7 +28,7 @@
#include <string>
#include "../exceptions/WDHNoSuchFile.h"
#include "../../common/WDefines.h"
/**
* Read some data from a given file. This base class is just for file
......@@ -36,7 +36,7 @@
* specify their file format which is not the purpose of this base class.
* \ingroup dataHandler
*/
class WReader // NOLINT
class WReader
{
public:
/**
......@@ -47,13 +47,22 @@ public:
*/
explicit WReader( std::string fname ) throw( WDHNoSuchFile );
/**
* Reset the file name and checks if it exists.
*
* \param fname file name
* \throws WDHNoSuchFile
* \deprecated use setFilename instead.
*/
OW_API_DEPRECATED void setFileName( std::string fname ) throw( WDHNoSuchFile );
/**
* Reset the file name and checks if it exists.
*
* \param fname file name
* \throws WDHNoSuchFile
*/
void setFileName( std::string fname ) throw( WDHNoSuchFile );
void setFilename( std::string fname ) throw( WDHNoSuchFile );
protected:
std::string m_fname; //!< Absolute path of the file to read from
......
......@@ -33,10 +33,15 @@
WWriter::WWriter( std::string fname, bool overwrite )
: m_overwrite( overwrite )
{
setFileName( fname ); // not in constructor list since fileExcsits check
setFilename( fname ); // not in constructor list since fileExcsits check
}
void WWriter::setFileName( std::string fname )
{
setFilename( fname );
}
void WWriter::setFilename( std::string fname )
{
m_fname = fname;
if( !m_overwrite && boost::filesystem::exists( boost::filesystem::path( m_fname ) ) )
......
......@@ -27,7 +27,7 @@
#include <string>
#include "../../common/WDefines.h"
/**
* Write some data to the given file. This base class is just for file
......@@ -51,13 +51,21 @@ public:
* non overwriting is specified.
*
* \param fname file name
* \deprecated use setFilename instead
*/
void setFileName( std::string fname );
OW_API_DEPRECATED void setFileName( std::string fname );
/**
* Reset file name and checks if the file already exists in case of
* non overwriting is specified.
*
* \param fname file name
*/
void setFilename( std::string fname );
protected:
std::string m_fname; //!< Absolute path of the file to write to
bool m_overwrite; //!< flag indicating if the file may be overwritten (true) or not (false)
private:
};
......
......@@ -84,8 +84,8 @@ public:
{
boost::shared_ptr< WDataSet > dummyDataSet;
dummyDataSet = boost::shared_ptr< WDataSet >( new WDataSet );
std::string fileName = "Hallo";
dummyDataSet->setFileName( fileName );
std::string filename = "Hallo";
dummyDataSet->setFilename( filename );
WSubject dummySubject;
dummySubject.addDataSet( dummyDataSet );
......@@ -97,7 +97,7 @@ public:
for( WSubject::DatasetConstIterator iter = a->get().begin(); iter != a->get().end(); ++iter )
{
count++;
TS_ASSERT_EQUALS( fileName, ( *iter )->getFileName() );
TS_ASSERT_EQUALS( filename, ( *iter )->getFilename() );
TS_ASSERT_EQUALS( dummyDataSet, ( *iter ) );
}
......@@ -111,8 +111,8 @@ public:
{
boost::shared_ptr< WDataSet > dummyDataSet;
dummyDataSet = boost::shared_ptr< WDataSet >( new WDataSet );
std::string fileName = "Hallo";
dummyDataSet->setFileName( fileName );
std::string filename = "Hallo";
dummyDataSet->setFilename( filename );
WSubject dummySubject;
TS_ASSERT_EQUALS( 0, dummySubject.m_datasets.size() );
......
......@@ -31,10 +31,10 @@
#include "WBatchLoader.h"
WBatchLoader::WBatchLoader( std::vector< std::string > fileNames, boost::shared_ptr< WModuleContainer > targetContainer ):
WBatchLoader::WBatchLoader( std::vector< std::string > filenames, boost::shared_ptr< WModuleContainer > targetContainer ):
WThreadedRunner(),
boost::enable_shared_from_this< WBatchLoader >(),
m_fileNamesToLoad( fileNames ),
m_filenamesToLoad( filenames ),
m_targetContainer( targetContainer ),
m_suppressColormaps( false )
{
......@@ -58,7 +58,7 @@ void WBatchLoader::run()
void WBatchLoader::threadMain()
{
// add a new data module for each file to load
for( std::vector< std::string >::iterator iter = m_fileNamesToLoad.begin(); iter != m_fileNamesToLoad.end(); ++iter )
for( std::vector< std::string >::iterator iter = m_filenamesToLoad.begin(); iter != m_filenamesToLoad.end(); ++iter )
{
boost::shared_ptr< WModule > mod = WModuleFactory::getModuleFactory()->create(
WModuleFactory::getModuleFactory()->getPrototypeByName( "Data Module" )
......
......@@ -65,10 +65,10 @@ public:
/**
* Initializes the batchloader but does not start it. Use run().
*
* \param fileNames the files to load.
* \param filenames the files to load.
* \param targetContainer the container to which the data modules should be added.
*/
WBatchLoader( std::vector< std::string > fileNames, boost::shared_ptr< WModuleContainer > targetContainer );
WBatchLoader( std::vector< std::string > filenames, boost::shared_ptr< WModuleContainer > targetContainer );
/**
* Destructor.
......@@ -114,7 +114,7 @@ protected:
/**
* List of files to load.
*/
std::vector< std::string > m_fileNamesToLoad;
std::vector< std::string > m_filenamesToLoad;
/**
* The container which later will contain the loaded datasets.
......
......@@ -160,14 +160,14 @@ const WBoolFlag& WKernel::isFinishRequested() const
return m_shutdownFlag;
}
WBatchLoader::SPtr WKernel::loadDataSets( std::vector< std::string > fileNames, bool suppressColormaps )
WBatchLoader::SPtr WKernel::loadDataSets( std::vector< std::string > filenames, bool suppressColormaps )
{
return getRootContainer()->loadDataSets( fileNames, suppressColormaps );
return getRootContainer()->loadDataSets( filenames, suppressColormaps );
}
WBatchLoader::SPtr WKernel::loadDataSetsSynchronously( std::vector< std::string > fileNames, bool suppressColormaps )
WBatchLoader::SPtr WKernel::loadDataSetsSynchronously( std::vector< std::string > filenames, bool suppressColormaps )
{
return getRootContainer()->loadDataSetsSynchronously( fileNames, suppressColormaps );
return getRootContainer()->loadDataSetsSynchronously( filenames, suppressColormaps );
}
boost::shared_ptr< WModule > WKernel::applyModule( boost::shared_ptr< WModule > applyOn, boost::shared_ptr< WModule > prototype )
......
......@@ -109,26 +109,26 @@ public:
/**
* Load specified datasets. It immediately returns and starts another thread, which actually loads the data.
*
* \param fileNames list of filenames to load. The registered notification handler for the root container will get notified on
* \param filenames list of filenames to load. The registered notification handler for the root container will get notified on
* error and success.
* \param suppressColormaps if true, the data modules are instructed to avoid registration of colormaps. This can be very handy if you
* combine multiple data loaders into one new data loader or data set
*
* \return the batch loader responsible for loading. Can be queried for the list of data modules.
*/
WBatchLoader::SPtr loadDataSets( std::vector< std::string > fileNames, bool suppressColormaps = false );
WBatchLoader::SPtr loadDataSets( std::vector< std::string > filenames, bool suppressColormaps = false );
/**
* Loads the specified files synchronously.
*
* \param fileNames list of filenames to load. The registered notification handler for the root container will get notified on
* \param filenames list of filenames to load. The registered notification handler for the root container will get notified on
* error and success.
* \param suppressColormaps if true, the data modules are instructed to avoid registration of colormaps. This can be very handy if you
* combine multiple data loaders into one new data loader or data set
*
* \return the batch loader responsible for loading. Can be queried for the list of data modules.
*/
WBatchLoader::SPtr loadDataSetsSynchronously( std::vector< std::string > fileNames, bool suppressColormaps = false );
WBatchLoader::SPtr loadDataSetsSynchronously( std::vector< std::string > filenames, bool suppressColormaps = false );
/**
* Function combines to modules. This is a simple alias for "getRootContainer()->applyModule". It runs synchronously, which
......
......@@ -436,10 +436,10 @@ boost::shared_ptr< WModule > WModuleContainer::applyModule( boost::shared_ptr< W
return m;
}
WBatchLoader::SPtr WModuleContainer::loadDataSets( std::vector< std::string > fileNames, bool suppressColormaps )
WBatchLoader::SPtr WModuleContainer::loadDataSets( std::vector< std::string > filenames, bool suppressColormaps )
{
// create thread which actually loads the data
boost::shared_ptr< WBatchLoader > t = boost::shared_ptr< WBatchLoader >( new WBatchLoader( fileNames,
boost::shared_ptr< WBatchLoader > t = boost::shared_ptr< WBatchLoader >( new WBatchLoader( filenames,
boost::shared_static_cast< WModuleContainer >( shared_from_this() ) )
);
t->setSuppressColormaps( suppressColormaps );
......@@ -447,10 +447,10 @@ WBatchLoader::SPtr WModuleContainer::loadDataSets( std::vector< std::string > fi
return t;
}
WBatchLoader::SPtr WModuleContainer::loadDataSetsSynchronously( std::vector< std::string > fileNames, bool suppressColormaps )
WBatchLoader::SPtr WModuleContainer::loadDataSetsSynchronously( std::vector< std::string > filenames, bool suppressColormaps )
{
// create thread which actually loads the data
boost::shared_ptr< WBatchLoader > t = boost::shared_ptr< WBatchLoader >( new WBatchLoader( fileNames,
boost::shared_ptr< WBatchLoader > t = boost::shared_ptr< WBatchLoader >( new WBatchLoader( filenames,
boost::shared_static_cast< WModuleContainer >( shared_from_this() ) )
);
t->setSuppressColormaps( suppressColormaps );
......
......@@ -202,26 +202,26 @@ public:
/**
* Load specified datasets. It immediately returns and starts another thread, which actually loads the data.
*
* \param fileNames list of filenames to load. The registered notification handler for the root container will get notified on
* \param filenames list of filenames to load. The registered notification handler for the root container will get notified on
* error and success.
* \param suppressColormaps if true, the data modules are instructed to avoid registration of colormaps. This can be very handy if you
* combine multiple data loaders into one new data loader or data set
*
* \return the loader handling the load operation
*/
WBatchLoader::SPtr loadDataSets( std::vector< std::string > fileNames, bool suppressColormaps = false );
WBatchLoader::SPtr loadDataSets( std::vector< std::string > filenames, bool suppressColormaps = false );
/**
* Loads the specified files synchronously. The returned batchloader can be queried for the list of data modules that have been added.
*
* \param fileNames list of filenames to load. The registered notification handler for the root container will get notified on
* \param filenames list of filenames to load. The registered notification handler for the root container will get notified on
* error and success.
* \param suppressColormaps if true, the data modules are instructed to avoid registration of colormaps. This can be very handy if you
* combine multiple data loaders into one new data loader or data set
*
* \return the loader has handled the load operation
*/
WBatchLoader::SPtr loadDataSetsSynchronously( std::vector< std::string > fileNames, bool suppressColormaps = false );
WBatchLoader::SPtr loadDataSetsSynchronously( std::vector< std::string > filenames, bool suppressColormaps = false );
/**
* Add the specified thread to the list of pending jobs. Only this ensures, that ALL pending threads get stopped before the
......
......@@ -150,7 +150,7 @@ void WMAtlasSurfaces::moduleMain()
if( m_labelFile->get( true ) == boost::filesystem::path( "" ) )
{
std::string fn = m_dataSet->getFileName();
std::string fn = m_dataSet->getFilename();
std::string ext( ".nii.gz" );
std::string csvExt( ".csv" );
fn.replace( fn.find( ext ), ext.size(), csvExt );
......
......@@ -250,7 +250,7 @@ void WMBermanTracking::moduleMain()
boost::shared_ptr< WValueSet< float > > vs( new WValueSet< float >( 0, 1, m_hits, DataType< float >::type ) );
m_result = boost::shared_ptr< WDataSetScalar >( new WDataSetScalar( vs, m_dataSet->getGrid() ) );
m_result->setFileName( "Berman_prob_tracking_result" );
m_result->setFilename( "Berman_prob_tracking_result" );
m_result->getTexture()->threshold()->set( 0.05f );
m_result->getTexture()->colormap()->set( m_result->getTexture()->colormap()->get().newSelector( WItemSelector::IndexList( 1, 2 ) ) );
......
......@@ -393,7 +393,7 @@ void WMClusterDisplay::moduleMain()
if( m_dataSet != m_fiberInput->getData() )
{
m_dataSet = m_fiberInput->getData();
std::string fn = m_dataSet->getFileName();
std::string fn = m_dataSet->getFilename();
std::string ext( ".fib" );
std::string csvExt( "_hie.txt" );
fn.replace( fn.find( ext ), ext.size(), csvExt );
......
......@@ -51,18 +51,18 @@ WPagerEEGLibeep::WPagerEEGLibeep( std::string fileName )
std::setlocale( LC_NUMERIC, "C" );
// initialize
std::FILE* file = std::fopen( m_fileName.c_str(), "rb" );
std::FILE* file = std::fopen( getFilename().c_str(), "rb" );
if( !file )
{
throw WDHNoSuchFile( m_fileName + " could not be opened" );
throw WDHNoSuchFile( getFilename() + " could not be opened" );
}
int status;
m_eeg = eep_init_from_file( m_fileName.c_str(), file, &status );
m_eeg = eep_init_from_file( getFilename().c_str(), file, &status );
if( status != CNTERR_NONE || !m_eeg )
{
std::ostringstream stream;
stream << m_fileName << " could not be initialized. Libeep status code: " << status;
stream << getFilename() << " could not be initialized. Libeep status code: " << status;
throw WDHIOFailure( stream.str() );
}
......@@ -83,7 +83,7 @@ WPagerEEGLibeep::~WPagerEEGLibeep()
if( status != CNTERR_NONE )
{
std::ostringstream stream;
stream << m_fileName << " could not be closed. Libeep status code: " << status;
stream << getFilename() << " could not be closed. Libeep status code: " << status;
throw WDHIOFailure( stream.str() );
}
}
......@@ -103,7 +103,7 @@ std::size_t WPagerEEGLibeep::getNumberOfSamples( std::size_t segmentID ) const
if( segmentID != 0 )
{
std::ostringstream stream;
stream << m_fileName << " has no segment number " << segmentID;
stream << getFilename() << " has no segment number " << segmentID;
throw WOutOfBounds( stream.str() );
}
......@@ -115,14 +115,14 @@ boost::shared_ptr< WEEGValueMatrix > WPagerEEGLibeep::getValues( std::size_t seg
if( segmentID != 0 )
{
std::ostringstream stream;
stream << m_fileName << " has no segment number " << segmentID;
stream << getFilename() << " has no segment number " << segmentID;
throw WOutOfBounds( stream.str() );
}
if( start + length > m_nbSamples )
{
std::ostringstream stream;
stream << "Could not read sample number " << start + length - 1 << " of file " <<