nidas v1.2.3
|
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 | 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 | BitArray |
A class for holding bits. More... | |
class | Cond |
A wrapper class for a Posix condition variable. More... | |
class | DatagramPacket |
class | DatagramPacketBase |
Abstract base class for a UDP datagram. More... | |
class | DatagramPacketT |
A DatagramPacket with a specific structure of data. More... | |
class | DatagramSocket |
A socket for sending or receiving datagrams, either unicast, broadcast or multicast. More... | |
class | DetachedThread |
A Thread with a constructor that sets detached=true. More... | |
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 | 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 | FlipConverter |
EndianConverter that flips bytes, used for conversion of little-to-big and big-to-little. 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 | LogConfig |
A configuration to enable or disable a matching set of log points. More... | |
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 | LogContextState |
LogContextState holds the status members of a LogContext and related behavior. More... | |
class | Logger |
Simple logging class, based on UNIX syslog interface. More... | |
class | LoggerPrivate |
class | LogMessage |
A class for formatting and streaming a log message. More... | |
class | LogScheme |
A LogScheme is a vector of LogConfig's and the vector of fields to show in log messages. 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... | |
struct | McSocketData |
class | McSocketDatagram |
Datagram that is multicast by a host when it wants a service. 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 | MulticastSocket |
A datagram socket to be used for multicasts. More... | |
class | Multisync |
class | Mutex |
A C++ wrapper for a POSIX mutex. More... | |
class | MutexAttributes |
A C++ wrapper for a POSIX mutex attributes. More... | |
class | MutexCount |
A class which wraps a numeric value and guards operations on it with a Mutex. More... | |
class | NoFlipConverter |
EndianConverter that doesn't flip bytes. 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 | Runnable |
class | RunningAverage |
Basic running average template class. More... | |
class | RWLock |
A C++ wrapper for a POSIX rwlock. More... | |
class | RWLockAttributes |
A C++ wrapper for a POSIX rwlock attributes. More... | |
class | Semaphore |
A POSIX semaphore. More... | |
class | SerialOptions |
Class providing a method to parse a string into a Termios. More... | |
class | SerialPort |
class | ServerSocket |
A stream (TCP) socket that is used to listen for connections. More... | |
class | Socket |
A stream (TCP) socket. More... | |
class | SocketAddress |
An interface for a socket address. More... | |
class | SocketImpl |
Implementation of a socket, providing a C++ interface to system socket calls: socket,bind,listen,accept,setsockopt, etc. More... | |
class | Synchronized |
Synchronized is used a simple guard object for critical sections. More... | |
class | Termios |
A class providing get/set methods into a termios structure. More... | |
class | Thread |
class | ThreadJoiner |
In certain situations one needs to "join oneself", which would be a deadlock. More... | |
class | ThreadRunnable |
The ThreadRunnable class implements a Thread which uses a Runnable target to supply the run() method. 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. | |
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. | |
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. | |
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. | |
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. | |
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. | |
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. | |
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. | |
void | flipFloatOut (const float &v, void *p) |
Function for writing a 4 byte float value to an address, flipping the bytes. | |
void | flipInt64Out (const int64_t &v, void *p) |
Function for writing an 8 byte, 64 bit int value to an address, flipping the bytes. | |
void | flipInt32Out (const int32_t &v, void *p) |
Function for writing a 4 byte, 32 bit int value to an address, flipping the bytes. | |
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. | |
void | flipInt16Out (const int16_t &v, void *p) |
Function for writing a 2 byte 16 bit int value to an address, flipping the bytes. | |
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. | |
bool | NMEAchecksumOK (const char *rec, int len) |
Calculate the checksum of a NMEA message and return a logical indicating whether it is equal to the checksum at the end of the message. | |
int | stringToLogLevel (const std::string &slevel) |
Convert the name of a log level to its integer value. | |
string | logLevelToString (int) |
Convert an integral log level to a string name. | |
LogMessage & | endlog (LogMessage &logmsg) |
LogMessage manipulator which logs the current message buffer, if any, and then clears the message. | |
LogMessage & | operator<< (LogMessage &logmsg, LogMessage &(*op)(LogMessage &)) |
Template to call LogMessage manipulators like endlog when streamed to a LogMessage. | |
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. | |
std::string | addBackslashSequences (const std::string &str) |
Utility function for substituting backslash sequences back into a string. | |
void | trimString (std::string &str) |
Utility to remove white space characters (matching isspace()) from end of string. | |
void | replaceCharsIn (std::string &in, const std::string &pat, const std::string &rep) |
Replace all occurences of pat in string in with rep. | |
std::string | replaceChars (const std::string &in, const std::string &pat, const std::string &rep) |
std::string | svnStatus (const std::string &path) |
Run "svn status -v --depth empty" on a path and return a concatentated string of revision + flags, where flags are the first 8 characters. | |
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. | |
void | derive_uv_from_spd_dir (float &u, float &v, float &spd, float &dir) |
Normalize dir, then derive u and v from spd and direction. | |
void | derive_spd_dir_from_uv (float &spd, float &dir, float &u, float &v) |
Derive speed and direction from wind components u, v. | |
bool | sleepUntil (unsigned int periodMsec, unsigned int offsetMsec=0) |
Utility function, sleeps until the next even period + offset. | |
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. | |
template<typename charT > | |
UTime_stream_manip< charT > | setTZ (const std::string &val) |
Function to set the UTime timezone on an ostream. | |
long long | getSystemTime () |
Return the current unix system time, in microseconds since Jan 1, 1970, 00:00 GMT. | |
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. | |
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. | |
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 |
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.
std::string nidas::util::addBackslashSequences | ( | const std::string & | str | ) |
Utility function for substituting backslash sequences back into a string.
Referenced by SampleCounter::accumulateData(), nidas::core::IOStream::backup(), nidas::core::CharacterSensor::getBackslashedMessageSeparator(), nidas::core::MessageSampleScanner::getBackslashedMessageSeparator(), nidas::core::MessageStreamScanner::getBackslashedMessageSeparator(), nidas::dynld::isff::CSAT3_Sonic::querySonic(), DumpClient::receive(), Receiver::run(), Sender::send(), and Garmin::substCRNL().
void nidas::util::derive_spd_dir_from_uv | ( | float & | spd, |
float & | dir, | ||
float & | u, | ||
float & | v ) |
Derive speed and direction from wind components u, v.
Unlike u, v which are positive in the direction the wind is blowing towards, direction is where the wind is blowing from. If both u and v are zero, then dir is set to nan.
References dirFromUV().
void nidas::util::derive_uv_from_spd_dir | ( | float & | u, |
float & | v, | ||
float & | spd, | ||
float & | dir ) |
Normalize dir, then derive u and v from spd and direction.
u, v are the components of wind direction, positive u in the north direction, positive v in east direction, where "north" can be the instrument's reference azimuth in instrument coordinate space, or north can be geographic north. If spd is zero, then u and v are set to zero regardless of direction.
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(), derive_spd_dir_from_uv(), nidas::dynld::isff::ATIK_Sonic::process(), nidas::dynld::isff::Wind3D::process(), nidas::dynld::isff::CSAT3_Sonic::process(), and nidas::dynld::isff::CSI_IRGA_Sonic::process().
|
inline |
References flipDoubleIn().
Referenced by nidas::util::FlipConverter::doubleValue().
|
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().
|
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().
|
inline |
References flipFloatIn().
Referenced by nidas::util::FlipConverter::floatValue().
|
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().
|
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().
|
inline |
References flipInt16In().
Referenced by nidas::util::FlipConverter::int16Value().
|
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().
|
inline |
Function for writing a 2 byte 16 bit int value to an address, flipping the bytes.
Referenced by nidas::util::FlipConverter::int16Copy().
|
inline |
References flipInt32In().
Referenced by nidas::util::FlipConverter::int32Value().
|
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().
|
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().
|
inline |
References flipInt64In().
Referenced by nidas::util::FlipConverter::int64Value().
|
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().
|
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().
|
inline |
References flipUint16In().
Referenced by nidas::util::FlipConverter::uint16Value().
|
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().
|
inline |
Function for writing a 2 byte unsigned 16 bit int value to an address, flipping the bytes.
Referenced by nidas::util::FlipConverter::uint16Copy().
|
inline |
References flipUint32In().
Referenced by nidas::util::FlipConverter::uint32Value().
|
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().
|
inline |
Function for writing a 4 byte unsigned 32 bit int value to an address, flipping the bytes.
Referenced by nidas::util::FlipConverter::uint32Copy().
|
inline |
|
inline |
Return the current unix system time, in microseconds since Jan 1, 1970, 00:00 GMT.
References NSECS_PER_USEC, and USECS_PER_SEC.
Referenced by nidas::core::SampleClock::addSampleDate(), nidas::dynld::raf::IRIGSensor::checkClock(), nidas::core::SensorHandler::handlePollingChange(), nidas::dynld::isff::MOSMote::MOS_TimeSyncer::looperNotify(), nidas::dynld::raf::IRIGSensor::printStatus(), nidas::dynld::raf::TwoD_USB::printStatus(), nidas::core::MessageStreamScanner::readBuffer(), nidas::core::DatagramSampleScanner::readBuffer(), nidas::core::MessageStreamScanner::readBuffer(), nidas::core::SampleSorter::receive(), nidas::core::Looper::run(), nidas::core::SensorHandler::run(), nidas::core::DSMEngineStat::run(), nidas::core::DSMServerStat::run(), nidas::core::SampleClock::SampleClock(), nidas::core::SensorHandler::SensorHandler(), nidas::core::SampleClock::setTime(), sleepUntil(), and nidas::dynld::UDPSampleOutput::write().
void nidas::util::listMulticastInterfaces | ( | MulticastSocket * | requestmsock, |
std::vector< Inet4NetworkInterface > & | ifaces ) |
References nidas::util::Inet4NetworkInterface::getFlags(), and VLOG.
Referenced by nidas::util::McSocketListener::run(), and nidas::util::McSocketMulticaster< SocketTT >::run().
bool nidas::util::NMEAchecksumOK | ( | const char * | rec, |
int | len ) |
Calculate the checksum of a NMEA message and return a logical indicating whether it is equal to the checksum at the end of the message.
Referenced by nidas::dynld::GPS_NMEA_Serial::checksumOK(), nidas::dynld::GPS_NMEA_Serial::process(), and TeeI2C::writeFilteredOutput().
References operator==().
References nidas::util::BitArray::getConstPtr().
std::basic_ostream< charT, std::char_traits< charT > > & nidas::util::operator<< | ( | std::basic_ostream< charT, std::char_traits< charT > > & | os, |
const UTime & | x ) |
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 ) |
Referenced by operator!=().
References nidas::util::BitArray::getConstPtr().
References nidas::util::BitArray::getConstPtr().
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::MessageSampleScanner::setMessageParameters(), nidas::core::MessageStreamScanner::setMessageParameters(), and nidas::core::CharacterSensor::setMessageParameters().
std::string nidas::util::replaceChars | ( | const std::string & | in, |
const std::string & | pat, | ||
const std::string & | rep ) |
References replaceCharsIn().
Referenced by nidas::dynld::isff::WisardMote::createSampleTag(), and nidas::dynld::isff::WisardMote::createSampleTags().
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().
UTime_stream_manip< charT > nidas::util::setDefaultFormat | ( | const std::string & | val | ) |
Function to set the default UTime output format on an ostream.
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 ) |
Utility function, sleeps until the next even period + offset.
Returns true if interrupted.
IOException |
References getSystemTime(), MSECS_PER_SEC, NSECS_PER_MSEC, periodMsec, and USECS_PER_MSEC.
Referenced by Sender::run(), and nidas::core::Looper::run().
std::string nidas::util::svnStatus | ( | const std::string & | path | ) |
Run "svn status -v --depth empty" on a path and return a concatentated string of revision + flags, where flags are the first 8 characters.
IOException |
References nidas::util::Process::spawn(), and trimString().
|
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().
|
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().