AURobotServers  4
Public Member Functions | Protected Member Functions | List of all members
UClientPortSml Class Reference

#include <uclientport.h>

Inheritance diagram for UClientPortSml:
Inheritance graph

Public Member Functions

virtual const char * getSourceName ()
 
 UClientPortSml ()
 
- Public Member Functions inherited from UClientPort
bool blockSend (const char *buffer, int length)
 
void closeConnection ()
 
int getDataFromLine (char *buffer, int bufferSize, int pollTimeoutMs)
 
const char * getHost ()
 
const char * getHostIP ()
 
int getPort ()
 
bool isConnected ()
 
bool isVerbose ()
 
bool sendMsg (const char *message)
 
bool sendWithLock (const char *message)
 
void setHost (const char *toHost)
 
void setPort (int toPort)
 
void setVerbose (bool value)
 
bool tryConnect ()
 
 UClientPort ()
 
virtual ~UClientPort ()
 
- Public Member Functions inherited from ULock
bool lock ()
 
void lockInit ()
 
void post ()
 
bool tryLock ()
 
bool tryWait ()
 
 ULock ()
 
void unlock ()
 
bool wait ()
 
 ~ULock ()
 
- Public Member Functions inherited from USmlSource
void allowTagAtStartOfLineOnly ()
 
const char * getErrorBuffer ()
 
virtual int getLineNumber ()
 
virtual int getNBytes (char *buffer, int n, int msTimeout=100)
 
virtual bool getNextTag (USmlTag *tag, int msTimeout=100, USmlTagIn *failEndTag=NULL, char *beforeTagBuffer=NULL, int *beforeTagCnt=NULL)
 
char * getRxDataBuffer ()
 
int getRxDataBufferCnt ()
 
bool getToEndTag (USmlTagIn *tag, char *buffer, const int bufferSize, int msTimeout=100, USmlTagIn *lastTag=NULL)
 
bool isErrorText ()
 
bool isVerbose ()
 
virtual bool logSourceData (const char *, int)
 
void setErrorBuffer (char *buf, const int bufCnt)
 
virtual void setLineNumber (int)
 
int setRxDataBufferCnt (int newMaxLength)
 
virtual bool skipNBytes (int n, int msTimeout=100)
 
virtual bool skipToEndTag (USmlTagIn *tag, int msTimeout=100)
 
virtual void syntaxError (const char *message)
 
 USmlSource ()
 
virtual ~USmlSource ()
 

Protected Member Functions

virtual bool doVerboseMessages ()
 
virtual int getMoreData (char *buffer, int bufferSize, int pollTimeoutMs)
 
virtual bool isSourceAvailable ()
 
virtual bool outputData (const char *message)
 
- Protected Member Functions inherited from UClientPort
virtual void connectionChange (bool nowConnected)
 
virtual void sendNamespaceOpenTag ()
 
- Protected Member Functions inherited from USmlSource
void clearRxBuffer ()
 

Additional Inherited Members

- Public Attributes inherited from UClientPort
int rxByteCnt
 
ULock tx
 
- Public Attributes inherited from USmlSource
const char * ifName
 
- Protected Types inherited from UClientPort
enum  { notLost, forReopen, rxError, txError }
 
- Protected Attributes inherited from UClientPort
enum UClientPort:: { ... }  connectionLostReason
 
UTime connectTime
 
char host [MAX_HOST_LENGTH]
 
char hostIP [MAX_HOST_LENGTH]
 
int port
 
unsigned int readCnt
 
bool verboseMessages
 
- Protected Attributes inherited from USmlSource
int dataCnt
 
char * errorBuffer
 
int errorBufferCnt
 
bool gotFirstTag
 
bool tagStartAtStartOfLineOnly
 

Detailed Description

class that extends the client post functions with a receive buffer and functions to handle simple SML formatted tags.

Constructor & Destructor Documentation

UClientPortSml::UClientPortSml ( )

Constructor

Member Function Documentation

bool UClientPortSml::doVerboseMessages ( )
protectedvirtual

Should additional messaves be printed to console

Reimplemented from USmlSource.

References UClientPort::verboseMessages.

int UClientPortSml::getMoreData ( char *  buffer,
int  bufferSize,
int  pollTimeoutMs 
)
protectedvirtual

Get more data, if more data is available.

Parameters
buffer,putthe new data in the buffer
bufferSize,butnot more that this number of bytes
waitat maximum this number of ms for more data
Returns
the number of bytes available in buffer, or -1 if source is no longer available.

Reimplemented from USmlSource.

References UClientPort::getDataFromLine().

Referenced by UClientHandler::threadRunLoop().

virtual const char* UClientPortSml::getSourceName ( )
inlinevirtual

Got an unusable message - just skip to other end. 'tag' should point to the start tag, of which the content is unwanted. timeout is in miliseconds, when waiting for new data. Returns true when relevant end-tag is removed from the stream or false when a period of 'msTimeout' has passed with no data. Skip N bytes (from a binary message). Returns true if n bytes skipped. Returns false if timeout or source is down. Get the next n bytes loaded into the provided buffer. N may be of any length (that can be received within the timeout period). Returns the number of bytes loaded into the buffer. If source is invalid or no data is available zero is returned. Read the next available tag into the provided buffer. The found tag is loaded into the 'tag' buffer. if 'beforeTagBuffer' != NULL then the data before the next tag is stored in this buffer. The buffer size is initiated in 'beforeTagCnt'. The number of bytes befor the next tag is also returned into 'beforeTagCnt'. If there is more data before the next tag than the space in 'beforeTagBuffer' then the function returns with 'beforeTagBuffer' equal to the buffer size and the function returnes true. Note the buffer is NOT nul-terminated (to allow binary data), so the user must add a nul at the 'beforeTagCnt' position if the result is used as a string. The search is also stopped if an end-tag is found matching the 'failEndTag' (makes the function return false). Returns true if tag is valid (and the beforeTagBuffer has no overflow). Get source name pointer for the SML source

Reimplemented from USmlSource.

References UClientPort::getHost().

bool UClientPortSml::isSourceAvailable ( )
protectedvirtual

Discard all data in buffer – assumed garbage, e.g server reply error Is tha data source (still) open.

Returns
true if open

Reimplemented from USmlSource.

References UClientPort::isConnected().

bool UClientPortSml::outputData ( const char *  message)
protectedvirtual

Output a reply to the source (if possible, e.g. a socket connection)

Parameters
messageis 0-terminated
Returns
true if send.

Reimplemented from USmlSource.

References UClientPort::sendWithLock().


The documentation for this class was generated from the following files: