143 #define DASHEL_VERSION "1.3.3" 144 #define DASHEL_VERSION_INT 10301 201 static std::map<int, std::pair<std::string, std::string> > getPorts();
213 IPV4Address(
unsigned addr = 0,
unsigned short prt = 0);
216 IPV4Address(
const std::string& name,
unsigned short port);
228 std::string format(
const bool resolveName =
true)
const;
231 std::string hostname()
const;
241 std::map<std::string, std::string> values;
242 std::vector<std::string> params;
246 void add(
const char *line);
254 void addParam(
const char *param,
const char *value = NULL,
bool atStart =
false);
257 bool isSet(
const char *key)
const;
261 template<
typename T> T
get(
const char *key)
const;
264 const std::string&
get(
const char *key)
const;
267 std::string getString()
const;
270 void erase(
const char *key);
280 std::string failReason;
293 explicit Stream(
const std::string& protocolName) : failedFlag(false), protocolName(protocolName) {}
309 bool failed()
const {
return failedFlag; }
346 virtual void write(
const void *data,
const size_t size) = 0;
352 template<
typename T>
void write(T v)
354 write(&v,
sizeof(T));
362 virtual void flush() = 0;
372 virtual void read(
void *data,
size_t size) = 0;
443 explicit Hub(
const bool resolveIncomingNames =
true);
458 Stream* connect(
const std::string &target);
482 bool step(
const int timeout = 0);
539 typedef Stream* (*CreatorFunc)(
const std::string& target,
const Hub& hub);
545 void reg(
const std::string& proto,
const CreatorFunc func);
548 Stream* create(
const std::string& proto,
const std::string& target,
const Hub& hub)
const;
551 std::string list()
const;
564 return new C(target);
571 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:396
Some I/O error.
Definition: dashel.h:161
Stream(const std::string &protocolName)
Constructor.
Definition: dashel.h:293
const ParameterSet getTarget() const
Returns the target description.
Definition: dashel.h:335
const std::string & getTargetParameter(const char *param) const
Returns the value of a parameter extracted from the target.
Definition: dashel.h:330
virtual void connectionClosed(Stream *stream, bool abnormal)
Called when target closes connection.
Definition: dashel.h:532
The central place where to create, destroy, and synchronize streams.
Definition: dashel.h:422
bool failed() const
Query failed state of stream.
Definition: dashel.h:309
virtual void incomingData(Stream *stream)
Called when data is available for reading on the stream.
Definition: dashel.h:519
The target string was bad.
Definition: dashel.h:158
const bool resolveIncomingNames
Whether Dashel should try to resolve the peer's hostname of incoming TCP connections.
Definition: dashel.h:437
A IP version 4 address.
Definition: dashel.h:205
static std::string sourceToString(Source s)
Return a string description of the source error.
Parameter set.
Definition: dashel.h:238
void write(T v)
Write a variable of basic type to the stream.
Definition: dashel.h:352
A data stream, with low-level (not-endian safe) read/write functions.
Definition: dashel.h:274
Source source
The exception cause.
Definition: dashel.h:168
The connection was lost.
Definition: dashel.h:160
ParameterSet target
The target description.
Definition: dashel.h:284
Serial port enumerator class.
Definition: dashel.h:191
CreatorMap creators
streams that can be created
Definition: dashel.h:557
The one size fits all exception for streams.
Definition: dashel.h:151
StreamTypeRegistry streamTypeRegistry
The registry of all known stream types.
Dashel, a cross-platform stream abstraction library.
Definition: dashel.h:138
The operation is not valid on this stream.
Definition: dashel.h:159
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:164
unsigned address
IP host address. Stored in local byte order.
Definition: dashel.h:208
T read()
Read a variable of basic type from the stream.
Definition: dashel.h:379
Well, hopefully never used.
Definition: dashel.h:156
unsigned short port
IP port. Stored in local byte order.
Definition: dashel.h:209
StreamsSet dataStreams
All our streams that transfer data (in opposition to streams that just listen for data)...
Definition: dashel.h:434
const std::string & getFailReason() const
Returns the reason the stream has failed.
Definition: dashel.h:314
Stream * createInstanceWithHub(const std::string &target, const Hub &hub)
Create an instance of stream type C, passing target to its constructor.
Definition: dashel.h:569
Some synchronisation error.
Definition: dashel.h:157
std::set< Stream * > StreamsSet
A list of streams.
Definition: dashel.h:426
Stream * createInstance(const std::string &target, const Hub &hub)
Create an instance of stream type C, passing target to its constructor.
Definition: dashel.h:562
virtual ~Stream()
Virtual destructor, to ensure calls to destructors of sub-classes.
Definition: dashel.h:296
int sysError
The reason as an OS error code.
Definition: dashel.h:170
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:317
virtual void connectionCreated(Stream *stream)
Called when any data connection is created.
Definition: dashel.h:507
std::map< std::string, CreatorFunc > CreatorMap
a map of stream type names to constructors and arguments
Definition: dashel.h:555
Registry of constructors to a stream, to add new stream types dynamically.
Definition: dashel.h:536
Some serial enumeration error.
Definition: dashel.h:163
std::string getTargetName() const
Returns the name of the target.
Definition: dashel.h:324
Stream * stream
The stream that caused the exception to be thrown.
Definition: dashel.h:172
Source
The different exception causes.
Definition: dashel.h:155
PacketStream(const std::string &protocolName)
Constructor.
Definition: dashel.h:400
std::string protocolName
The protocol name.
Definition: dashel.h:286
The connection could not be established.
Definition: dashel.h:162
std::string getString() const
Get the parameters as string.