]> git.tdb.fi Git - libs/core.git/blobdiff - source/io/base.cpp
Add move semantics to Variant
[libs/core.git] / source / io / base.cpp
index bf4c82018dc60d9a6d4ddd18be350468f9a4c0a0..b8c13d2193060f94f957178f8f01052c62593d41 100644 (file)
@@ -6,14 +6,13 @@ using namespace std;
 namespace Msp {
 namespace IO {
 
-Base::Base():
-       mode(M_READ),
-       eof_flag(false)
+Base::Base()
 { }
 
 Base::~Base()
 {
        signal_deleted.emit();
+       delete mutex;
 }
 
 void Base::check_access(Mode m) const
@@ -29,7 +28,7 @@ bool Base::getline(string &line)
        if(eof_flag)
                return false;
 
-       while(1)
+       while(!eof())
        {
                int c = get();
                if(c==-1 || c=='\n')
@@ -57,5 +56,19 @@ void Base::set_eof()
        }
 }
 
+
+Base::Synchronize::Synchronize(Base &i):
+       io(i)
+{
+       if(!io.mutex)
+               io.mutex = new Mutex;
+       io.mutex->lock();
+}
+
+Base::Synchronize::~Synchronize()
+{
+       io.mutex->unlock();
+}
+
 } // namespace IO
 } // namespace Msp