libUTL++
IOmux.h
1 #pragma once
2 
4 
5 #include <libutl/Array.h>
6 #include <libutl/Stream.h>
7 
9 
10 UTL_NS_BEGIN;
11 
23 
25 class IOmux : public Stream
26 {
28 
29 public:
35  IOmux(uint_t mode, bool owner = true)
36  {
37  init(mode, owner);
38  }
39 
41  virtual void close();
42 
43  virtual void copy(const Object& rhs);
44 
46  bool
47  add(const Stream* stream)
48  {
49  setError(false);
50  return _streams.add(stream);
51  }
52 
53  virtual void checkOK();
54 
56  bool remove(const Stream* stream);
57 
59  bool setInput(const Stream* stream);
60 
62  bool
63  isOwner() const
64  {
65  return _streams.isOwner();
66  }
67 
69  void
70  setOwner(bool owner)
71  {
72  super::setOwner(owner);
73  _streams.setOwner(owner);
74  }
75 
77  const TArray<Stream>&
78  streams() const
79  {
80  return _streams;
81  }
82 
83  virtual size_t read(byte_t* array, size_t maxBytes, size_t minBytes = size_t_max);
84 
85  virtual void write(const byte_t* array, size_t num);
86 
87 protected:
88  size_t _input;
89  TArray<Stream> _streams;
90 
91 private:
92  void init(uint_t mode = io_rdwr, bool owner = true);
93  void
94  deInit()
95  {
96  }
97 };
98 
100 
101 UTL_NS_END;
const TArray< Stream > & streams() const
Get the array of associated stream.
Definition: IOmux.h:78
void deInit()
De-initialize UTL++.
#define UTL_CLASS_DECL(DC, BC)
Declaration of standard UTL++ functionality for a non-template class.
Definition: macros.h:688
unsigned char byte_t
Unsigned character.
Definition: types.h:31
read/write
Definition: util.h:60
const size_t size_t_max
Maximum size_t value.
void copy(T *dest, const T *src, size_t len)
Copy one array of objects to another.
Definition: util_inl.h:690
Template version of Array.
Definition: TArray.h:25
bool add(const Stream *stream)
Add a stream.
Definition: IOmux.h:47
unsigned int uint_t
Unsigned integer.
Definition: types.h:59
bool isOwner() const
Get the owner flag.
Definition: IOmux.h:63
Stream I/O abstraction.
Definition: Stream.h:68
void setOwner(bool owner)
Set the owner flag.
Definition: IOmux.h:70
Stream (de)-multiplexor.
Definition: IOmux.h:25
IOmux(uint_t mode, bool owner=true)
Constructor.
Definition: IOmux.h:35
Root of UTL++ class hierarchy.
Definition: Object.h:52
void init()
Initialize UTL++.