Namespaces | Classes | Typedefs | Functions | Variables

vpr Namespace Reference

Namespaces

namespace  SerialTypes
 

Serial I/O types.


namespace  SocketOptions
 

Socket-level options.


namespace  SocketTypes
 

Socket I/O types.


namespace  sim
namespace  prof
 

Set of routines for allowing simplified access to profile monitoring API.


namespace  detail

Classes

class  LibraryException
 Base class for exceptions dealing with dynamic code loading. More...
class  LibraryFinder
 Helper class that will perform dynamic library discovery based on a file extension (e.g., .so or .dll) in a specific directory. More...
class  LibraryLoader
 A helper for loading a specific class of dynamic shared objects (DSOs). More...
class  LoaderError
 Error reporting class for dynamic library loading. More...
class  SymbolLookupException
 Exception type thrown when the lookup of a symbol in dynamically loaded code fails. More...
class  BlockIO
 Block-style (as opposed to streaming) I/O interface. More...
class  BufferObjectReader
 Object reader that reads out of a data buffer. More...
class  BufferObjectWriter
 Object writer for data buffers. More...
class  EOFException
 Exception type thrown if end of file (EOF) is reached unexpectedly. More...
class  FileHandle_t
 Extension to the vpr::BlockIO interface defining a cross-platform file handle interface. More...
class  IOException
 Base class for exceptions dealing with I/O. More...
class  IOSysBase
 Base class for all for the IOSys class. More...
class  ObjectReader
 Interface used to read object data from a stream. More...
class  ObjectWriter
 Interface used to write object data to a stream. More...
class  Port
 A cross-platform interface to using a computer's I/O ports (serial, parallel, IR, etc. More...
class  SerialPort_t
 Cross-platform serial port interface. More...
class  Selector_t
 Cross-platform selection interface. More...
class  SelectorBase
 Common base for all selectors and implementations. More...
class  WriteableObject
 The abstract base class for all types that can be written to a stream. More...
class  ReadableObject
 The abstract base class for all types that can be read from a stream. More...
class  SerializableObject
 The abstract base class for all types that support serialization. More...
class  SerializableObjectMixin
 Mix-in type to add serialization capabilities to an existing type, usually one that is defined in third-party code and therefore cannot have its base type list modified. More...
class  AveragingAllocationStrategy
 This allocation strategy, designed specifically for use with vpr::NoPushWriter, keeps a sliding window of allocation sizes. More...
class  ConnectionAbortedException
 Exception type thrown if network communication fails because the connection is reset. More...
class  ConnectionRefusedException
 Exception type thrown if a connection fails because the connection is refused. More...
class  ConnectionResetException
 Exception type thrown if network communication fails because the connection is reset. More...
struct  InetAddrHash
 Nice little helper class for hashing a vpr::InetAddr. More...
class  MaximumAllocationStrategy
 A memory allocation strategy for use with vpr::NoPushWriter that keeps track of the maximum amount of memory allocated while the socket is in the no-push ("corked") state. More...
class  McastReq
 Multicast request wrapper. More...
class  NoPushWriter
 A userland implementation of no-push or "corked" writing. More...
class  NoRouteToHostException
 Exception type thrown if a connection fails because there is no route to the remote host. More...
class  Socket_t
 Cross-platform block-based socket interface. More...
class  SocketAcceptor
 Socket connection acceptor factory. More...
class  SocketConnector
 Defines a factory for creating new connections both synchronously and asynchronously. More...
class  SocketDatagram_t
 Datagram socket interface. More...
class  SocketException
 Base class for exceptions associated with network (socket) communication. More...
class  SocketStream_t
 Cross-platform stream socket class. More...
class  UnknownHostException
 Exception type thrown if a host lookup fails because the hostname is unknown. More...
class  BandwidthIOStatsStrategy
 Strategy for collecting bandwidth data about the block I/O device. More...
class  BaseIOStatsStrategy
 Base interface for IO Stat collection. More...
class  NullIOStatsStrategy
 Null strategy. More...
class  IOStatsStrategyAdapter
 This is a template adapter that combines two I/O Stats strategies together into a single class. More...
class  TimeoutException
 Exception type thrown if an I/O operation times out. More...
class  WouldBlockException
 Exception type thrown if an I/O operation would block when using a non-blocking I/O channel. More...
class  XMLObjectReader
 Object reader that reads out of a data buffer. More...
class  XMLObjectWriter
 Object writer for data buffers. More...
class  IOSysBOOST
 Wrapper around BOOST file descriptors. More...
class  SelectorImplBOOST
 Implementation of a selector for simulated sockets. More...
class  InetAddrBOOST
 Cross-platform abstraction to Internet address structures. More...
class  SocketDatagramImplBOOST
 Implementation class for datagram sockets using the BOOST sockets interface. More...
class  SocketImplBOOST
 Basic socket wrapper implementation for BOOST sockets. More...
class  SocketStreamImplBOOST
 Implementation of the stream socket wrapper using BOOST sockets. More...
class  LibraryNSPR
 Low-level class for loading symbols dynamically. More...
class  IOSysNSPR
 Wrapper around NSPR file descriptors. More...
struct  HandlePred
class  SelectorImplNSPR
 NSPR Implementation of cross-platform selection interface. More...
class  InetAddrNSPR
 Cross-platform abstraction to Internet address structures. More...
class  SocketDatagramImplNSPR
 NSPR implementation of the datagram socket interface. More...
class  SocketImplNSPR
 NSPR implementation of the base socket interface. More...
class  SocketStreamImplNSPR
 NSPR implementation of the stream-oriented socket interface. More...
class  CondVarNSPR
 Condition variable wrapper for NSPR condition variables. More...
class  MutexNSPR
 Mutex wrapper for NSPR locks. More...
class  RWMutexNSPR
 Read/write mutex implementation using NSPR read/write mutexes (PRRWLock). More...
class  SemaphoreNSPR
 Wrapper for semaphores implemented using condition variables. More...
class  SystemNSPR
 Low-level operating system feature abstractions using NSPR functionality. More...
class  ThreadKeyNSPR
 Wrapper around NSPR thread-specific data. More...
class  ThreadNSPR
 Threads implementation using the NSPR API. More...
class  ErrorImplNSPR
 NSPR Implementation of a cross-platform error reporting class. More...
class  LibraryUNIX
 Low-level class for loading symbols dynamically. More...
class  FileHandleImplUNIX
 Wrapper around UNIX file descriptors. More...
class  IOSysUnix
 Wrapper around UNIX file descriptors. More...
class  SerialPortImplTermios
 vpr::SerialPort implementation using termios. More...
class  SelectorImplBSD
 BSD Implementation of cross-platform selection interface. More...
class  InetAddrBSD
 Cross-platform abstraction to Internet address structures. More...
class  SocketDatagramImplBSD
 Implementation class for datagram sockets using the BSD sockets interface. More...
union  sockopt_data
 Define a simple union used as the optval argument to [gs]etsockopt(2). More...
class  SocketImplBSD
 Basic socket wrapper implementation for BSD sockets. More...
class  SocketStreamImplBSD
 Implementation of the stream socket wrapper using BSD sockets. More...
class  CondVarPosix
 Condition variable wrapper for POSIX-compliant systems using pthreads condition variables for the implementation. More...
class  MutexPosix
 Mutex wrapper for POSIX-compliant systems using pthreads mutex variables for the implementation. More...
class  RWMutexPosix
 RWMutex wrapper for POSIX-compliant systems using pthreads rw mutex variables for the implementation. More...
class  SemaphorePosix
 Semaphore wrapper for POSIX.4-compliant systems. More...
union  uint64_holder
class  SystemPosix
 Low-level operating system feature abstractions using POSIX functionality. More...
class  ThreadKeyPosix
 Wrapper around pthread keys (thread-specific data). More...
class  ThreadPosix
 Threads implementation using POSIX threads (both Draft 4 and the "final" draft of the standard are supported). More...
class  ErrorImplPosix
 POSIX Implementation of cross-platform error reporting class. More...
class  IOSysSIM
 Wrapper around simulated file descriptors. More...
class  SelectorImplSIM
 Implementation of a selector for simulated sockets. More...
class  InetAddrSIM
 Simulated Internet address structures. More...
class  SocketDatagramImplSIM
 Implementation of datagram sockets using simulated sockets. More...
class  SocketImplSIM
 Implementation class for simulated sockets. More...
class  SocketStreamImplSIM
 Implementation of stream sockets using simulated sockets. More...
class  LibraryWin32
 Low-level class for loading symbols dynamically. More...
class  SerialPortImplWin32
 vpr::SerialPort implementation for Win32. More...
class  CondVarWin32
 Condition variable wrapper for Win32 systems. More...
class  MutexWin32
class  SemaphoreWin32
class  SystemWin32
 Low-level operating system feature abstractions using Win32 functionality. More...
class  ThreadKeyWin32
 Wrapper around Win32 thread local storage (thread-specific data). More...
class  ThreadWin32
 Threads implementation using Win32 threads. More...
class  ErrorImplWin32
 Win32 implementation of cross-platform error reporting class. More...
class  ProfileIterator
 An iterator to navigate through the Profile tree. More...
class  ProfileManager
 Global static facade for using the profiling code. More...
class  ProfileSample
 ProfileSample is a guard style class for handle a single sample. More...
class  ProfileNode
 A node in the Profile Hierarchy Tree. More...
class  DeadlockException
 Exception type thrown if deadlock would occur when trying to perform an operation on a lock object. More...
class  Guard
 Scoped wrapper for a lock. More...
class  GuardedQueue
 A guarded queue. More...
class  LockException
 Exception type thrown if an error occurs while performing an operation on a lock object. More...
class  NullMutex
 Null mutex wrapper. More...
class  ReadGuard
 Read Guard wrapper. More...
class  WriteGuard
 Write Guard wrapper. More...
struct  TimeVal
 A data structure for storing the time value returned by vpr::System::gettimeofday(). More...
struct  TimeZone
 A data structure for storing the time zone returned by vpr::System::gettimeofday(). More...
class  SystemBase
 vpr::SystemBase is a base class for vpr::System. More...
class  BaseThread
 Base class for all thread implementations. More...
class  SignalSet
 Wrapper class for a signal set. More...
class  SignalAction
 Wrapper class for a signal action. More...
class  SigHandler
 This class wraps the calls needed to register signal handlers with the operating system. More...
class  ThreadManager
 Holds list of all threads in system. More...
class  OneThread
 Helper class for vpr::ThreadPool. More...
class  ThreadPool
 A pool of threads to process user jobs. More...
class  TSBaseObject
 Base thread-specific object. More...
class  TSObject
 Wrapper template for storing thread-specific objects. More...
class  TSObjectProxyBase
 Base class for all thread-specific object proxies. More...
class  TSObjectProxy
 This is a smart pointer to a thread-specific object. More...
class  TSTable
 This class is the actual thread-specific table. More...
class  UncaughtThreadException
 Exception type used for handling an exception that propagates up to the top of the call stack of a spawned thread. More...
class  AttributeMapBase
 Basic interface for adding attributes to classes. More...
class  BadCastException
 Exception type thrown if a cast (such as dynamic_cast) fails. More...
class  DateTime
 Simple wrapper around time since the UNIX Epoch (00:00 UTC January 1, 1970). More...
struct  DebugCategory
 Container for load-time extension of the debugging categories. More...
class  Debug
 Class to support debug output. More...
struct  DebugColumnGuard
 Helper class. More...
struct  DebugColorGuard
 Helper class. More...
class  DebugOutputGuard
 Helper class that outputs debug information at creation and destruction of the object. More...
class  DurationStatCollector
 Duration statistics collector class. More...
class  ErrorBase
 Common base for platform-specific error management. More...
class  Exception
 Base exception for all VPR exceptions. More...
struct  NullFactoryError
class  Factory
 Implements generic Factory pattern. More...
class  GUID
 A cross-platform implementation of globally unique identifiers, also known as GUIDs or UUIDs (universally unique identifiers). More...
class  IllegalArgumentException
 Exception type thrown if an illegal/invalid argument is passed in to a function. More...
class  Interval
 This class captures a high-resolution interval. More...
class  ResourceException
 Exception type thrown if resource allocation fails. More...
class  ReturnStatus
 Class used to represent the status of a function or method upon its return. More...
class  SampleLimitedStatCollector
 Statistics collection class. More...
class  Singleton
 You can use this coolio class to make a singleton, just inherit like so: More...
class  StatCollector
 Statistics collection class. More...
class  StreamLock
 Class to lock a stream for multi-process output. More...
class  StreamUnLock
 Class to unlock a stream that has been previously locked. More...
class  Timer
 Simple class to take timings and give averages. More...
struct  SocketConfiguration
 Socket configuration for BSD sockets. More...
struct  Uint64Hash
 Nice little helper class for hashing a vpr::Uint64. More...

Typedefs

typedef LibraryUNIX Library
typedef boost::shared_ptr
< Library
LibraryPtr
typedef FileHandle_t
< FileHandleImplUNIX
FileHandle
typedef Socket_t
< SocketConfiguration
Socket
typedef SocketDatagram_t
< SocketConfiguration
SocketDatagram
typedef SocketStream_t
< SocketConfiguration
SocketStream
typedef boost::int8_t Int8
typedef boost::uint8_t Uint8
typedef boost::int16_t Int16
typedef boost::uint16_t Uint16
typedef boost::int32_t Int32
typedef boost::uint32_t Uint32
typedef boost::int64_t Int64
typedef boost::uint64_t Uint64
typedef PRThreadPrivateDTOR KeyDestructor
typedef vpr::Uint32 thread_id_t
typedef boost::function< void()> thread_func_t
 Typedef to help with cross-platform abilities.
typedef RETSIGTYPE(* SignalHandler_t )(int)
typedef class InetAddrBSD InetAddr
typedef class IOSysUnix IOSys
typedef class Selector_t
< class SelectorImplBSD
Selector
typedef class SerialPort_t
< class SerialPortImplTermios
SerialPort
typedef boost::function
< size_t(const size_t, const
size_t)> 
NoPushAllocStrategy
 The type for strategies used to determine the amount of memory to allocate for the corking buffer.
typedef class ErrorImplPosix Error
typedef class SystemPosix System
typedef class CondVarPosix CondVar
typedef class MutexPosix Mutex
typedef class RWMutexPosix RWMutex
typedef class SemaphorePosix Semaphore
typedef int cancel_state_t
typedef class ThreadPosix Thread
typedef class ThreadKeyPosix KeyId

Functions

static const std::string PATH_SEP ("/")
static const std::string DSO_FILE_EXT (".so")
static std::string errorPrep (const std::string &who, const std::string &msg)
size_t minimalAllocationStrategy (const size_t curBufferSize, const size_t increaseAmt)
 Returns the sum of curBufferSize and increaseAmt thus indicating that only the minimum amount of memory should be allocated to fulfill the request.
size_t doublingAllocationStrategy (const size_t curBufferSize, const size_t increaseAmt)
 Returns the smaller of two possible sizes: doubling the current buffer size or doubling the sum of the current buffer size and the increase amount.
std::vector< vpr::InetAddrBOOSTgetIfAddrs (const bool withLoopback, const bool withDown)
 Retrieves all the IPv4 addresses associated with the local machine, including the loopback address (127.0.0.1) if so indicated.
void buildAndThrowException (const std::string &prefix, const std::string &location, int error_number=-2)
void NSPR_PrintError (const std::string &errorPrefixString, std::ostream &=std::cout)
 Prints the current NSPR error state to the given output stream.
PRIntervalTime NSPR_getInterval (const vpr::Interval &interval)
 Converts the given vpr::Interval object to an NSPR interval.
std::ostream & operator<< (std::ostream &out, ProfileIterator &iter)
std::ostream & operator<< (std::ostream &out, vpr::Thread *threadPtr)
void vprThreadFunctorFunction (void *arg)
 vprSingletonImpLifetime (ThreadManager, 100)
std::ostream & operator<< (std::ostream &outfile, vpr::OneThread &thread)
 vprSingletonImpLifetimeWithInitFunc (Debug, init, 50)
template<typename T , typename Destroyer >
void SetLongevity (T *pDynObject, unsigned int longevity, Destroyer d=detail::Deleter< T >::Delete)
template<class AbstractProduct , class ConcreteProduct >
AbstractProduct * CreateProduct ()
 Implements a useful little template function usable as a Creator in factory.
 VPR_IMPLEMENT (std::string) replaceEnvVars(const std
std::ostream & operator<< (std::ostream &s, const vpr::StreamLock &streamLock)
std::ostream & operator<< (std::ostream &s, const vpr::StreamUnLock &streamUnLock)
const char * VPR_VERSION (__VPR_VERSION_STRING__)
 VPR_IMPLEMENT (vpr::Uint32) getVersionNumber()
 VPR_DATA_API (const char *) VPR_VERSION
 This is the "human-readable" VPR version string.
 VPR_API (std::string) getVersionString()
 Retruns the "human-readable" VPR version string.
 VPR_API (vpr::Uint32) getVersionNumber()
 Returns the 9-digit VPR version integer.

Variables

static const vpr::Uint32 SOCK_MAX_BUFFER_SIZE = 65536
vpr::Mutex sStartSignalLock
vpr::Mutex sExitSignalLock
VPR_API(std::ostream
&) operator<<(std void 
vprThreadFunctorFunction (void *args)
 Ouput operator.
TSObjectProxy< std::vector< int > > gVprDebugCurColumn
TSObjectProxy< std::vector
< std::string > > 
gVprDebugCurColor
vpr::GUID::StdGUID null_guid_struct

Typedef Documentation

Definition at line 81 of file Library.h.

typedef boost::shared_ptr<Library> vpr::LibraryPtr

Definition at line 88 of file Library.h.

Definition at line 66 of file FileHandle.h.

Definition at line 63 of file Socket.h.

Definition at line 67 of file SocketDatagram.h.

Definition at line 66 of file SocketStream.h.

typedef PRInt8 vpr::Int8

Definition at line 43 of file vprTypesBOOST.h.

typedef PRUint8 vpr::Uint8

Definition at line 44 of file vprTypesBOOST.h.

typedef PRInt16 vpr::Int16

Definition at line 45 of file vprTypesBOOST.h.

typedef PRUint16 vpr::Uint16

Definition at line 46 of file vprTypesBOOST.h.

typedef PRInt32 vpr::Int32

Definition at line 47 of file vprTypesBOOST.h.

typedef PRUint32 vpr::Uint32

Definition at line 48 of file vprTypesBOOST.h.

typedef PRInt64 vpr::Int64

Definition at line 49 of file vprTypesBOOST.h.

typedef PRUint64 vpr::Uint64

Definition at line 50 of file vprTypesBOOST.h.

typedef void(* vpr::KeyDestructor)(void *)

Definition at line 55 of file ThreadKeyNSPR.h.

Definition at line 62 of file ThreadPosix.h.

typedef boost::function<void()> vpr::thread_func_t

Typedef to help with cross-platform abilities.

This type is the basic function pointer type for all functions initially passed as code to execute within a separate thread of control.

Definition at line 57 of file BaseThread.h.

typedef RETSIGTYPE(* vpr::SignalHandler_t)(int)

Definition at line 62 of file Signal.h.

typedef class InetAddrBSD vpr::InetAddr

Definition at line 141 of file vprDomain.h.

typedef class IOSysUnix vpr::IOSys

Definition at line 142 of file vprDomain.h.

typedef class Selector_t< class SelectorImplBSD > vpr::Selector

Definition at line 144 of file vprDomain.h.

Definition at line 145 of file vprDomain.h.

typedef boost::function<size_t (const size_t, const size_t)> vpr::NoPushAllocStrategy

The type for strategies used to determine the amount of memory to allocate for the corking buffer.

The first parameter is the current size of the corking buffer. The second is the necessary number of additional bytes. Upon initial allocation of the corking buffer (when vpr::SocketStream::cork() is invoked), the first value will be 0. The value returned is the number of bytes to (re)allocate for the corking buffer. If this value is less than or equal to the current buffer size, a vpr::Exception will be thrown by the code utilizing the allocation strategy.

See also:
vpr::SocketStream_t::setCorkAllocStrategy()
vpr::NoPushWriter
Since:
2.1.9

Definition at line 167 of file vprDomain.h.

typedef class ErrorImplPosix vpr::Error

Definition at line 200 of file vprDomain.h.

typedef class SystemPosix vpr::System

Definition at line 201 of file vprDomain.h.

typedef class CondVarPosix vpr::CondVar

Definition at line 205 of file vprDomain.h.

typedef class MutexPosix vpr::Mutex

Definition at line 206 of file vprDomain.h.

typedef class RWMutexPosix vpr::RWMutex

Definition at line 207 of file vprDomain.h.

Definition at line 208 of file vprDomain.h.

typedef int vpr::cancel_state_t

Definition at line 210 of file vprDomain.h.

typedef class ThreadPosix vpr::Thread

Definition at line 211 of file vprDomain.h.

typedef class ThreadKeyPosix vpr::KeyId

Definition at line 212 of file vprDomain.h.


Function Documentation

static const std::string vpr::PATH_SEP ( "/"   )  [static]
static const std::string vpr::DSO_FILE_EXT ( ".so"   )  [static]
static std::string vpr::errorPrep ( const std::string &  who,
const std::string &  msg 
) [static]

Definition at line 44 of file LoaderError.cpp.

{
   return who + ": " + msg;
}

size_t vpr::minimalAllocationStrategy ( const size_t  curBufferSize,
const size_t  increaseAmt 
) [inline]

Returns the sum of curBufferSize and increaseAmt thus indicating that only the minimum amount of memory should be allocated to fulfill the request.

See also:
vpr::NoPushWriter
vpr::StreamSocket
Since:
2.1.9

Definition at line 55 of file SimpleAllocationStrategies.h.

{
   return curBufferSize + increaseAmt;
}

size_t vpr::doublingAllocationStrategy ( const size_t  curBufferSize,
const size_t  increaseAmt 
) [inline]

Returns the smaller of two possible sizes: doubling the current buffer size or doubling the sum of the current buffer size and the increase amount.

Which of these is returned is determined by comparing the doubled current buffer size against the needed amount of space for the additional bytes. If doubling the current buffer size is sufficient, then that value is returned. Otherwise, the doubled sum of the current buffer size and the increase amount is returned.

Returns:
A value strictly larger than curBufferSize + increaseAmt.
Since:
2.1.9

Definition at line 74 of file SimpleAllocationStrategies.h.

{
   return (curBufferSize * 2 > curBufferSize + increaseAmt) ?
             curBufferSize * 2 : (curBufferSize + increaseAmt) * 2;
}

std::vector< vpr::InetAddrBSD > vpr::getIfAddrs ( const bool  withLoopback,
const bool  withDown 
)

Retrieves all the IPv4 addresses associated with the local machine, including the loopback address (127.0.0.1) if so indicated.

This is an internal function that is not part of the public VPR interface.

This function exists in this form primarily because NSPR does not provide any wrapper that offerrs this functionality. Since the WinSock2 use of WSAIoctl() so closely mimics the use of ioctl(2) to get the interface addresses, much code duplication would be required between vpr::InetAddrBSD and vpr::InetAddrNSPR. Instead of duplicating complicated code, those classes call into this function.

Parameters:
withLoopback A flag indicating whether to include the loopback address (127.0.0.1) in the returned collection.
withDown A flag indicating whether the address for interfaces in the down state should be included.
Note:
This method currently supports only IPv4.
Exceptions:
vpr::Exception is thrown if a fatal error occurs that prevents discovery of the local machine's addresses.
Returns:
A vector containing vpr::InetAddr objects holding all the local IPv4 addresses for the local machine.

Definition at line 94 of file InetAddrHelpers.cpp.

{
#if defined(VPR_OS_Windows)
   const unsigned long loop = ntohl(INADDR_LOOPBACK);
#else
   const in_addr_t loop = ntohl(INADDR_LOOPBACK);
#endif

   std::vector<vpr::InetAddr> host_addrs;

#if defined(HAVE_GETIFADDRS)
   ifaddrs* addrs(NULL);

   int result = getifaddrs(&addrs);

   if ( result < 0 )
   {
      std::ostringstream msg_stream;
      msg_stream << "Failed to query interface addresses: " << strerror(errno);
      throw vpr::Exception(msg_stream.str(), VPR_LOCATION);
   }
   else
   {
      for ( ifaddrs* a = addrs; a != NULL; a = a->ifa_next )
      {
         sockaddr_in* addr_in = (sockaddr_in*) a->ifa_addr;

         // We only handle IPv4 addresses.
         if ( addr_in->sin_family != AF_INET )
         {
            continue;
         }

         // If the inerface is down and the caller asked to exclude down
         // interfaces, skip this one.
         if ( (a->ifa_flags & IFF_UP) == 0 && ! withDown )
         {
            continue;
         }

         // If we have the loopback address and withLoopback is false, then we
         // skip this address.
         if ( addr_in->sin_addr.s_addr == loop && ! withLoopback )
         {
            continue;
         }

         char netaddr[18];
         const char* temp_addr = inet_ntop(addr_in->sin_family,
                                           &addr_in->sin_addr, netaddr,
                                           sizeof(netaddr));

         if ( NULL != temp_addr )
         {
            vpr::InetAddr vpr_addr;
            vpr_addr.setAddress(netaddr, 0);
            host_addrs.push_back(vpr_addr);
         }
      }
   }

   freeifaddrs(addrs);
#else   /* ! HAVE_GETIFADDRS */
   // While the implementation of this method is long and rather complex
   // looking, the idea is simple:
   //
   //    1. Create an IPv4 socket.
   //    2. Use ioctl(2) or WSAIoctl() on the socket handle to query all the
   //       network interfaces.
   //    3. Iterate over the returned interface request objects and extract
   //       the valid IPv4 addresses.
   //    4. Store each IPv4 address in a new vpr::InetAddr object.
#if defined(VPR_OS_Windows)
   typedef INTERFACE_INFO ifreq_t;

   SOCKET sock = WSASocket(AF_INET, SOCK_DGRAM, 0, 0, 0, 0);

   // Socket creation failed, so we cannot proceed.
   if ( sock == SOCKET_ERROR )
   {
      std::ostringstream msg_stream;
      msg_stream << "Socket creation failed (error code " << WSAGetLastError()
                 << ")";
      throw vpr::Exception(msg_stream.str(), VPR_LOCATION);
   }
#else
   typedef ifreq ifreq_t;

   int sock = socket(AF_INET, SOCK_DGRAM, 0);

   // Socket creation failed, so we cannot proceed.
   if ( sock < 0 )
   {
      std::ostringstream msg_stream;
      msg_stream << "Socket creation failed: " << strerror(errno);
      throw vpr::Exception(msg_stream.str(), VPR_LOCATION);
   }
#endif

   // Initial guess on the size of the buffer that will be returned by
   // ioctl(2) or WSAIoctl().
   unsigned int num_reqs(32);

   size_t lastlen(0);
   unsigned long bytes_returned(0);
#if ! defined(VPR_OS_Windows)
   ifconf ifc;
#endif
   ifreq_t* if_list(NULL);

   // Call ioctl(2) or WSAIoctl() iteratively to ensure that we get back all
   // the interface addresses. This is based on code from NSPR.
   for ( ; ; )
   {
      // Allocate storage for the data returned by ioctl(2) or WSAIoctl().
      if_list = new ifreq_t[num_reqs];

      if ( NULL == if_list )
      {
#if defined(VPR_OS_Windows)
         closesocket(sock);
#else
         close(sock);
#endif
         throw vpr::Exception("Out of memory", VPR_LOCATION);
      }

      const size_t len = sizeof(ifreq_t) * num_reqs;
#if defined(VPR_OS_Windows)
      int result = WSAIoctl(sock, SIO_GET_INTERFACE_LIST, NULL, 0, if_list,
                            len, &bytes_returned, NULL, NULL);
#else
      ifc.ifc_len = len;
      ifc.ifc_req = if_list;

      int result = ioctl(sock, SIOCGIFCONF, &ifc);
      bytes_returned = ifc.ifc_len;
#endif

      // Ask the kernel for all the network interfaces to which sock could be
      // bound.
#if defined(VPR_OS_Windows)
      if ( result == SOCKET_ERROR )
#else
      if ( result < 0 )
#endif
      {
#if defined(VPR_OS_Windows)
         const int inval_err(WSAEINVAL);
         const int err_code(WSAGetLastError());
#else
         const int inval_err(EINVAL);
         const int err_code(errno);
#endif

         // If ioctl(2) or WSAIoctl() failed for reasons other than our buffer
         // being too small, then we cannot continue. We need to clean up after
         // ourselves before we throw the exception explaining what went
         // wrong.
         if ( err_code != inval_err || lastlen != 0 )
         {
#if defined(VPR_OS_Windows)
            closesocket(sock);
#else
            close(sock);
#endif
            delete[] if_list;

            std::ostringstream msg_stream;
#if defined(VPR_OS_Windows)
            msg_stream << "Bad ioctl (error code " << err_code << ")";
#else
            msg_stream << "Bad ioctl: " << strerror(errno);
#endif
            throw vpr::Exception(msg_stream.str(), VPR_LOCATION);
         }
      }
      // If ioctl(2) or WSAIoctl() returned successfully, check the size of
      // the buffer that it returned.
      else
      {
         // If lastlen is the same as the size of the buffer returned by
         // ioctl(2) or WSAIoctl(), then we are done. If the size of the buffer
         // returned by ioctl(2) or WASIoctl() is no larger than what we
         // allocated, then we are done.
         if ( bytes_returned == lastlen || bytes_returned <= len )
         {
            break;
         }
         // Otherwise, we continue iterating.
         else
         {
            lastlen = bytes_returned;
         }
      }

      // Increment the size of the returned buffer by increasing the number of
      // allocated request structures.
      num_reqs += 10;
      delete[] if_list;
   }

   // We are done with the socket.
#if defined(VPR_OS_Windows)
   closesocket(sock);
#else
   close(sock);
#endif

   // Figure out how many interfaces were returned.
   const size_t num = bytes_returned / sizeof(ifreq_t);

   // Iterate over the returned ifreq objects and pull out the valid IPv4
   // addresses.
   for ( size_t i = 0; i < num; ++i )
   {
#if defined(VPR_OS_Windows)
      sockaddr_in* addr = (sockaddr_in*) &if_list[i].iiAddress;
#else
      sockaddr_in* addr = (sockaddr_in*) &ifc.ifc_req[i].ifr_addr;
#endif

      // Skip addresses that are not IPv4.
      // XXX: We should support IPv6 at some point.
      if ( addr->sin_family != AF_INET )
      {
         continue;
      }

#if defined(VPR_OS_Windows)
      const bool down = if_list[i].iiFlags & IFF_UP == 0;
#else
      // XXX: This call may cause problems. It may not work on Linux.
      const bool down = ifc.ifc_req[i].ifr_flags & IFF_UP == 0;
#endif

      // If the inerface is down and the caller asked to exclude down
      // interfaces, skip this one.
      if ( down && ! withDown )
      {
         continue;
      }

      // If we have the loopback address and withLoopback is false, then we
      // skip this address.
      if ( addr->sin_addr.s_addr == loop && ! withLoopback )
      {
         continue;
      }

      std::ostringstream addr_stream;

#if defined(VPR_OS_Windows)
      // inet_ntoa() returns a pointer to static memory, which means that
      // it is not reentrant. Unfortunately, WinSock2 does not provide
      // inet_ntop(). The memory returned is guaranteed to be valid until
      // the next socket call in this thread, so there should not be a
      // race condition here.
      const char* temp_addr = inet_ntoa(addr->sin_addr);

      if ( NULL != temp_addr )
      {
         addr_stream << temp_addr;
      }
#else
      char netaddr[18];
      const char* temp_addr = inet_ntop(addr->sin_family, &addr->sin_addr,
                                        netaddr, sizeof(netaddr));

      if ( NULL != temp_addr )
      {
         addr_stream << netaddr;
      }
#endif

      if ( ! addr_stream.str().empty() )
      {
         vpr::InetAddr vpr_addr;
         vpr_addr.setAddress(addr_stream.str(), 0);
         host_addrs.push_back(vpr_addr);
      }
   }

   // All done.
   delete[] if_list;
#endif  /* defined(HAVE_GETIFADDRS) */

   return host_addrs;
}

void vpr::buildAndThrowException ( const std::string &  prefix,
const std::string &  location,
int  error_number = -2 
)

Build error string.

Definition at line 77 of file SocketImplBOOST.cpp.

{
   if ( -2 == error_number )
   {
      error_number = errno;
   }

   const char* err_str(strerror(error_number));
   std::string err_string;

   if ( NULL != err_str )
   {
      err_string = std::string(err_str);
   }

   // Build and throw exception
   if ( ECONNREFUSED == error_number )
   {
      std::ostringstream msg_stream;
      msg_stream << prefix << "Connection refused: " << err_string;
      throw vpr::ConnectionRefusedException(msg_stream.str(), location);
   }
   else if ( ECONNRESET == error_number )
   {
      std::ostringstream msg_stream;
      msg_stream << prefix << "Connection reset: " << err_string;
      throw vpr::ConnectionResetException(msg_stream.str(), location);
   }
   else if ( EHOSTUNREACH == error_number )
   {
      std::ostringstream msg_stream;
      msg_stream << prefix << "No route to hose: " << err_string;
      throw vpr::NoRouteToHostException(msg_stream.str(), location);
   }
   else if ( ENETDOWN == error_number )
   {
      std::ostringstream msg_stream;
      msg_stream << prefix << "Network is down: " << err_string;
      throw vpr::SocketException(msg_stream.str(), location);
   }
   else
   {
      std::ostringstream msg_stream;
      msg_stream << prefix << "Error: " << err_string;
      throw vpr::SocketException(msg_stream.str(), location);
   }
}

void vpr::NSPR_PrintError ( const std::string &  errorPrefixString,
std::ostream &  = std::cout 
)

Prints the current NSPR error state to the given output stream.

PRIntervalTime vpr::NSPR_getInterval ( const vpr::Interval interval  )  [inline]

Converts the given vpr::Interval object to an NSPR interval.

Definition at line 55 of file NSPRHelpers.h.

{
   if(interval == vpr::Interval::NoTimeout)
   {
      return PR_INTERVAL_NO_TIMEOUT;
   }
   else if(interval == vpr::Interval::NoWait)
   {
      return PR_INTERVAL_NO_WAIT;
   }
   else
   {
      PRUint32 usec;
      LL_L2UI(usec, interval.usec());
      return PR_MicrosecondsToInterval(usec);
   }
}

std::ostream& vpr::operator<< ( std::ostream &  out,
ProfileIterator &  iter 
)

Definition at line 102 of file ProfileIterator.cpp.

   {
      while ( iter != ProfileIterator(NULL))
      {
         out << (*iter).getName() << " total calls: " << (*iter).getTotalCalls()
             << " total time: " << (*iter).getTotalTime().msecf()
             << " avg: " << (*iter).getAverage().msecf()
             << " history: ";

         ProfileNode::NodeHistoryRange p = (*iter).getNodeHistoryRange();
         for ( ; p.first != p.second; p.first++ )
         {
            out << p.first->msecf() << " ";
         }

         out << std::endl;
         ++iter;
      }

      return out;
   }

std::ostream& vpr::operator<< ( std::ostream &  out,
vpr::Thread threadPtr 
)

Definition at line 94 of file BaseThread.cpp.

{
   if (threadPtr != NULL)
   {
      threadPtr->outStream(out);
   }
   else
   {
      out << " TID: N/A  ";
   }

   return out;
}

void vpr::vprThreadFunctorFunction ( void *  arg  ) 

Definition at line 155 of file BaseThread.cpp.

{
   vpr::thread_func_t& func = *((vpr::thread_func_t*) arg);
   vprASSERT(! func.empty());
   func();
}

vpr::vprSingletonImpLifetime ( ThreadManager  ,
100   
)
std::ostream& vpr::operator<< ( std::ostream &  outfile,
vpr::OneThread thread 
)

Definition at line 234 of file ThreadPool.cpp.

{
   outfile << thread.thread;
   return outfile;
}

vpr::vprSingletonImpLifetimeWithInitFunc ( Debug  ,
init  ,
50   
)
template<typename T , typename Destroyer >
void vpr::SetLongevity ( T *  pDynObject,
unsigned int  longevity,
Destroyer  d = detail::Deleter<T>::Delete 
)

Definition at line 131 of file LifetimeTracker.h.

    {
        using namespace detail;
        
        TrackerArray pNewArray = static_cast<TrackerArray>(
                std::realloc(pTrackerArray, 
                    sizeof(*pTrackerArray) * (elements + 1)));
        if (!pNewArray) throw std::bad_alloc();
        
        // Delayed assignment for exception safety
        pTrackerArray = pNewArray;
        
        LifetimeTracker* p = new ConcreteLifetimeTracker<T, Destroyer>(
            pDynObject, longevity, d);
        
        // Insert a pointer to the object into the queue
        TrackerArray pos = std::upper_bound(
            pTrackerArray, 
            pTrackerArray + elements, 
            p, 
            LifetimeTracker::Compare);
        std::copy_backward(
            pos, 
            pTrackerArray + elements,
            pTrackerArray + elements + 1);
        *pos = p;
        ++elements;
        
        // Register a call to AtExitFn
        std::atexit(detail::AtExitFn);
    }

template<class AbstractProduct , class ConcreteProduct >
AbstractProduct* vpr::CreateProduct (  ) 

Implements a useful little template function usable as a Creator in factory.

Definition at line 63 of file Factory.h.

{
   return (new ConcreteProduct);
}

vpr::VPR_IMPLEMENT ( std::string   )  const

Definition at line 57 of file Version.cpp.

{
   std::string subsystem_string;

#if defined(VPR_USE_NSPR)
   subsystem_string = std::string("NSPR");
#elif defined(VPR_USE_PTHREADS)
   subsystem_string = std::string("POSIX");
#endif

   return subsystem_string;
}

std::ostream& vpr::operator<< ( std::ostream &  s,
const vpr::StreamLock streamLock 
)

Definition at line 41 of file StreamLock.cpp.

{
   streamLock.mMutex.acquire();
   
   return s;
}

std::ostream& vpr::operator<< ( std::ostream &  s,
const vpr::StreamUnLock streamUnLock 
)

Definition at line 49 of file StreamLock.cpp.

{
   streamUnLock.mMutex.release();
   
   return s;
}

const char* vpr::VPR_VERSION ( __VPR_VERSION_STRING__   ) 
vpr::VPR_IMPLEMENT ( vpr::Uint32   ) 

Definition at line 52 of file Version.cpp.

{
   return __VPR_version;
}

vpr::VPR_DATA_API ( const char *   ) 

This is the "human-readable" VPR version string.

The full form includes the version number (major.minor.patch-build), the canonical name of the release, the threading subsystem, and the build date. The major version number is updated when major architectural changes are made; the minor when there are minor API changes; and the patch when there are bug fixes. The build number is usually representative of the nightly build process relative to a given version x.y.z.

See also:
vpr::getVersionString()
vpr::VPR_API ( std::string   ) 

Retruns the "human-readable" VPR version string.

Returns the name of the threading subsystem used to compile VPR.

The full form includes the version number (major.minor.patch-build), the canonical name of the release, the threading subsystem, and the build date. The major version number is updated when major architectural changes are made; the minor when there are minor API changes; and the patch when there are bug fixes. The build number is usually representative of the nightly build process relative to a given version x.y.z.

See also:
vpr::VPR_VERSION

It will be one of "POSIX" or "NSPR". This identifier is part of the full version string returned by vpr::getVersionString().

See also:
vpr::getVersionString()
vpr::VPR_API ( vpr::Uint32   ) 

Returns the 9-digit VPR version integer.

This form provides three digits for each of the major, minor, and patch numbers with no leading zeros.

Note:
The number returned is the value at run time. For a compile-time version identifier, use __VPR_version. The value is the same as what is returned by this function.

Variable Documentation

const vpr::Uint32 vpr::SOCK_MAX_BUFFER_SIZE = 65536 [static]

Definition at line 52 of file SocketImplSIM.cpp.

Definition at line 51 of file BaseThread.cpp.

Definition at line 52 of file BaseThread.cpp.

VPR_API (std::ostream&) operator<<(std void vpr::vprThreadFunctorFunction(void *args)

Ouput operator.

Definition at line 287 of file BaseThread.h.

Definition at line 65 of file Debug.cpp.

TSObjectProxy<std::vector<std::string> > vpr::gVprDebugCurColor

Definition at line 66 of file Debug.cpp.

Initial value:
 { 0x00000000, 0x0000, 0x0000, 0x00, 0x00,
   { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
}

Definition at line 84 of file GUID.cpp.