diff options
author | Mike Buland <eichlan@xagasoft.com> | 2012-03-25 20:00:08 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2012-03-25 20:00:08 +0000 |
commit | 469bbcf0701e1eb8a6670c23145b0da87357e178 (patch) | |
tree | b5b062a16e46a6c5d3410b4e574cd0cc09057211 /src/stable/conduit.h | |
parent | ee1b79396076edc4e30aefb285fada03bb45e80d (diff) | |
download | libbu++-469bbcf0701e1eb8a6670c23145b0da87357e178.tar.gz libbu++-469bbcf0701e1eb8a6670c23145b0da87357e178.tar.bz2 libbu++-469bbcf0701e1eb8a6670c23145b0da87357e178.tar.xz libbu++-469bbcf0701e1eb8a6670c23145b0da87357e178.zip |
Code is all reorganized. We're about ready to release. I should write up a
little explenation of the arrangement.
Diffstat (limited to 'src/stable/conduit.h')
-rw-r--r-- | src/stable/conduit.h | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/src/stable/conduit.h b/src/stable/conduit.h new file mode 100644 index 0000000..9babaaf --- /dev/null +++ b/src/stable/conduit.h | |||
@@ -0,0 +1,64 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2007-2011 Xagasoft, All rights reserved. | ||
3 | * | ||
4 | * This file is part of the libbu++ library and is released under the | ||
5 | * terms of the license contained in the file LICENSE. | ||
6 | */ | ||
7 | |||
8 | #ifndef BU_CONDUIT_H | ||
9 | #define BU_CONDUIT_H | ||
10 | |||
11 | #include "bu/stream.h" | ||
12 | #include "bu/string.h" | ||
13 | #include "bu/queuebuf.h" | ||
14 | #include "bu/mutex.h" | ||
15 | #include "bu/condition.h" | ||
16 | |||
17 | namespace Bu | ||
18 | { | ||
19 | /** | ||
20 | * Simple inter-thread communication stream. This acts like a pair of | ||
21 | * pipes for stream communication between any two things, but without the | ||
22 | * use of pipes, making this a bad choice for IPC. | ||
23 | */ | ||
24 | class Conduit : public Stream | ||
25 | { | ||
26 | public: | ||
27 | Conduit( int iBlockSize=256 ); | ||
28 | virtual ~Conduit(); | ||
29 | |||
30 | virtual void close(); | ||
31 | virtual Bu::size read( void *pBuf, Bu::size nBytes ); | ||
32 | virtual Bu::size peek( void *pBuf, Bu::size nBytes ); | ||
33 | virtual Bu::size peek( void *pBuf, Bu::size nBytes, Bu::size nSkip ); | ||
34 | virtual Bu::size write( const void *pBuf, Bu::size nBytes ); | ||
35 | virtual Bu::size tell(); | ||
36 | virtual void seek( Bu::size offset ); | ||
37 | virtual void setPos( Bu::size pos ); | ||
38 | virtual void setPosEnd( Bu::size pos ); | ||
39 | virtual bool isEos(); | ||
40 | virtual bool isOpen(); | ||
41 | virtual void flush(); | ||
42 | virtual bool canRead(); | ||
43 | virtual bool canWrite(); | ||
44 | virtual bool isReadable(); | ||
45 | virtual bool isWritable(); | ||
46 | virtual bool isSeekable(); | ||
47 | virtual bool isBlocking(); | ||
48 | virtual void setBlocking( bool bBlocking=true ); | ||
49 | virtual void setSize( Bu::size iSize ); | ||
50 | |||
51 | virtual size getSize() const; | ||
52 | virtual size getBlockSize() const; | ||
53 | virtual Bu::String getLocation() const; | ||
54 | |||
55 | private: | ||
56 | QueueBuf qb; | ||
57 | mutable Mutex im; | ||
58 | Condition cBlock; | ||
59 | bool bBlocking; | ||
60 | bool bOpen; | ||
61 | }; | ||
62 | } | ||
63 | |||
64 | #endif | ||