137 #define DASHEL_VERSION "1.1.0" 138 #define DASHEL_VERSION_INT 10100 191 static std::map<int, std::pair<std::string, std::string> > getPorts();
203 IPV4Address(
unsigned addr = 0,
unsigned short prt = 0);
206 IPV4Address(
const std::string& name,
unsigned short port);
218 std::string format(
const bool resolveName =
true)
const;
221 std::string hostname()
const;
231 std::map<std::string, std::string> values;
232 std::vector<std::string> params;
236 void add(
const char *line);
244 void addParam(
const char *param,
const char *value = NULL,
bool atStart =
false);
247 bool isSet(
const char *key)
const;
251 template<
typename T> T
get(
const char *key)
const;
254 const std::string&
get(
const char *key)
const;
257 std::string getString()
const;
260 void erase(
const char *key);
270 std::string failReason;
283 Stream(
const std::string& protocolName) : failedFlag(false), protocolName(protocolName) {}
299 bool failed()
const {
return failedFlag; }
331 virtual void write(
const void *data,
const size_t size) = 0;
337 template<
typename T>
void write(T v)
339 write(&v,
sizeof(T));
347 virtual void flush() = 0;
357 virtual void read(
void *data,
size_t size) = 0;
428 Hub(
const bool resolveIncomingNames =
true);
443 Stream* connect(
const std::string &target);
467 bool step(
const int timeout = 0);
524 typedef Stream* (*CreatorFunc)(
const std::string& target,
const Hub& hub);
530 void reg(
const std::string& proto,
const CreatorFunc func);
533 Stream* create(
const std::string& proto,
const std::string& target,
const Hub& hub)
const;
536 std::string list()
const;
549 return new C(target);
556 return new C(target, hub);
A data stream, that can be later send data as at UDP packet or read data from an UDP packet...
Definition: dashel.h:381
Some I/O error.
Definition: dashel.h:155
Stream(const std::string &protocolName)
Constructor.
Definition: dashel.h:283
const std::string & getTargetParameter(const char *param) const
Returns the value of a parameter extracted from the target.
Definition: dashel.h:320
The central place where to create, destroy, and synchronize streams.
Definition: dashel.h:407
virtual void connectionCreated(Stream *)
Called when any data connection is created.
Definition: dashel.h:492
bool failed() const
Query failed state of stream.
Definition: dashel.h:299
The target string was bad.
Definition: dashel.h:152
const bool resolveIncomingNames
Whether Dashel should try to resolve the peer's hostname of incoming TCP connections.
Definition: dashel.h:422
A IP version 4 address.
Definition: dashel.h:195
Parameter set.
Definition: dashel.h:228
virtual void connectionClosed(Stream *, bool)
Called when target closes connection.
Definition: dashel.h:517
void write(T v)
Write a variable of basic type to the stream.
Definition: dashel.h:337
A data stream, with low-level (not-endian safe) read/write functions.
Definition: dashel.h:264
Source source
The exception cause.
Definition: dashel.h:162
The connection was lost.
Definition: dashel.h:154
ParameterSet target
The target description.
Definition: dashel.h:274
Serial port enumerator class.
Definition: dashel.h:181
CreatorMap creators
streams that can be created
Definition: dashel.h:542
The one size fits all exception for streams.
Definition: dashel.h:145
StreamTypeRegistry streamTypeRegistry
The registry of all known stream types.
Dashel, a cross-platform stream abstraction library.
Definition: dashel.h:132
The operation is not valid on this stream.
Definition: dashel.h:153
virtual void incomingData(Stream *)
Called when data is available for reading on the stream.
Definition: dashel.h:504
DashelException(Source s, int se, const char *reason, Stream *stream=NULL)
Construct an stream exception with everything.
The incoming data was not read by the Hub subclass.
Definition: dashel.h:158
unsigned address
IP host address. Stored in local byte order.
Definition: dashel.h:198
T read()
Read a variable of basic type from the stream.
Definition: dashel.h:364
Well, hopefully never used.
Definition: dashel.h:150
unsigned short port
IP port. Stored in local byte order.
Definition: dashel.h:199
StreamsSet dataStreams
All our streams that transfer data (in opposition to streams that just listen for data)...
Definition: dashel.h:419
const std::string & getFailReason() const
Returns the reason the stream has failed.
Definition: dashel.h:304
Stream * createInstanceWithHub(const std::string &target, const Hub &hub)
Create an instance of stream type C, passing target to its constructor.
Definition: dashel.h:554
Some synchronisation error.
Definition: dashel.h:151
std::set< Stream * > StreamsSet
A list of streams.
Definition: dashel.h:411
Stream * createInstance(const std::string &target, const Hub &hub)
Create an instance of stream type C, passing target to its constructor.
Definition: dashel.h:547
virtual ~Stream()
Virtual destructor, to ensure calls to destructors of sub-classes.
Definition: dashel.h:286
int sysError
The reason as an OS error code.
Definition: dashel.h:164
T get(const char *key) const
Get a parameter value.
const std::string & getProtocolName() const
Returns the protocol name of the stream.
Definition: dashel.h:307
std::map< std::string, CreatorFunc > CreatorMap
a map of stream type names to constructors and arguments
Definition: dashel.h:540
Registry of constructors to a stream, to add new stream types dynamically.
Definition: dashel.h:521
Some serial enumeration error.
Definition: dashel.h:157
std::string getTargetName() const
Returns the name of the target.
Definition: dashel.h:314
Stream * stream
The stream that caused the exception to be thrown.
Definition: dashel.h:166
Source
The different exception causes.
Definition: dashel.h:149
PacketStream(const std::string &protocolName)
Constructor.
Definition: dashel.h:385
std::string protocolName
The protocol name.
Definition: dashel.h:276
The connection could not be established.
Definition: dashel.h:156
std::string getString() const
Get the parameters as string.