[Saga-devel] saga SVN commit 3408: /trunk/adaptors/default/stream/
hkaiser at cct.lsu.edu
hkaiser at cct.lsu.edu
Fri Jan 30 10:39:06 CST 2009
User: hkaiser
Date: 2009/01/30 10:39 AM
Modified:
/trunk/adaptors/default/stream/
stream.cpp, stream.hpp
Log:
Fixing ticket #291
File Changes:
Directory: /trunk/adaptors/default/stream/
==========================================
File [modified]: stream.cpp
Delta lines: +26 -24
===================================================================
--- trunk/adaptors/default/stream/stream.cpp 2009-01-30 16:23:39 UTC (rev 3407)
+++ trunk/adaptors/default/stream/stream.cpp 2009-01-30 16:39:03 UTC (rev 3408)
@@ -99,6 +99,22 @@
}
///////////////////////////////////////////////////////////////////////////////
+void stream::check_if_open (std::string const& functionname,
+ saga::url const& location)
+{
+ saga::stream::state state = retrieve_state();
+ if (saga::stream::Open != state || !sock_->is_open())
+ {
+ SAGA_OSSTREAM errstrm;
+ errstrm << functionname << ": stream (" << location.get_url()
+ << ") is not in 'Open' state, current state is: "
+ << saga::adaptors::get_state_name(state);
+ SAGA_ADAPTOR_THROW(SAGA_OSSTREAM_GETSTRING(errstrm),
+ saga::IncorrectState);
+ }
+}
+
+///////////////////////////////////////////////////////////////////////////////
void stream::update_state(saga::stream::state newstate)
{
// update state attribute and promote state change to the metric callbacks
@@ -203,6 +219,10 @@
stream::sync_wait(std::vector<saga::stream::activity>& ret,
saga::stream::activity act, double timeout)
{
+ {
+ instance_data_type data (this);
+ check_if_open("stream::sync_wait", data->location_);
+ }
SAGA_ADAPTOR_THROW("Not Implemented (stream::sync_wait)",
saga::NotImplemented);
}
@@ -210,15 +230,9 @@
void stream::sync_close(saga::impl::void_t& ret, double timeout)
{
// verify stream is 'Open'
- saga::stream::state state = retrieve_state();
- if (saga::stream::Open != state)
{
- SAGA_OSSTREAM errstrm;
- errstrm << "stream::sync_close: stream is not in 'Open' state, "
- "current state is: "
- << saga::adaptors::get_state_name(state);
- SAGA_ADAPTOR_THROW(SAGA_OSSTREAM_GETSTRING(errstrm),
- saga::IncorrectState);
+ instance_data_type data (this);
+ check_if_open("stream::sync_wait", data->location_);
}
// positive timeout is not supported
@@ -260,15 +274,9 @@
saga::ssize_t len_in)
{
// verify stream is 'Open'
- saga::stream::state state = retrieve_state();
- if (saga::stream::Open != state)
{
- SAGA_OSSTREAM errstrm;
- errstrm << "stream::sync_read: stream is not in 'Open' state, "
- "current state is: "
- << saga::adaptors::get_state_name(state);
- SAGA_ADAPTOR_THROW(SAGA_OSSTREAM_GETSTRING(errstrm),
- saga::IncorrectState);
+ instance_data_type data (this);
+ check_if_open("stream::sync_wait", data->location_);
}
mutex_type::scoped_lock l(this->mtx_);
@@ -332,15 +340,9 @@
saga::ssize_t len_out)
{
// verify stream is 'Open'
- saga::stream::state state = retrieve_state();
- if (saga::stream::Open != state)
{
- SAGA_OSSTREAM errstrm;
- errstrm << "stream::sync_read: stream is not in 'Open' state, "
- "current state is: "
- << saga::adaptors::get_state_name(state);
- SAGA_ADAPTOR_THROW(SAGA_OSSTREAM_GETSTRING(errstrm),
- saga::IncorrectState);
+ instance_data_type data (this);
+ check_if_open("stream::sync_wait", data->location_);
}
mutex_type::scoped_lock l(this->mtx_);
File [modified]: stream.hpp
Delta lines: +3 -0
===================================================================
--- trunk/adaptors/default/stream/stream.hpp 2009-01-30 16:23:39 UTC (rev 3407)
+++ trunk/adaptors/default/stream/stream.hpp 2009-01-30 16:39:03 UTC (rev 3408)
@@ -98,6 +98,9 @@
protected:
void update_state(saga::stream::state newstate);
saga::stream::state retrieve_state();
+
+ void check_if_open (std::string const& functionname,
+ saga::url const& location);
}; // class stream
} // namespace stream
More information about the saga-devel
mailing list