]> git.tdb.fi Git - libs/core.git/blobdiff - source/file.h
Drop copyright and license notices from files
[libs/core.git] / source / file.h
index 49b596bb943077411db57b0bc66044de8de87a92..6353a4626c5461036ffd4a935d15b12b0efbffbc 100644 (file)
@@ -1,14 +1,10 @@
-/* $Id$
-
-This file is part of libmspio
-Copyright © 2007 Mikko Rasa, Mikkosoft Productions
-Distributed under the LGPL
-*/
 #ifndef MSP_IO_FILE_H_
 #define MSP_IO_FILE_H_
 
 #include <string>
 #include "base.h"
+#include "buffered.h"
+#include "filtered.h"
 #include "seek.h"
 
 namespace Msp {
@@ -24,42 +20,44 @@ class File: public Base
 public:
        enum CreateMode
        {
-               C_NONE=0,
-               C_CREATE=1,
-               C_TRUNCATE=2
+               C_NONE = 0,
+               C_CREATE = 1,
+               C_TRUNCATE = 2
        };
 
-       File(const std::string &, Mode=M_READ, CreateMode =CreateMode(C_CREATE+C_TRUNCATE));
+       File(const std::string &, Mode = M_READ, CreateMode =CreateMode(C_CREATE+C_TRUNCATE));
 
        void close();
 
        void set_block(bool);
-       void enable_events();
 
-       void sync();
+       virtual void sync();
 
-       int  seek(int, SeekType);
-       int  tell() const;
+       virtual int  seek(int, SeekType);
+       virtual int  tell() const;
 
-       Handle get_event_handle() { return handle; }
+       virtual Handle get_event_handle() { return handle; }
 
-       ~File();
+       virtual ~File();
 private:
        Handle handle;
 
-       void      check_access(Mode) const;
-       unsigned  do_write(const char *, unsigned);
-       unsigned  do_read(char *, unsigned);
+       void              check_access(Mode) const;
+protected:
+       virtual unsigned  do_write(const char *, unsigned);
+       virtual unsigned  do_read(char *, unsigned);
 };
 
 inline File::CreateMode operator|(File::CreateMode m, File::CreateMode n)
-{ return File::CreateMode((int)m|(int)n); }
+{ return File::CreateMode(static_cast<int>(m)|static_cast<int>(n)); }
 
 inline File::CreateMode operator&(File::CreateMode m, File::CreateMode n)
-{ return File::CreateMode((int)m&(int)n); }
+{ return File::CreateMode(static_cast<int>(m)&static_cast<int>(n)); }
 
 inline File::CreateMode operator~(File::CreateMode m)
-{ return File::CreateMode(~(int)m); }
+{ return File::CreateMode(~static_cast<int>(m)); }
+
+typedef Filtered<File, Buffered> BufferedFile;
 
 } // namespace IO
 } // namespace Msp