ALPSCore reference
Public Types | Public Member Functions | List of all members
alps::testing::unique_file Class Reference

Resource manager: manages a file with unique name. More...

#include <unique_file.hpp>

Inheritance diagram for alps::testing::unique_file:
Inheritance graph
Collaboration diagram for alps::testing::unique_file:
Collaboration graph

Public Types

enum  action_type { REMOVE_AFTER, KEEP_AFTER, REMOVE_NOW, REMOVE_AND_DISOWN }
 

Public Member Functions

 unique_file (const std::string &prefix, action_type action=KEEP_AFTER)
 Generates a random file name with a given prefix. More...
 
const std::string & name () const
 Returns temporary file name. More...
 
 ~unique_file ()
 Closes and optionally deletes the file. More...
 

Detailed Description

Resource manager: manages a file with unique name.

Definition at line 17 of file unique_file.hpp.

Member Enumeration Documentation

Enumerator
REMOVE_AFTER 

Remove the file when destroying the object.

KEEP_AFTER 

Keep the file when destroying the object.

REMOVE_NOW 

Remove the file after constructing the object, remove when destructing too.

REMOVE_AND_DISOWN 

Remove the file after constructing the object only.

Definition at line 19 of file unique_file.hpp.

Constructor & Destructor Documentation

alps::testing::unique_file::unique_file ( const std::string &  prefix,
unique_file::action_type  action = KEEP_AFTER 
)
explicit

Generates a random file name with a given prefix.

Parameters
prefixThe file prefix
actionWhether to delete file in dtor
Warning
This method cannot ensure that the file name is indeed unique by the time the name is actually used.
Current implementation actually creates a file and then closes it.

Definition at line 27 of file unique_file.cpp.

alps::testing::unique_file::~unique_file ( )

Closes and optionally deletes the file.

Definition at line 44 of file unique_file.cpp.

Member Function Documentation

const std::string& alps::testing::unique_file::name ( ) const
inline

Returns temporary file name.

Definition at line 38 of file unique_file.hpp.


The documentation for this class was generated from the following files: