nidas  v1.2-1520
Classes | Typedefs | Functions
nidas::util Namespace Reference

General utility classes. nidas::util contains classes of general utility, like Socket, Thread, etc. The classes use only the standard Unix system libraries and libstdc++, and have no dependency on other external packages such as an XML parser, or a logging package. More...

Classes

class  BitArray
 A class for holding bits. More...
 
class  DatagramPacketBase
 Abstract base class for a UDP datagram. More...
 
class  DatagramPacketT
 A DatagramPacket with a specific structure of data. More...
 
class  DatagramPacket
 
class  EndianConverter
 Virtual base class declaring methods for converting numeric values between little-endian and big-endian representations, and for determining the endian represenation of the host system. More...
 
class  FlipConverter
 EndianConverter that flips bytes, used for conversion of little-to-big and big-to-little. More...
 
class  NoFlipConverter
 EndianConverter that doesn't flip bytes. More...
 
class  EOFException
 
class  Exception
 
class  FileSet
 A description of a set of output files, consisting of a directory name and a file name format containing UNIX strftime conversion specifiers, like Y, m, etc. More...
 
class  Inet4Address
 Support for IP version 4 host address. More...
 
class  Inet4NetworkInterface
 
class  Inet4PacketInfo
 Ancillary information that can be determined about an incoming UDP packet. More...
 
class  Inet4PacketInfoX
 
class  Inet4SocketAddress
 A IP version 4 socket address, containing a host address, and a port number. More...
 
class  InterruptedException
 
class  InvalidParameterException
 
class  IOException
 
class  IOTimeoutException
 
class  LoggerPrivate
 
class  LogContext
 The LogContext is created at a point in the application code and filled in with details about that log point, such as the file and line number, and the function name of the containing function, and the log level of that log point, such as LOGGER_DEBUG or LOGGER_ERROR. More...
 
class  LogConfig
 A configuration to enable or disable a matching set of log points. More...
 
class  LogScheme
 A LogScheme is a vector of LogConfig's and the vector of fields to show in log messages. More...
 
class  LogMessage
 A class for formatting and streaming a log message. More...
 
class  Logger
 Simple logging class, based on UNIX syslog interface. More...
 
struct  McSocketData
 
class  McSocketDatagram
 Datagram that is multicast by a host when it wants a service. More...
 
class  McSocket
 A McSocket provides a way to establish a TCP stream socket connection, or a pair of UDP datagram sockets using a common port number. More...
 
class  McSocketListener
 Class for listening on McSocket requests on a specific multicast address and UDP port number. More...
 
class  McSocketMulticaster
 Thread which is started by McSocket to multicast requests for connections. More...
 
class  MutexCount
 A class which wraps a numeric value and guards operations on it with a Mutex. More...
 
class  ParseException
 
class  Process
 Process provides an encapsulation of a spawned process, allowing the parent process to perform I/O with the spawned process, send it signals and wait for it to finish. More...
 
class  RunningAverage
 Basic running average template class. More...
 
class  SerialOptions
 Class providing a method to parse a string into a Termios. More...
 
class  SerialPort
 
class  SocketImpl
 Implementation of a socket, providing a C++ interface to system socket calls: socket,bind,listen,accept,setsockopt, etc. More...
 
class  Socket
 A stream (TCP) socket. More...
 
class  ServerSocket
 A stream (TCP) socket that is used to listen for connections. More...
 
class  DatagramSocket
 A socket for sending or receiving datagrams, either unicast, broadcast or multicast. More...
 
class  MulticastSocket
 A datagram socket to be used for multicasts. More...
 
class  SocketAddress
 An interface for a socket address. More...
 
class  Termios
 A class providing get/set methods into a termios structure. More...
 
class  Runnable
 
class  Thread
 
class  DetachedThread
 A Thread with a constructor that sets detached=true. More...
 
class  ThreadRunnable
 The ThreadRunnable class implements a Thread which uses a Runnable target to supply the run() method. More...
 
class  ThreadJoiner
 In certain situations one needs to "join oneself", which would be a deadlock. More...
 
class  MutexAttributes
 A C++ wrapper for a POSIX mutex attributes. More...
 
class  RWLockAttributes
 A C++ wrapper for a POSIX rwlock attributes. More...
 
class  Mutex
 A C++ wrapper for a POSIX mutex. More...
 
class  Cond
 A wrapper class for a Posix condition variable. More...
 
class  RWLock
 A C++ wrapper for a POSIX rwlock. More...
 
class  Semaphore
 A POSIX semaphore. More...
 
class  Multisync
 
class  Synchronized
 Synchronized is used a simple guard object for critical sections. More...
 
class  Autolock
 Autolock is used a simple guard object for critical sections. More...
 
class  AutoRdLock
 Autolock for acquiring/releasing a read lock on a RWLock. More...
 
class  AutoWrLock
 Autolock for acquiring/releasing a write lock on a RWLock. More...
 
class  UnixSocketAddress
 An AF_UNIX socket address. More...
 
class  UnknownHostException
 
class  UTime
 A class for parsing, formatting and doing operations on time, based on Unix time conventions, where leap seconds are ignored, so that there are always 60 seconds in a minute, 3600 seconds in an hour and 86400 seconds in a day. More...
 
class  UTime_stream_manip
 class for changing output format of UTime on ostream, in a way like the standard stream manipulator classes. More...
 

Typedefs

typedef ThreadRunnable DefaultThread
 

Functions

BitArray operator| (const BitArray &x, const BitArray &y)
 
BitArray operator& (const BitArray &x, const BitArray &y)
 
BitArray operator^ (const BitArray &x, const BitArray &y)
 
bool operator== (const BitArray &x, const BitArray &y)
 
bool operator!= (const BitArray &x, const BitArray &y)
 
double flipDoubleIn (const void *p)
 Function for reading 8 bytes from an address, flipping the bytes, and returning the double value. More...
 
double flipDouble (const double &p)
 
float flipFloatIn (const void *p)
 Function for reading 4 bytes from an address, flipping the bytes, and returning the float value. More...
 
float flipFloat (const float &p)
 
int64_t flipInt64In (const void *p)
 Function for reading 8 bytes from an address, flipping the bytes, and returning the int64_t value. More...
 
int64_t flipInt64 (const int64_t &p)
 
int32_t flipInt32In (const void *p)
 Function for reading 4 bytes from an address, flipping the bytes, and returning the 32 bit int value. More...
 
int32_t flipInt32 (const int32_t &p)
 
uint32_t flipUint32In (const void *p)
 Function for reading 4 bytes from an address, flipping the bytes, and returning the unsigned 32 bit int value. More...
 
uint32_t flipUint32 (const uint32_t &p)
 
int16_t flipInt16In (const void *p)
 Function for reading 2 bytes from an address, flipping the bytes, and returning the 16 bit int value. More...
 
int16_t flipInt16 (const int16_t &p)
 
uint16_t flipUint16In (const void *p)
 Function for reading 2 bytes from an address, flipping the bytes, and returning the unsigned 16 bit int value. More...
 
uint16_t flipUint16 (const uint16_t &p)
 
void flipDoubleOut (const double &v, void *p)
 Function for writing an 8 byte double value to an address, flipping the bytes. More...
 
void flipFloatOut (const float &v, void *p)
 Function for writing a 4 byte float value to an address, flipping the bytes. More...
 
void flipInt64Out (const int64_t &v, void *p)
 Function for writing an 8 byte, 64 bit int value to an address, flipping the bytes. More...
 
void flipInt32Out (const int32_t &v, void *p)
 Function for writing a 4 byte, 32 bit int value to an address, flipping the bytes. More...
 
void flipUint32Out (const uint32_t &v, void *p)
 Function for writing a 4 byte unsigned 32 bit int value to an address, flipping the bytes. More...
 
void flipInt16Out (const int16_t &v, void *p)
 Function for writing a 2 byte 16 bit int value to an address, flipping the bytes. More...
 
void flipUint16Out (const uint16_t &v, void *p)
 Function for writing a 2 byte unsigned 16 bit int value to an address, flipping the bytes. More...
 
int stringToLogLevel (const std::string &slevel)
 Convert the name of a log level to its integer value. More...
 
string logLevelToString (int)
 Convert an integral log level to a string name. More...
 
LogMessageendlog (LogMessage &logmsg)
 LogMessage manipulator which logs the current message buffer, if any, and then clears the message. More...
 
LogMessageoperator<< (LogMessage &logmsg, LogMessage &(*op)(LogMessage &))
 Template to call LogMessage manipulators like endlog when streamed to a LogMessage. More...
 
int getMcSocketType (McSocket< Socket > *)
 
int getMcSocketType (McSocket< DatagramSocket > *)
 
void listMulticastInterfaces (MulticastSocket *requestmsock, std::vector< Inet4NetworkInterface > &ifaces)
 
std::string replaceBackslashSequences (const std::string &str)
 Utility function for replacing backslash sequences in a string. More...
 
std::string addBackslashSequences (const std::string &str)
 Utility function for substituting backslash sequences back into a string. More...
 
void trimString (std::string &str)
 Utility to remove white space characters (matching isspace()) from end of string. More...
 
void replaceCharsIn (std::string &in, const std::string &pat, const std::string &rep)
 Replace all occurences of pat in string in with rep. More...
 
std::string replaceChars (const std::string &in, const std::string &pat, const std::string &rep)
 
std::string svnStatus (const std::string &path) throw (IOException)
 Run "svn status -v --depth empty" on a path and return a concatentated string of revision + flags, where flags are the first 8 characters. More...
 
float dirFromUV (float u, float v)
 Calculate wind direction in degrees from U and V wind components, or if U and V are both zero return NAN as wind direction is undefined. More...
 
template<typename charT >
std::basic_ostream< charT,
std::char_traits< charT > > & 
operator<< (std::basic_ostream< charT, std::char_traits< charT > > &os, const UTime &x)
 
template<typename charT >
std::basic_ostream< charT,
std::char_traits< charT > > & 
operator<< (std::basic_ostream< charT, std::char_traits< charT > > &os, const UTime_stream_manip< charT > &m)
 
template<typename charT >
UTime_stream_manip< charT > setDefaultFormat (const std::string &val)
 Function to set the default UTime output format on an ostream. More...
 
template<typename charT >
UTime_stream_manip< charT > setTZ (const std::string &val)
 Function to set the UTime timezone on an ostream. More...
 
long long getSystemTime ()
 Return the current unix system time, in microseconds since Jan 1, 1970, 00:00 GMT. More...
 
long long timeCeiling (long long t, long long delta)
 Return smallest time that is an integral multiple of delta, that isn't less than or equal to argument t. More...
 
long long timeFloor (long long t, long long delta)
 Return largest time that is an integral multiple of delta, that isn't greater than argument t. More...
 
bool sleepUntil (unsigned int periodMsec, unsigned int offsetMsec=0) throw (IOException)
 Utility function, sleeps until the next even period + offset. More...
 

Variables

const int LOGGER_EMERG = LOG_EMERG
 
const int LOGGER_EMERGENCY = LOG_EMERG
 
const int LOGGER_ALERT = LOG_ALERT
 
const int LOGGER_CRIT = LOG_CRIT
 
const int LOGGER_CRITICAL = LOG_CRIT
 
const int LOGGER_ERROR = LOG_ERR
 
const int LOGGER_ERR = LOG_ERR
 
const int LOGGER_PROBLEM = LOG_ERR
 
const int LOGGER_WARNING = LOG_WARNING
 
const int LOGGER_NOTICE = LOG_NOTICE
 
const int LOGGER_INFO = LOG_INFO
 
const int LOGGER_DEBUG = LOG_DEBUG
 
const int LOGGER_VERBOSE = LOG_DEBUG+1
 
const int LOGGER_NONE = LOG_EMERG-1
 

Detailed Description

General utility classes. nidas::util contains classes of general utility, like Socket, Thread, etc. The classes use only the standard Unix system libraries and libstdc++, and have no dependency on other external packages such as an XML parser, or a logging package.

Typedef Documentation

Function Documentation

std::string nidas::util::addBackslashSequences ( const std::string &  str)
float nidas::util::dirFromUV ( float  u,
float  v 
)

Calculate wind direction in degrees from U and V wind components, or if U and V are both zero return NAN as wind direction is undefined.

Referenced by nidas::dynld::StatisticsCruncher::computeStats(), nidas::dynld::isff::ATIK_Sonic::process(), nidas::dynld::isff::CSI_IRGA_Sonic::process(), nidas::dynld::isff::Wind3D::process(), nidas::dynld::isff::CSAT3_Sonic::process(), and nidas::dynld::isff::Wind2D::process().

double nidas::util::flipDouble ( const double &  p)
inline
double nidas::util::flipDoubleIn ( const void *  p)
inline

Function for reading 8 bytes from an address, flipping the bytes, and returning the double value.

Address does not need to be 8 byte aligned.

Referenced by nidas::util::FlipConverter::doubleValue(), and flipDouble().

void nidas::util::flipDoubleOut ( const double &  v,
void *  p 
)
inline

Function for writing an 8 byte double value to an address, flipping the bytes.

Address does not need to be 8 byte aligned.

Referenced by nidas::util::FlipConverter::doubleCopy().

float nidas::util::flipFloat ( const float &  p)
inline
float nidas::util::flipFloatIn ( const void *  p)
inline

Function for reading 4 bytes from an address, flipping the bytes, and returning the float value.

Address does not need to be 4 byte aligned.

Referenced by flipFloat(), and nidas::util::FlipConverter::floatValue().

void nidas::util::flipFloatOut ( const float &  v,
void *  p 
)
inline

Function for writing a 4 byte float value to an address, flipping the bytes.

Address does not need to be 4 byte aligned.

Referenced by nidas::util::FlipConverter::floatCopy().

int16_t nidas::util::flipInt16 ( const int16_t &  p)
inline
int16_t nidas::util::flipInt16In ( const void *  p)
inline

Function for reading 2 bytes from an address, flipping the bytes, and returning the 16 bit int value.

Address does not need to be 2 byte aligned.

Referenced by flipInt16(), and nidas::util::FlipConverter::int16Value().

void nidas::util::flipInt16Out ( const int16_t &  v,
void *  p 
)
inline

Function for writing a 2 byte 16 bit int value to an address, flipping the bytes.

Referenced by nidas::util::FlipConverter::int16Copy().

int32_t nidas::util::flipInt32 ( const int32_t &  p)
inline
int32_t nidas::util::flipInt32In ( const void *  p)
inline

Function for reading 4 bytes from an address, flipping the bytes, and returning the 32 bit int value.

Address does not need to be 4 byte aligned.

Referenced by flipInt32(), and nidas::util::FlipConverter::int32Value().

void nidas::util::flipInt32Out ( const int32_t &  v,
void *  p 
)
inline

Function for writing a 4 byte, 32 bit int value to an address, flipping the bytes.

Address does not need to be 4 byte aligned.

Referenced by nidas::util::FlipConverter::int32Copy().

int64_t nidas::util::flipInt64 ( const int64_t &  p)
inline
int64_t nidas::util::flipInt64In ( const void *  p)
inline

Function for reading 8 bytes from an address, flipping the bytes, and returning the int64_t value.

Address does not need to be 8 or 4 byte aligned.

Referenced by flipInt64(), and nidas::util::FlipConverter::int64Value().

void nidas::util::flipInt64Out ( const int64_t &  v,
void *  p 
)
inline

Function for writing an 8 byte, 64 bit int value to an address, flipping the bytes.

Address does not need to be 8 or 4 byte aligned.

Referenced by nidas::util::FlipConverter::int64Copy().

uint16_t nidas::util::flipUint16 ( const uint16_t &  p)
inline
uint16_t nidas::util::flipUint16In ( const void *  p)
inline

Function for reading 2 bytes from an address, flipping the bytes, and returning the unsigned 16 bit int value.

Address does not need to be 2 byte aligned.

Referenced by flipUint16(), and nidas::util::FlipConverter::uint16Value().

void nidas::util::flipUint16Out ( const uint16_t &  v,
void *  p 
)
inline

Function for writing a 2 byte unsigned 16 bit int value to an address, flipping the bytes.

Referenced by nidas::util::FlipConverter::uint16Copy().

uint32_t nidas::util::flipUint32 ( const uint32_t &  p)
inline
uint32_t nidas::util::flipUint32In ( const void *  p)
inline

Function for reading 4 bytes from an address, flipping the bytes, and returning the unsigned 32 bit int value.

Address does not need to be 4 byte aligned.

Referenced by flipUint32(), and nidas::util::FlipConverter::uint32Value().

void nidas::util::flipUint32Out ( const uint32_t &  v,
void *  p 
)
inline

Function for writing a 4 byte unsigned 32 bit int value to an address, flipping the bytes.

Referenced by nidas::util::FlipConverter::uint32Copy().

int nidas::util::getMcSocketType ( McSocket< Socket > *  )
inline
int nidas::util::getMcSocketType ( McSocket< DatagramSocket > *  )
inline
long long nidas::util::getSystemTime ( )
inline
void nidas::util::listMulticastInterfaces ( MulticastSocket requestmsock,
std::vector< Inet4NetworkInterface > &  ifaces 
)
bool nidas::util::operator!= ( const BitArray x,
const BitArray y 
)

References operator==().

BitArray nidas::util::operator& ( const BitArray x,
const BitArray y 
)
template<typename charT >
std::basic_ostream<charT, std::char_traits<charT> >& nidas::util::operator<< ( std::basic_ostream< charT, std::char_traits< charT > > &  os,
const UTime &  x 
)
template<typename charT >
std::basic_ostream<charT, std::char_traits<charT> >& nidas::util::operator<< ( std::basic_ostream< charT, std::char_traits< charT > > &  os,
const UTime_stream_manip< charT > &  m 
)
bool nidas::util::operator== ( const BitArray x,
const BitArray y 
)
BitArray nidas::util::operator^ ( const BitArray x,
const BitArray y 
)
BitArray nidas::util::operator| ( const BitArray x,
const BitArray y 
)
std::string nidas::util::replaceBackslashSequences ( const std::string &  str)

Utility function for replacing backslash sequences in a string.

\n=newline, \r=carriage-return, \t=tab, \\=backslash \xhh=hex, where hh are (exactly) two hex digits and \000=octal, where 000 are exactly three octal digits.

Referenced by nidas::core::CharacterSensor::init(), nidas::core::SerialSensor::initPrompting(), RemoteSerial::openConnection(), SensorSimApp::parseRunstring(), FileSim::sendASCIIMessage(), nidas::core::CharacterSensor::sendInitString(), nidas::core::CharacterSensor::setMessageParameters(), nidas::core::MessageSampleScanner::setMessageParameters(), and nidas::core::MessageStreamScanner::setMessageParameters().

std::string nidas::util::replaceChars ( const std::string &  in,
const std::string &  pat,
const std::string &  rep 
)
void nidas::util::replaceCharsIn ( std::string &  in,
const std::string &  pat,
const std::string &  rep 
)

Replace all occurences of pat in string in with rep.

Referenced by replaceChars(), and nidas::core::CalFile::setDateTimeFormat().

template<typename charT >
UTime_stream_manip<charT> nidas::util::setDefaultFormat ( const std::string &  val)

Function to set the default UTime output format on an ostream.

Referenced by main().

template<typename charT >
UTime_stream_manip<charT> nidas::util::setTZ ( const std::string &  val)

Function to set the UTime timezone on an ostream.

bool nidas::util::sleepUntil ( unsigned int  periodMsec,
unsigned int  offsetMsec = 0 
)
throw (IOException
)

Utility function, sleeps until the next even period + offset.

Returns true if interrupted.

References getSystemTime(), MSECS_PER_SEC, NSECS_PER_MSEC, periodMsec, and USECS_PER_MSEC.

Referenced by nidas::core::Looper::run(), Sender::run(), and nidas::dynld::isff::GOESOutput::run().

std::string nidas::util::svnStatus ( const std::string &  path)
throw (IOException
)

Run "svn status -v --depth empty" on a path and return a concatentated string of revision + flags, where flags are the first 8 characters.

References nidas::util::Process::errStream(), nidas::util::Process::outStream(), trimString(), and nidas::util::Process::wait().

long long nidas::util::timeCeiling ( long long  t,
long long  delta 
)
inline

Return smallest time that is an integral multiple of delta, that isn't less than or equal to argument t.

Similar to to ceil() math function, except ceil() finds value that isn't less than argument, not less-than-or-equal, i.e. this function always returns a value greater than the arg.

Referenced by nidas::core::SensorHandler::calcStatistics(), nidas::core::SensorHandler::checkTimeouts(), nidas::core::SensorHandler::handlePollingChange(), nidas::core::SampleAverager::receive(), and nidas::core::SensorHandler::SensorHandler().

long long nidas::util::timeFloor ( long long  t,
long long  delta 
)
inline

Return largest time that is an integral multiple of delta, that isn't greater than argument t.

Analogous to floor() math function.

Referenced by nidas::core::SampleClock::SampleClock(), and nidas::core::SampleClock::setTime().

void nidas::util::trimString ( std::string &  str)

Utility to remove white space characters (matching isspace()) from end of string.

Referenced by nidas::core::FsMount::autoMount(), nidas::core::FsMount::mount(), nidas::dynld::isff::CSAT3_Sonic::open(), and svnStatus().