switched to autobrief
This commit is contained in:
+30
-30
@@ -29,7 +29,7 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
/** @brief the available data types. */
|
||||
/** the available data types. */
|
||||
enum DataType {
|
||||
dt_none, //!< default for __text_only__
|
||||
dt_bool, //!< boolean
|
||||
@@ -40,14 +40,14 @@ enum DataType {
|
||||
dt_string //!< string
|
||||
};
|
||||
|
||||
/** @brief option types. */
|
||||
/** option types. */
|
||||
enum OptionType {
|
||||
ot_none, //!< no option type is needed
|
||||
ot_optional, //!< a value is optional
|
||||
ot_mandatory //!< a value is mandatory
|
||||
};
|
||||
|
||||
/** @brief structure for defining application options */
|
||||
/** structure for defining application options */
|
||||
typedef struct {
|
||||
const char* name; //!< long option name
|
||||
const char* shortname; //!< short option name
|
||||
@@ -57,7 +57,7 @@ typedef struct {
|
||||
} opt_t;
|
||||
|
||||
/**
|
||||
* @brief union for option values
|
||||
* union for option values
|
||||
*/
|
||||
union OptVal {
|
||||
/** boolean */
|
||||
@@ -76,36 +76,36 @@ union OptVal {
|
||||
const char* c;
|
||||
|
||||
/**
|
||||
* @brief clear memory
|
||||
* clear memory
|
||||
*/
|
||||
OptVal() { memset(this, 0, sizeof(OptVal)); }
|
||||
|
||||
/**
|
||||
* @brief create boolean type
|
||||
* create boolean type
|
||||
* @param _b the boolean
|
||||
*/
|
||||
OptVal(bool _b) : b(_b) {}
|
||||
|
||||
/**
|
||||
* @brief create integer type
|
||||
* create integer type
|
||||
* @param _i the integer
|
||||
*/
|
||||
OptVal(int _i) : i(_i) {}
|
||||
|
||||
/**
|
||||
* @brief create long type
|
||||
* create long type
|
||||
* @param _l the long
|
||||
*/
|
||||
OptVal(long _l) : l(_l) {}
|
||||
|
||||
/**
|
||||
* @brief create float type
|
||||
* create float type
|
||||
* @param _f the float
|
||||
*/
|
||||
OptVal(float _f) : f(_f) {}
|
||||
|
||||
/**
|
||||
* @brief create string type
|
||||
* create string type
|
||||
* @param _c the string
|
||||
*/
|
||||
OptVal(const char* _c) : c(_c) {}
|
||||
@@ -113,14 +113,14 @@ union OptVal {
|
||||
|
||||
|
||||
/**
|
||||
* @brief class for all kinds of application parameters.
|
||||
* class for all kinds of application parameters.
|
||||
*/
|
||||
class Appl
|
||||
{
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief create an instance and return the reference.
|
||||
* create an instance and return the reference.
|
||||
* @param command string for help page.
|
||||
* @param argument string for help page.
|
||||
* @return the reference to instance.
|
||||
@@ -128,24 +128,24 @@ public:
|
||||
static Appl& Instance(const char* command="", const char* argument="");
|
||||
|
||||
/**
|
||||
* @brief destructor.
|
||||
* destructor.
|
||||
*/
|
||||
~Appl();
|
||||
|
||||
/**
|
||||
* @brief save application version string.
|
||||
* save application version string.
|
||||
* @param version string.
|
||||
*/
|
||||
void setVersion(const char* version) { m_version = version; }
|
||||
|
||||
/**
|
||||
* @brief create new entry of application option only for help page.
|
||||
* create new entry of application option only for help page.
|
||||
* @param text string to print.
|
||||
*/
|
||||
void addText(const char* text);
|
||||
|
||||
/**
|
||||
* @brief create new entry of application option.
|
||||
* create new entry of application option.
|
||||
* @param name the long name.
|
||||
* @param shortname optional short name.
|
||||
* @param optval value of option.
|
||||
@@ -157,7 +157,7 @@ public:
|
||||
DataType datatype, OptionType optiontype, const char* description);
|
||||
|
||||
/**
|
||||
* @brief returns the value of the interested option.
|
||||
* returns the value of the interested option.
|
||||
* @param name the interested option.
|
||||
* @return casted value.
|
||||
*/
|
||||
@@ -169,7 +169,7 @@ public:
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief parse application arguments.
|
||||
* parse application arguments.
|
||||
* @param argc the number of options.
|
||||
* @param argv the given options.
|
||||
* @return false if the arguments are invalid or a help/error message was printed and the process should exit.
|
||||
@@ -177,32 +177,32 @@ public:
|
||||
bool parseArgs(int argc, char* argv[]);
|
||||
|
||||
/**
|
||||
* @brief returns the number of saved commands and arguments.
|
||||
* returns the number of saved commands and arguments.
|
||||
* @return number of commands and arguments.
|
||||
*/
|
||||
int numArgs() const { return m_arguments.size(); }
|
||||
/**
|
||||
* @brief returns the string of an interested argument.
|
||||
* returns the string of an interested argument.
|
||||
* @param num number of interested argument.
|
||||
* @return the argument string.
|
||||
*/
|
||||
string getArg(const int num) const { return m_arguments[num]; }
|
||||
|
||||
/**
|
||||
* @brief returns the string of given command.
|
||||
* returns the string of given command.
|
||||
* @return the command string.
|
||||
*/
|
||||
string getCommand() const { return m_command; }
|
||||
|
||||
/**
|
||||
* @brief Get whether a command string is missing.
|
||||
* Get whether a command string is missing.
|
||||
* @return true if a command string is missing.
|
||||
*/
|
||||
bool missingCommand() const { return (m_command.size() == 0 ? true : false); }
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief private construtor.
|
||||
* private construtor.
|
||||
* @param command string for help page.
|
||||
* @param argument string for help page.
|
||||
*/
|
||||
@@ -210,13 +210,13 @@ private:
|
||||
: m_version(NULL), m_withCommand(command), m_withArgument(argument) {}
|
||||
|
||||
/**
|
||||
* @brief private copy construtor.
|
||||
* private copy construtor.
|
||||
* @param reference to an instance.
|
||||
*/
|
||||
Appl(const Appl&);
|
||||
|
||||
/**
|
||||
* @brief private = operator.
|
||||
* private = operator.
|
||||
* @param reference to an instance.
|
||||
* @return reference to instance.
|
||||
*/
|
||||
@@ -253,7 +253,7 @@ private:
|
||||
vector<string> m_arguments;
|
||||
|
||||
/**
|
||||
* @brief checks the passed parameter if this is a valid option.
|
||||
* checks the passed parameter if this is a valid option.
|
||||
* @param option to check.
|
||||
* @param value to save.
|
||||
* @return true if parameter is a valid option.
|
||||
@@ -261,7 +261,7 @@ private:
|
||||
bool checkOption(const string& option, const string& value);
|
||||
|
||||
/**
|
||||
* @brief save the passed value to option.
|
||||
* save the passed value to option.
|
||||
* @param option name.
|
||||
* @param value to save.
|
||||
* @param datatype of given option.
|
||||
@@ -269,19 +269,19 @@ private:
|
||||
void setOptVal(const char* option, const string value, DataType datatype);
|
||||
|
||||
/**
|
||||
* @brief print application version.
|
||||
* print application version.
|
||||
* @return false.
|
||||
*/
|
||||
bool printVersion();
|
||||
|
||||
/**
|
||||
* @brief print help page.
|
||||
* print help page.
|
||||
* @return false.
|
||||
*/
|
||||
bool printHelp();
|
||||
|
||||
/**
|
||||
* @brief print used option settings.
|
||||
* print used option settings.
|
||||
* @return false.
|
||||
*/
|
||||
bool printSettings();
|
||||
|
||||
+10
-10
@@ -25,49 +25,49 @@
|
||||
/** \file daemon.h */
|
||||
|
||||
/**
|
||||
* @brief class to daemonize a process.
|
||||
* class to daemonize a process.
|
||||
*/
|
||||
class Daemon
|
||||
{
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief create an instance and return the reference.
|
||||
* create an instance and return the reference.
|
||||
* @return the reference to instance.
|
||||
*/
|
||||
static Daemon& Instance();
|
||||
|
||||
/**
|
||||
* @brief daemonize act process.
|
||||
* daemonize act process.
|
||||
* @param pidfile the name of the pid file.
|
||||
*/
|
||||
void run(const char* pidfile);
|
||||
|
||||
/**
|
||||
* @brief stop daemon and delete the pid file.
|
||||
* stop daemon and delete the pid file.
|
||||
*/
|
||||
void stop() { if (m_pidfile != NULL) pidfile_close(); }
|
||||
|
||||
/**
|
||||
* @brief show actual status if daemonize.
|
||||
* show actual status if daemonize.
|
||||
* @return true if process is a daemon.
|
||||
*/
|
||||
bool status() { return m_status; }
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief private construtor.
|
||||
* private construtor.
|
||||
*/
|
||||
Daemon() : m_status(false), m_pidfile(NULL), m_pidfd(0) {}
|
||||
|
||||
/**
|
||||
* @brief private copy construtor.
|
||||
* private copy construtor.
|
||||
* @param reference to an instance.
|
||||
*/
|
||||
Daemon(const Daemon&);
|
||||
|
||||
/**
|
||||
* @brief private = operator.
|
||||
* private = operator.
|
||||
* @param reference to an instance.
|
||||
* @return reference to instance.
|
||||
*/
|
||||
@@ -83,13 +83,13 @@ private:
|
||||
int m_pidfd;
|
||||
|
||||
/**
|
||||
* @brief creates a pid file for process.
|
||||
* creates a pid file for process.
|
||||
* @return true if success.
|
||||
*/
|
||||
bool pidfile_open();
|
||||
|
||||
/**
|
||||
* @brief close and delete the pid file.
|
||||
* close and delete the pid file.
|
||||
* @return true if success.
|
||||
*/
|
||||
bool pidfile_close();
|
||||
|
||||
+41
-41
@@ -32,7 +32,7 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
/** @brief available types for all subsystems */
|
||||
/** available types for all subsystems */
|
||||
enum AreasType {
|
||||
bas=0, /*!< basis */
|
||||
net, /*!< network */
|
||||
@@ -41,7 +41,7 @@ enum AreasType {
|
||||
Size_of_Areas=4 /*!< number of possible areas */
|
||||
};
|
||||
|
||||
/** @brief available logging levels */
|
||||
/** available logging levels */
|
||||
enum LevelType {
|
||||
error=0, /*!< silent run, only errors will be printed */
|
||||
event, /*!< only interesting message for normal use */
|
||||
@@ -51,28 +51,28 @@ enum LevelType {
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Calculate the mask of logging areas from string.
|
||||
* Calculate the mask of logging areas from string.
|
||||
* @param areas the string to parse the areas from.
|
||||
* @return the bit combination of @a AreasType.
|
||||
*/
|
||||
int calcAreaMask(const string areas);
|
||||
|
||||
/**
|
||||
* @brief Calculate the log level from string.
|
||||
* Calculate the log level from string.
|
||||
* @param level the level as string.
|
||||
* @return @a the LevelType.
|
||||
*/
|
||||
LevelType calcLevel(const string level);
|
||||
|
||||
/**
|
||||
* @brief class which describes a logging message itself.
|
||||
* class which describes a logging message itself.
|
||||
*/
|
||||
class LogMessage
|
||||
{
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief creates a new logging message.
|
||||
* creates a new logging message.
|
||||
* @param area the logging area of the message.
|
||||
* @param level the logging level of the message.
|
||||
* @param text the logging message.
|
||||
@@ -80,25 +80,25 @@ public:
|
||||
LogMessage(const int area, const int level, const string text);
|
||||
|
||||
/**
|
||||
* @brief get the logging area.
|
||||
* get the logging area.
|
||||
* @return the logging area.
|
||||
*/
|
||||
int getArea() const { return m_area; }
|
||||
|
||||
/**
|
||||
* @brief get the logging level.
|
||||
* get the logging level.
|
||||
* @return the logging level.
|
||||
*/
|
||||
int getLevel() const { return m_level; }
|
||||
|
||||
/**
|
||||
* @brief get the logging text.
|
||||
* get the logging text.
|
||||
* @return the logging text.
|
||||
*/
|
||||
string getText() const { return m_text.c_str(); }
|
||||
|
||||
/**
|
||||
* @brief get the logging timestamp.
|
||||
* get the logging timestamp.
|
||||
* @return the logging timestamp.
|
||||
*/
|
||||
string getTime() const { return m_time.c_str(); }
|
||||
@@ -119,55 +119,55 @@ private:
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief base class for all type of logging sinks.
|
||||
* base class for all type of logging sinks.
|
||||
*/
|
||||
class LogSink : public Thread
|
||||
{
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief creates a virtual logging sink.
|
||||
* creates a virtual logging sink.
|
||||
* @param areaMask the logging area mask.
|
||||
* @param level the logging level.
|
||||
*/
|
||||
LogSink(const int areaMask, const int level) : m_areaMask(areaMask), m_level(level) {}
|
||||
|
||||
/**
|
||||
* @brief destructor.
|
||||
* destructor.
|
||||
*/
|
||||
virtual ~LogSink();
|
||||
|
||||
/**
|
||||
* @brief adds the logging message to internal message queue.
|
||||
* adds the logging message to internal message queue.
|
||||
* @param message a reference to logging message.
|
||||
*/
|
||||
void addMessage(const LogMessage& message);
|
||||
|
||||
/**
|
||||
* @brief endless loop for logging sink instance.
|
||||
* endless loop for logging sink instance.
|
||||
*/
|
||||
void run();
|
||||
|
||||
/**
|
||||
* @brief get the logging area mask.
|
||||
* get the logging area mask.
|
||||
* @return the logging area mask.
|
||||
*/
|
||||
int getAreaMask() const { return m_areaMask; }
|
||||
|
||||
/**
|
||||
* @brief set the logging area mask.
|
||||
* set the logging area mask.
|
||||
* @param areaMask the logging area mask.
|
||||
*/
|
||||
void setAreaMask(const int& areaMask) { m_areaMask = areaMask; }
|
||||
|
||||
/**
|
||||
* @brief get the logging level.
|
||||
* get the logging level.
|
||||
* @return the logging level.
|
||||
*/
|
||||
int getLevel() const { return (m_level); }
|
||||
|
||||
/**
|
||||
* @brief set the logging level.
|
||||
* set the logging level.
|
||||
* @param level the logging level.
|
||||
*/
|
||||
void setLevel(const int& level) { m_level = level; }
|
||||
@@ -186,7 +186,7 @@ private:
|
||||
protected:
|
||||
|
||||
/**
|
||||
* @brief virtual function for writing the logging message.
|
||||
* virtual function for writing the logging message.
|
||||
* @param message the logging message.
|
||||
*/
|
||||
virtual void write(const LogMessage& message) const = 0;
|
||||
@@ -194,14 +194,14 @@ protected:
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief class for console logging sink type.
|
||||
* class for console logging sink type.
|
||||
*/
|
||||
class LogConsole : public LogSink
|
||||
{
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief creates a console logging sink.
|
||||
* creates a console logging sink.
|
||||
* @param areaMask the logging area mask.
|
||||
* @param level the logging level.
|
||||
* @param name the thread name for logging sink.
|
||||
@@ -210,14 +210,14 @@ public:
|
||||
: LogSink(areaMask, level) { this->start(name); }
|
||||
|
||||
/**
|
||||
* @brief destructor.
|
||||
* destructor.
|
||||
*/
|
||||
virtual ~LogConsole() {}
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
* @brief write the logging message to stdout.
|
||||
* write the logging message to stdout.
|
||||
* @param message the logging message.
|
||||
*/
|
||||
virtual void write(const LogMessage& message) const;
|
||||
@@ -225,14 +225,14 @@ protected:
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief class for logfile logging sink type.
|
||||
* class for logfile logging sink type.
|
||||
*/
|
||||
class LogFile : public LogSink
|
||||
{
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief creates a log file logging sink.
|
||||
* creates a log file logging sink.
|
||||
* @param areaMask the logging area mask.
|
||||
* @param level the logging level.
|
||||
* @param name the thread name for logging sink.
|
||||
@@ -242,7 +242,7 @@ public:
|
||||
: LogSink(areaMask, level), m_file(file) { this->start(name); }
|
||||
|
||||
/**
|
||||
* @brief destructor.
|
||||
* destructor.
|
||||
*/
|
||||
virtual ~LogFile() {}
|
||||
|
||||
@@ -254,7 +254,7 @@ private:
|
||||
protected:
|
||||
|
||||
/**
|
||||
* @brief write the logging message to specific log file.
|
||||
* write the logging message to specific log file.
|
||||
* @param message the logging message.
|
||||
*/
|
||||
virtual void write(const LogMessage& message) const;
|
||||
@@ -262,51 +262,51 @@ protected:
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief logger base class which provide the logging interface.
|
||||
* logger base class which provide the logging interface.
|
||||
*/
|
||||
class Logger : public Thread
|
||||
{
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief create an instance and return the reference.
|
||||
* create an instance and return the reference.
|
||||
* @return the reference to instance.
|
||||
*/
|
||||
static Logger& Instance();
|
||||
|
||||
/**
|
||||
* @brief destructor.
|
||||
* destructor.
|
||||
*/
|
||||
virtual ~Logger();
|
||||
|
||||
/**
|
||||
* @brief Add a @a LogSink.
|
||||
* Add a @a LogSink.
|
||||
* @param sink the used @a LogSink.
|
||||
* @return the reference to this @a Logger.
|
||||
*/
|
||||
Logger& operator+=(LogSink* sink);
|
||||
|
||||
/**
|
||||
* @brief Remove a @a LogSink and delete it.
|
||||
* Remove a @a LogSink and delete it.
|
||||
* @param sink the used @a LogSink.
|
||||
* @return the reference to this @a Logger.
|
||||
*/
|
||||
Logger& operator-=(const LogSink* sink);
|
||||
|
||||
/**
|
||||
* @brief Set the logging area mask on all @a LogSink instances.
|
||||
* Set the logging area mask on all @a LogSink instances.
|
||||
* @param areaMask the logging area mask.
|
||||
*/
|
||||
void setAreaMask(const int& areaMask);
|
||||
|
||||
/**
|
||||
* @brief Set the logging level on all @a LogSink instances.
|
||||
* Set the logging level on all @a LogSink instances.
|
||||
* @param level the logging level.
|
||||
*/
|
||||
void setLevel(const int& level);
|
||||
|
||||
/**
|
||||
* @brief Return whether a @a LogSink is available that will produce output for the specified area and level.
|
||||
* Return whether a @a LogSink is available that will produce output for the specified area and level.
|
||||
* @param area the logging area of the message.
|
||||
* @param level the logging level of the message.
|
||||
* @return whether a @a LogSink is available that will produce output for the specified area and level.
|
||||
@@ -314,7 +314,7 @@ public:
|
||||
bool hasSink(const int area, const int level);
|
||||
|
||||
/**
|
||||
* @brief creates a logging message and add them to internal message queue.
|
||||
* creates a logging message and add them to internal message queue.
|
||||
* @param area the logging area of the message.
|
||||
* @param level the logging level of the message.
|
||||
* @param text the logging message.
|
||||
@@ -335,25 +335,25 @@ protected:
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief private constructor.
|
||||
* private constructor.
|
||||
*/
|
||||
Logger() : m_direct(true), m_sink(NULL) {}
|
||||
|
||||
/**
|
||||
* @brief private copy constructor.
|
||||
* private copy constructor.
|
||||
* @param reference to an instance.
|
||||
*/
|
||||
Logger(const Logger&);
|
||||
|
||||
/**
|
||||
* @brief private = operator.
|
||||
* private = operator.
|
||||
* @param reference to an instance.
|
||||
* @return reference to instance.
|
||||
*/
|
||||
Logger& operator=(const Logger&);
|
||||
|
||||
/**
|
||||
* @brief Distribute the @a LogMessage to all known sinks and delete it afterwards.
|
||||
* Distribute the @a LogMessage to all known sinks and delete it afterwards.
|
||||
* @param mesage the @a LogMessage to distribute.
|
||||
*/
|
||||
void handleMessage(LogMessage* message);
|
||||
|
||||
@@ -26,14 +26,14 @@
|
||||
/** \file notify.h */
|
||||
|
||||
/**
|
||||
* @brief class to notify other thread per pipe.
|
||||
* class to notify other thread per pipe.
|
||||
*/
|
||||
class Notify
|
||||
{
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief constructs a new instance and do notifying.
|
||||
* constructs a new instance and do notifying.
|
||||
*/
|
||||
Notify()
|
||||
{
|
||||
@@ -49,18 +49,18 @@ public:
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief destructor.
|
||||
* destructor.
|
||||
*/
|
||||
~Notify() { close(m_sendfd); close(m_recvfd); }
|
||||
|
||||
/**
|
||||
* @brief file descriptor to watch for notify event.
|
||||
* file descriptor to watch for notify event.
|
||||
* @return the notification value.
|
||||
*/
|
||||
int notifyFD() { return m_recvfd; }
|
||||
|
||||
/**
|
||||
* @brief write notify event to file descriptor.
|
||||
* write notify event to file descriptor.
|
||||
* @return result of writing notification.
|
||||
*/
|
||||
int notify() const { return write(m_sendfd,"1",1); }
|
||||
|
||||
+17
-17
@@ -29,7 +29,7 @@
|
||||
using namespace std;
|
||||
|
||||
/**
|
||||
* @brief class for low level tcp socket operations. (open, close, send, receive).
|
||||
* class for low level tcp socket operations. (open, close, send, receive).
|
||||
*/
|
||||
class TCPSocket
|
||||
{
|
||||
@@ -42,12 +42,12 @@ public:
|
||||
friend class TCPServer;
|
||||
|
||||
/**
|
||||
* @brief destructor.
|
||||
* destructor.
|
||||
*/
|
||||
~TCPSocket() { close(m_sfd); }
|
||||
|
||||
/**
|
||||
* @brief write bytes to opened file descriptor.
|
||||
* write bytes to opened file descriptor.
|
||||
* @param buffer data to send.
|
||||
* @param len number of bytes to send.
|
||||
* @return number of written bytes or -1 if an error has occured.
|
||||
@@ -55,7 +55,7 @@ public:
|
||||
ssize_t send(const char* buffer, size_t len) { return ::send(m_sfd, buffer, len, MSG_NOSIGNAL); }
|
||||
|
||||
/**
|
||||
* @brief read bytes from opened file descriptor.
|
||||
* read bytes from opened file descriptor.
|
||||
* @param buffer for received bytes.
|
||||
* @param len size of the receive buffer.
|
||||
* @return number of read bytes or -1 if an error has occured.
|
||||
@@ -63,25 +63,25 @@ public:
|
||||
ssize_t recv(char* buffer, size_t len) { return ::recv(m_sfd, buffer, len, 0); }
|
||||
|
||||
/**
|
||||
* @brief returns the tcp port.
|
||||
* returns the tcp port.
|
||||
* @return the tcp port.
|
||||
*/
|
||||
int getPort() const { return m_port; }
|
||||
|
||||
/**
|
||||
* @brief returns the ip address.
|
||||
* returns the ip address.
|
||||
* @return the ip address.
|
||||
*/
|
||||
string getIP() const { return m_ip; }
|
||||
|
||||
/**
|
||||
* @brief returns the file descriptor.
|
||||
* returns the file descriptor.
|
||||
* @return the file descriptor.
|
||||
*/
|
||||
int getFD() const { return m_sfd; }
|
||||
|
||||
/**
|
||||
* @brief returns status of file descriptor.
|
||||
* returns status of file descriptor.
|
||||
* @return true if file descriptor is valid.
|
||||
*/
|
||||
bool isValid();
|
||||
@@ -97,7 +97,7 @@ private:
|
||||
string m_ip;
|
||||
|
||||
/**
|
||||
* @brief private constructor, limited access only for friend classes.
|
||||
* private constructor, limited access only for friend classes.
|
||||
* @param sfd the file desctriptor of tcp socket.
|
||||
* @param address struct which holds the ip address.
|
||||
*/
|
||||
@@ -106,14 +106,14 @@ private:
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief class to initiate a tcp socket connection to a listening server.
|
||||
* class to initiate a tcp socket connection to a listening server.
|
||||
*/
|
||||
class TCPClient
|
||||
{
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief initiate a tcp socket connection to a listening server.
|
||||
* initiate a tcp socket connection to a listening server.
|
||||
* @param server the server name or ip address to connect.
|
||||
* @param port the tcp port.
|
||||
* @return pointer to an opened tcp socket.
|
||||
@@ -123,14 +123,14 @@ public:
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief class for a tcp based network server.
|
||||
* class for a tcp based network server.
|
||||
*/
|
||||
class TCPServer
|
||||
{
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief creates a new instance of a listening tcp server.
|
||||
* creates a new instance of a listening tcp server.
|
||||
* @param port the tcp port.
|
||||
* @param address the ip address.
|
||||
*/
|
||||
@@ -138,24 +138,24 @@ public:
|
||||
: m_lfd(0), m_port(port), m_address(address), m_listening(false) {}
|
||||
|
||||
/**
|
||||
* @brief destructor.
|
||||
* destructor.
|
||||
*/
|
||||
~TCPServer() { if (m_lfd > 0) {close(m_lfd);} }
|
||||
|
||||
/**
|
||||
* @brief start listening of tcp socket.
|
||||
* start listening of tcp socket.
|
||||
* @return result of low level functions.
|
||||
*/
|
||||
int start();
|
||||
|
||||
/**
|
||||
* @brief accept an incomming tcp connection and create a local tcp socket for communication.
|
||||
* accept an incomming tcp connection and create a local tcp socket for communication.
|
||||
* @return pointer to an opened tcp socket.
|
||||
*/
|
||||
TCPSocket* newSocket();
|
||||
|
||||
/**
|
||||
* @brief returns the file descriptor.
|
||||
* returns the file descriptor.
|
||||
* @return the file descriptor.
|
||||
*/
|
||||
int getFD() const { return m_lfd; }
|
||||
|
||||
+12
-12
@@ -25,61 +25,61 @@
|
||||
/** \file thread.h */
|
||||
|
||||
/**
|
||||
* @brief wrapper class for pthread.
|
||||
* wrapper class for pthread.
|
||||
*/
|
||||
class Thread
|
||||
{
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief constructor.
|
||||
* constructor.
|
||||
*/
|
||||
Thread() : m_threadid(0), m_started(false), m_running(false), m_stopped(false), m_detached(false) {}
|
||||
|
||||
/**
|
||||
* @brief virtual destructor.
|
||||
* virtual destructor.
|
||||
*/
|
||||
virtual ~Thread();
|
||||
|
||||
/**
|
||||
* @brief Thread entry helper for pthread_create.
|
||||
* Thread entry helper for pthread_create.
|
||||
* @param arg pointer to the @a Thread.
|
||||
* @return NULL.
|
||||
*/
|
||||
static void* runThread(void* arg);
|
||||
|
||||
/**
|
||||
* @brief Return whether this @a Thread is still running and not yet stopped.
|
||||
* Return whether this @a Thread is still running and not yet stopped.
|
||||
* @return true if this @a Thread is till running and not yet stopped.
|
||||
*/
|
||||
virtual bool isRunning() { return m_running == true && m_stopped == false; }
|
||||
|
||||
/**
|
||||
* @brief Create the native thread and set its name.
|
||||
* Create the native thread and set its name.
|
||||
* @param name the thread name to show in the process list.
|
||||
* @return whether the thread was started.
|
||||
*/
|
||||
virtual bool start(const char* name);
|
||||
|
||||
/**
|
||||
* @brief Notify the thread that it shall stop.
|
||||
* Notify the thread that it shall stop.
|
||||
*/
|
||||
virtual void stop() { m_stopped = true; }
|
||||
|
||||
/**
|
||||
* @brief Join the thread.
|
||||
* Join the thread.
|
||||
* @return whether the thread was joined.
|
||||
*/
|
||||
virtual bool join();
|
||||
|
||||
/**
|
||||
* @brief Detach the thread.
|
||||
* Detach the thread.
|
||||
* @return whether the thread was detached.
|
||||
*/
|
||||
virtual bool detach();
|
||||
|
||||
/**
|
||||
* @brief Get the thread id.
|
||||
* Get the thread id.
|
||||
* @return the thread id.
|
||||
*/
|
||||
pthread_t self() {return m_threadid; }
|
||||
@@ -87,14 +87,14 @@ public:
|
||||
protected:
|
||||
|
||||
/**
|
||||
* @brief Thread entry method to be overridden by derived class.
|
||||
* Thread entry method to be overridden by derived class.
|
||||
*/
|
||||
virtual void run() = 0;
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* @brief Enter the Thread loop by calling run().
|
||||
* Enter the Thread loop by calling run().
|
||||
*/
|
||||
void enter();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user