13 #include <ecl/config/ecl.hpp> 25 #include "../../include/ecl/devices/shared_file.hpp" 53 if ( !
file.open(name,mode) ) {
76 std::map<std::string,SharedFileCommon*>::iterator iter = opened_files.find(name);
78 if ( iter != opened_files.end() ) {
82 iter->second->
count += 1;
83 shared_instance = iter->second;
90 opened_files.insert(std::pair<string,SharedFileCommon*>(name,shared_instance));
92 shared_instance = NULL;
97 return shared_instance;
107 std::map<std::string,SharedFileCommon*>::iterator iter = opened_files.find(name);
109 if ( iter == opened_files.end() ) {
113 if ( iter->second->count == 1 ) {
115 opened_files.erase(iter);
117 iter->second->count -= 1;
136 shared_instance(NULL)
182 unsigned int no_written = 0;
183 while ( no_written < n ) {
Interface distributed to all members of a shared output file.
Embedded control libraries.
WriteMode
Write mode for devices.
#define ecl_throw(exception)
devices::SharedFileCommon * shared_instance
long write(const char &c)
Write a character to the buffer.
devices::CharBuffer buffer
SharedFile()
Non-RAII style constructor, doesn't open a file.
static std::map< std::string, SharedFileCommon * > opened_files
static SharedFileCommon * RegisterSharedFile(const std::string &name, ecl::WriteMode mode=New)
#define ecl_debug_catch(exception)
unsigned int size() const
static bool DeRegisterSharedFile(const std::string &name)
#define ecl_debug_throw(exception)
virtual ~SharedFile()
Automatic cleaner for shared files.
#define ecl_catch(exception)
bool flush()
Flush the internal buffer.
long append(const char &c)
bool open()
Status flag indicating if the file is open/closed.