BDataIO: Provide default implementations for Read()/Write()
This makes the interface somewhat more suitable for unidirectional use, since one doesn't have to implement the other, not needed method.
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2007 Haiku, Inc. All rights reserved.
|
* Copyright 2007-2014 Haiku, Inc. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -38,7 +38,7 @@
|
|||||||
|
|
||||||
The interface provided by this class applies to objects or data that are
|
The interface provided by this class applies to objects or data that are
|
||||||
limited to reading and writing data. Classes derived from this class should
|
limited to reading and writing data. Classes derived from this class should
|
||||||
re-implement both the Read() and Write() method from this class.
|
re-implement the Read() or the Write() method from this class or both.
|
||||||
|
|
||||||
Candidates of types of data or objects that should be derived from this class
|
Candidates of types of data or objects that should be derived from this class
|
||||||
are probably broadcasting media streams (which don't support reading at a
|
are probably broadcasting media streams (which don't support reading at a
|
||||||
@@ -62,22 +62,28 @@
|
|||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn virtual ssize_t BDataIO::Read(void *buffer, size_t size) = 0
|
\fn virtual ssize_t BDataIO::Read(void *buffer, size_t size)
|
||||||
\brief Pure virtual to read data.
|
\brief Reads data from the object into a buffer.
|
||||||
|
|
||||||
Your implementation should copy data into \c buffer, with the maximum size
|
Your implementation should copy data into \c buffer, with the maximum size
|
||||||
of \c size.
|
of \c size.
|
||||||
\return You should return the amount of bytes actually read, or an error code
|
|
||||||
in case of failure.
|
The default implementation is a no-op returning \c B_NOT_SUPPORTED.
|
||||||
|
|
||||||
|
\return You should return the amount of bytes actually read, or an error
|
||||||
|
code in case of failure.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn virtual ssize_t BDataIO::Write(const void *buffer, size_t size) = 0
|
\fn virtual ssize_t BDataIO::Write(const void *buffer, size_t size)
|
||||||
\brief Pure virtual to write data.
|
\brief Writes data from a buffer to the object.
|
||||||
|
|
||||||
Your implementation should copy data from \c buffer, with the maximum size
|
Your implementation should copy data from \c buffer, with the maximum size
|
||||||
of \c size.
|
of \c size.
|
||||||
|
|
||||||
|
The default implementation is a no-op returning \c B_NOT_SUPPORTED.
|
||||||
|
|
||||||
\return You should return the amount of bytes actually written, or an error
|
\return You should return the amount of bytes actually written, or an error
|
||||||
code in case of failure.
|
code in case of failure.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2005-2010, Haiku, Inc. All rights reserved.
|
* Copyright 2005-2014, Haiku, Inc. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
#ifndef _DATA_IO_H
|
#ifndef _DATA_IO_H
|
||||||
@@ -14,8 +14,8 @@ public:
|
|||||||
BDataIO();
|
BDataIO();
|
||||||
virtual ~BDataIO();
|
virtual ~BDataIO();
|
||||||
|
|
||||||
virtual ssize_t Read(void* buffer, size_t size) = 0;
|
virtual ssize_t Read(void* buffer, size_t size);
|
||||||
virtual ssize_t Write(const void* buffer, size_t size) = 0;
|
virtual ssize_t Write(const void* buffer, size_t size);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BDataIO(const BDataIO&);
|
BDataIO(const BDataIO&);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2005-2006, Haiku.
|
* Copyright 2005-2014, Haiku, Inc.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -24,6 +24,20 @@ BDataIO::~BDataIO()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ssize_t
|
||||||
|
BDataIO::Read(void* buffer, size_t size)
|
||||||
|
{
|
||||||
|
return B_NOT_SUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ssize_t
|
||||||
|
BDataIO::Write(const void* buffer, size_t size)
|
||||||
|
{
|
||||||
|
return B_NOT_SUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Private or Reserved
|
// Private or Reserved
|
||||||
|
|
||||||
BDataIO::BDataIO(const BDataIO &)
|
BDataIO::BDataIO(const BDataIO &)
|
||||||
|
|||||||
Reference in New Issue
Block a user