JayBeams  0.1
Another project to have fun coding.
Namespaces | Classes | Typedefs | Enumerations | Functions
jb Namespace Reference

The top-level namespace for the JayBeams library. More...

Namespaces

 clfft
 Wrappers for the clFFT library.
 
 defaults
 Default values for configuration parameters.
 
 detail
 
 ehs
 Contains types and classes to implemented Embedded HTTP Servers.
 
 examples
 Contains types and functions useful in the examples.
 
 fftw
 Wrappers for the FFTW3 library.
 
 gmock
 
 itch5
 Contains classes and functions to parse NASDAQ ITCH-5.0 messages, more information about ITCH-5.0 can be found at: http://www.nasdaqtrader.com/content/technicalsupport/specifications/dataproducts/NQTVITCHSpecification.pdf.
 
 log
 Logging functions and objects for JayBeams.
 
 mktdata
 
 opencl
 Wrappers for the OpenCL library.
 
 pitch2
 
 tde
 
 testing
 Helper functions and classes to simplify unit tests.
 
 yaml
 

Classes

struct  as_hh_mm_ss_u
 Helper class to print time durations in HH:MM:SS.UUUUUU format. More...
 
struct  as_hhmmss
 Helper class to print time durations s in HHMMSS format. More...
 
struct  as_hhmmssu
 Helper class to print time durations in a HHMMSS.UUUUUU format. More...
 
class  binning_strategy_concept
 The interface that must be met by the binning_strategy in jb::histogram. More...
 
class  book_depth_statistics
 Keep statistics about a feed and its book depth. More...
 
class  config_attribute
 Helper class to easily define configuration attributes. More...
 
class  config_files_locations
 Compute the directories where a configuration file can be found. More...
 
class  config_files_locations_base
 Define the configuration file search algorithm for JayBeams. More...
 
class  config_object
 Base class for all configuration objects. More...
 
struct  config_recurse
 Recursively apply functions to config_object, attributes, and sequences of config objects. More...
 
class  cpu_set
 A wrapper for the Linux CPU_SET data structure. More...
 
struct  default_getenv
 Define the functor to read configuration variables from the environment. More...
 
struct  default_validator
 Define the functor to validate if paths are readable. More...
 
class  event_rate_estimator
 Estimate event rates over a trailing measurement period. More...
 
class  event_rate_histogram
 Keep a histogram of observed event rates. More...
 
class  explicit_cuts_binning
 A histogram binning_strategy for integer numbers with user defined cuts. More...
 
struct  extract_value_type
 Generic function to extract the floating point type of std::complex. More...
 
struct  extract_value_type< std::complex< T > >
 Partial specialization of jb::extract_value_type for std::complex. More...
 
class  feed_error
 Communicate feed error exceptions. More...
 
class  fixed_string
 A helper type to define short (and fixed sized) string fields. More...
 
class  histogram
 A histogram class with controllable binning and range strategy. More...
 
struct  histogram_summary
 A simple class to capture summary information about a histogram. More...
 
class  integer_range_binning
 A histogram binning_strategy for integer numbers in a known range. More...
 
class  offline_feed_statistics
 Keep statistics about a feed and its offline processor. More...
 
struct  stn_traits
 Traits to convert strings to numbers (e.g. More...
 
class  thread_config
 Hold the configuration to initialize threads. More...
 
class  usage
 A simple class to communicate the result of parsing the options. More...
 

Typedefs

typedef unsigned long int book_depth_t
 
typedef std::map< std::string, YAML::Node > class_overrides
 Store the overrides for each class. More...
 

Enumerations

enum  severity_level {
  severity_level::trace, severity_level::debug, severity_level::info, severity_level::notice,
  severity_level::warning, severity_level::error, severity_level::critical, severity_level::alert,
  severity_level::fatal
}
 Severity levels for JayBeams, based on syslog. More...
 

Functions

std::ostream & operator<< (std::ostream &os, as_hhmmssu const &x)
 Format as_hhmmssu into an iostream. More...
 
std::ostream & operator<< (std::ostream &os, as_hhmmss const &x)
 Format as_hhmmss into an iostream. More...
 
std::ostream & operator<< (std::ostream &os, as_hh_mm_ss_u const &x)
 Format as_hh_mm_ss_u into an iostream. More...
 
void raise_assertion_failure (char const *filename, int lineno, char const *predicate)
 Raise std::exception to indicate an assertion failure. More...
 
char const * sysconfdir ()
 Return the system configuration directory. More...
 
char const * bindir ()
 Return the binary installation directory directory. More...
 
std::ostream & operator<< (std::ostream &os, config_object const &x)
 
std::ostream & operator<< (std::ostream &, cpu_set const &)
 Stream a cpu set in list format. More...
 
std::istream & operator>> (std::istream &, cpu_set &)
 Read a cpu set in list format. More...
 
cpu_set operator & (cpu_set const &lhs, cpu_set const &rhs)
 Bitwise AND operator for cpu sets. More...
 
cpu_set operator| (cpu_set const &lhs, cpu_set const &rhs)
 Bitwise OR operator for cpu sets. More...
 
cpu_set operator^ (cpu_set const &lhs, cpu_set const &rhs)
 Bitwise XOR operator for cpu sets. More...
 
void open_output_file (boost::iostreams::filtering_ostream &out, std::string const &filename)
 Open a file for writing. More...
 
void open_input_file (boost::iostreams::filtering_istream &in, std::string const &filename)
 Open a file for reading. More...
 
bool is_gz (std::string const &filename)
 Return true if the filename ends in .gz. More...
 
template<std::size_t size>
std::ostream & operator<< (std::ostream &os, fixed_string< size > const &x)
 Streaming operator for jb::mktdata::fixed_string<> More...
 
template<std::size_t size>
std::size_t hash_value (fixed_string< size > const &x)
 Implement a hash function and integrate with boost::hash. More...
 
template<typename sample_type >
sample_type histogram_binning_linear_interpolation (sample_type x_a, sample_type x_b, double y_a, double s, double q)
 Convenience function to implement the binning_strategy_concept. More...
 
std::ostream & operator<< (std::ostream &os, histogram_summary const &x)
 
template<typename Function , typename... A>
void launch_thread (std::thread &t, thread_config const &config, Function &&f, A &&... a)
 Create a new thread, configure it as desired, and then call a user-defined function. More...
 
constexpr bool severity_static_predicate (jb::severity_level lvl)
 Statically check if the severity level should even be compiled in. More...
 
template<typename T >
constexpr T p2ceil_kernel (int shift, T n)
 Implement the key operation in the p2ceil() function. More...
 
constexpr std::uint64_t p2ceil (std::uint64_t n)
 Find the smallest power of 2 larger than n for a 64-bit integer. More...
 
constexpr std::uint32_t p2ceil (std::uint32_t n)
 Find the smallest power of 2 larger than n for a 32-bit integer. More...
 
constexpr std::uint16_t p2ceil (std::uint16_t n)
 Find the smallest power of 2 larger than n for a 16-bit integer. More...
 
constexpr std::uint8_t p2ceil (std::uint8_t n)
 Find the smallest power of 2 larger than n for an 8-bit integer. More...
 
std::ostream & operator<< (std::ostream &os, severity_level const &x)
 Streaming for severity levels. More...
 
std::istream & operator>> (std::istream &is, severity_level &x)
 
void parse (severity_level &lhs, std::string const &rhs)
 Parse a severity level. More...
 
char const * get_name (severity_level const &rhs)
 Get the name of a security level. More...
 
int severity_level_width ()
 Return the recommended with for printing security levels. More...
 
 STN_TRAITS (int, std::stoi)
 
 STN_TRAITS (unsigned long long, std::stoull)
 
 STN_TRAITS (long long, std::stoll)
 
 STN_TRAITS (unsigned long, std::stoul)
 
 STN_TRAITS (long, std::stol)
 
 STN_TRAITS (float, std::stof)
 
 STN_TRAITS (double, std::stod)
 
template<typename T >
bool strtonum (std::string const &s, T &r)
 Generic string to number conversion with validation. More...
 

Detailed Description

The top-level namespace for the JayBeams library.


Class Documentation

◆ jb::extract_value_type

struct jb::extract_value_type

template<typename T>
struct jb::extract_value_type< T >

Generic function to extract the floating point type of std::complex.

Some of the algorithms and data structures in JayBeams need to work for both std::complex<> and for primitive floating point values such as 'float'. These functions sometimes need a generic way to extract the 'T' parameter in a std::complex<T>. This function can be used to perform such conversions, for example:

template<typename sample_t> class Foo {
typedef typename jb::extra_value_type<sample_t>::precision prec;
prec epsilon = std::numeric_limits<prec>::epsilon();
};

Such code would work whether sample_t is a std::complex<T> or a primitive floating point value.

Definition at line 28 of file complex_traits.hpp.

Class Members
typedef T precision

◆ jb::extract_value_type< std::complex< T > >

struct jb::extract_value_type< std::complex< T > >

template<typename T>
struct jb::extract_value_type< std::complex< T > >

Partial specialization of jb::extract_value_type for std::complex.

Definition at line 34 of file complex_traits.hpp.

Class Members
typedef T precision

◆ jb::histogram_summary

struct jb::histogram_summary

A simple class to capture summary information about a histogram.

Definition at line 9 of file histogram_summary.hpp.

Class Members
double max
double min
size_t nsamples
double p25
double p50
double p75
double p90
double p99

◆ jb::stn_traits

struct jb::stn_traits

template<typename T>
struct jb::stn_traits< T >

Traits to convert strings to numbers (e.g.

integers, floats, etc).

For most types this refactors repetitive code, but also allows specialization for specific types.

Definition at line 16 of file strtonum.hpp.

Typedef Documentation

◆ book_depth_t

typedef unsigned long int jb::book_depth_t

Definition at line 12 of file book_depth_statistics.hpp.

◆ class_overrides

typedef std::map<std::string, YAML::Node> jb::class_overrides

Store the overrides for each class.

Jaybeams configuration objects can be overriden "by-class", meaning, all configs of the same class receive the same overrides. This type is used to (temporarily) store the by-class overrides in a given context.

Definition at line 17 of file merge_yaml.hpp.

Enumeration Type Documentation

◆ severity_level

enum jb::severity_level
strong

Severity levels for JayBeams, based on syslog.

Enumerator
trace 
debug 
info 
notice 
warning 
error 
critical 
alert 
fatal 

Definition at line 10 of file severity_level.hpp.

Function Documentation

◆ bindir()

char const * jb::bindir ( )

Return the binary installation directory directory.

Typically this is something like /usr/bin or /usr/local/bin but it can change depending on how JayBeams was configured and the target platform.

Definition at line 82 of file config_files_location.cpp.

References JB_DEFAULT_BINDIR.

Referenced by BOOST_AUTO_TEST_CASE(), jb::config_files_locations_base::config_files_locations_base(), and jb::config_files_locations< getenv_functor, validator_functor >::find_configuration_file().

◆ get_name()

char const * jb::get_name ( severity_level const &  rhs)

Get the name of a security level.

Definition at line 58 of file severity_level.cpp.

Referenced by BOOST_AUTO_TEST_CASE(), and YAML::convert< jb::severity_level >::encode().

◆ hash_value()

template<std::size_t size>
std::size_t jb::hash_value ( fixed_string< size > const &  x)

Implement a hash function and integrate with boost::hash.

Definition at line 110 of file fixed_string.hpp.

References jb::fixed_string< wire_size_value >::str().

◆ histogram_binning_linear_interpolation()

template<typename sample_type >
sample_type jb::histogram_binning_linear_interpolation ( sample_type  x_a,
sample_type  x_b,
double  y_a,
double  s,
double  q 
)
inline

Convenience function to implement the binning_strategy_concept.

The histogram class requires the binning strategy to solve the follow equation for \(x\):

\[ {{(x - x_a)} \over {(y - y_a)}} = {{(x_b - x_a)} \over {s}} \]

this is used in the computation of percentiles to better approximate the percentile value between different cuts. Some binning strategies might provide a non-linear interpolation, but in practice this (linear) solution is used in most cases.

Definition at line 24 of file histogram_binning_linear_interpolation.hpp.

Referenced by jb::integer_range_binning< std::int64_t >::interpolate(), and jb::explicit_cuts_binning< sample_type_t >::interpolate().

◆ is_gz()

bool jb::is_gz ( std::string const &  filename)

Return true if the filename ends in .gz.

Definition at line 3 of file filetype.cpp.

Referenced by BOOST_AUTO_TEST_CASE(), open_input_file(), and open_output_file().

◆ launch_thread()

template<typename Function , typename... A>
void jb::launch_thread ( std::thread &  t,
thread_config const &  config,
Function &&  f,
A &&...  a 
)

Create a new thread, configure it as desired, and then call a user-defined function.

Definition at line 15 of file launch_thread.hpp.

References jb::detail::make_thread_setup_wrapper().

Referenced by BOOST_AUTO_TEST_CASE(), and main().

◆ open_input_file()

void jb::open_input_file ( boost::iostreams::filtering_istream &  in,
std::string const &  filename 
)

Open a file for reading.

Definition at line 27 of file fileio.cpp.

References is_gz().

Referenced by check_read_write(), main(), and run_inside().

◆ open_output_file()

void jb::open_output_file ( boost::iostreams::filtering_ostream &  out,
std::string const &  filename 
)

Open a file for writing.

Definition at line 12 of file fileio.cpp.

References is_gz().

Referenced by BOOST_AUTO_TEST_CASE(), check_read_write(), main(), and run_inside().

◆ operator &()

cpu_set jb::operator& ( cpu_set const &  lhs,
cpu_set const &  rhs 
)
inline

Bitwise AND operator for cpu sets.

Definition at line 166 of file cpu_set.hpp.

◆ operator<<() [1/8]

std::ostream & jb::operator<< ( std::ostream &  os,
histogram_summary const &  x 
)

◆ operator<<() [2/8]

std::ostream & jb::operator<< ( std::ostream &  os,
severity_level const &  x 
)

Streaming for severity levels.

Definition at line 27 of file severity_level.cpp.

◆ operator<<() [3/8]

std::ostream & jb::operator<< ( std::ostream &  os,
jb::as_hhmmssu const &  x 
)

Format as_hhmmssu into an iostream.

Definition at line 8 of file as_hhmmss.cpp.

References jb::as_hhmmssu::t.

Referenced by BOOST_AUTO_TEST_CASE().

◆ operator<<() [4/8]

std::ostream & jb::operator<< ( std::ostream &  os,
jb::as_hhmmss const &  x 
)

Format as_hhmmss into an iostream.

Definition at line 15 of file as_hhmmss.cpp.

References jb::as_hhmmss::t.

◆ operator<<() [5/8]

std::ostream & jb::operator<< ( std::ostream &  os,
jb::as_hh_mm_ss_u const &  x 
)

Format as_hh_mm_ss_u into an iostream.

Definition at line 28 of file as_hhmmss.cpp.

References jb::as_hh_mm_ss_u::t.

◆ operator<<() [6/8]

template<std::size_t size>
std::ostream& jb::operator<< ( std::ostream &  os,
fixed_string< size > const &  x 
)

Streaming operator for jb::mktdata::fixed_string<>

Definition at line 104 of file fixed_string.hpp.

◆ operator<<() [7/8]

std::ostream & jb::operator<< ( std::ostream &  os,
jb::cpu_set const &  rhs 
)

Stream a cpu set in list format.

Definition at line 100 of file cpu_set.cpp.

References jb::cpu_set::as_list_format().

◆ operator<<() [8/8]

std::ostream& jb::operator<< ( std::ostream &  os,
config_object const &  x 
)
inline

Definition at line 312 of file config_object.hpp.

References jb::config_object::to_stream().

◆ operator>>() [1/2]

std::istream & jb::operator>> ( std::istream &  is,
severity_level x 
)

Definition at line 37 of file severity_level.cpp.

References parse().

◆ operator>>() [2/2]

std::istream & jb::operator>> ( std::istream &  is,
jb::cpu_set rhs 
)

Read a cpu set in list format.

Definition at line 104 of file cpu_set.cpp.

References jb::cpu_set::parse().

◆ operator^()

cpu_set jb::operator^ ( cpu_set const &  lhs,
cpu_set const &  rhs 
)
inline

Bitwise XOR operator for cpu sets.

Definition at line 180 of file cpu_set.hpp.

◆ operator|()

cpu_set jb::operator| ( cpu_set const &  lhs,
cpu_set const &  rhs 
)
inline

Bitwise OR operator for cpu sets.

Definition at line 173 of file cpu_set.hpp.

◆ p2ceil() [1/4]

constexpr std::uint64_t jb::p2ceil ( std::uint64_t  n)

Find the smallest power of 2 larger than n for a 64-bit integer.

The algorithm can be executed at compile time, so it is suitable for use in template expressions. The algorithm first computes all the

Parameters
nthe input number, must be smaller or equal to 2^63.
Returns
the smallest power of two larger than n.

Definition at line 34 of file p2ceil.hpp.

References p2ceil_kernel().

Referenced by BOOST_AUTO_TEST_CASE(), and jb::opencl::generic_reduce< reducer, input_type_t, output_type_t >::execute().

◆ p2ceil() [2/4]

constexpr std::uint32_t jb::p2ceil ( std::uint32_t  n)

Find the smallest power of 2 larger than n for a 32-bit integer.

Parameters
nthe input number, must be smaller or equal to 2^31.
Returns
the smallest power of two larger than n.

Definition at line 66 of file p2ceil.hpp.

References p2ceil_kernel().

◆ p2ceil() [3/4]

constexpr std::uint16_t jb::p2ceil ( std::uint16_t  n)

Find the smallest power of 2 larger than n for a 16-bit integer.

Parameters
nthe input number, must be smaller or equal to 2^15.
Returns
the smallest power of two larger than n.

Definition at line 80 of file p2ceil.hpp.

References p2ceil_kernel().

◆ p2ceil() [4/4]

constexpr std::uint8_t jb::p2ceil ( std::uint8_t  n)

Find the smallest power of 2 larger than n for an 8-bit integer.

Parameters
nthe input number, must be smaller or equal to 2^7.
Returns
the smallest power of two larger than n.

Definition at line 91 of file p2ceil.hpp.

References p2ceil_kernel().

◆ p2ceil_kernel()

template<typename T >
constexpr T jb::p2ceil_kernel ( int  shift,
n 
)

Implement the key operation in the p2ceil() function.

The p2ceil() functions are implemented as a series of recursive calls to this function.

Template Parameters
Tthe type of the input, must be an integer type.

Definition at line 18 of file p2ceil.hpp.

Referenced by p2ceil().

◆ parse()

void jb::parse ( severity_level lhs,
std::string const &  rhs 
)

Parse a severity level.

Definition at line 44 of file severity_level.cpp.

Referenced by YAML::convert< jb::severity_level >::decode(), and operator>>().

◆ raise_assertion_failure()

void jb::raise_assertion_failure ( char const *  filename,
int  lineno,
char const *  predicate 
)

Raise std::exception to indicate an assertion failure.

Definition at line 6 of file assert_throw.cpp.

◆ severity_level_width()

int jb::severity_level_width ( )

Return the recommended with for printing security levels.

Definition at line 69 of file severity_level.cpp.

Referenced by jb::log::format_common().

◆ severity_static_predicate()

constexpr bool jb::severity_static_predicate ( jb::severity_level  lvl)

Statically check if the severity level should even be compiled in.

Definition at line 19 of file log.hpp.

References JB_MIN_LOG_LEVEL.

◆ STN_TRAITS() [1/7]

jb::STN_TRAITS ( int  ,
std::stoi   
)

◆ STN_TRAITS() [2/7]

jb::STN_TRAITS ( unsigned long  long,
std::stoull   
)

◆ STN_TRAITS() [3/7]

jb::STN_TRAITS ( long  long,
std::stoll   
)

◆ STN_TRAITS() [4/7]

jb::STN_TRAITS ( unsigned  long,
std::stoul   
)

◆ STN_TRAITS() [5/7]

jb::STN_TRAITS ( long  ,
std::stol   
)

◆ STN_TRAITS() [6/7]

jb::STN_TRAITS ( float  ,
std::stof   
)

◆ STN_TRAITS() [7/7]

jb::STN_TRAITS ( double  ,
std::stod   
)

◆ strtonum()

template<typename T >
bool jb::strtonum ( std::string const &  s,
T &  r 
)

Generic string to number conversion with validation.

Definition at line 40 of file strtonum.hpp.

Referenced by BOOST_AUTO_TEST_CASE(), jb::thread_config::native_priority(), thread_config::native_priority(), jb::cpu_set::parse(), and jb::itch5::detail::setup_socket_udp_send().

◆ sysconfdir()

char const * jb::sysconfdir ( )

Return the system configuration directory.

Typically this is something like /etc or /usr/local/etc but it can change depending on how JayBeams was configured and the target platform.

Definition at line 74 of file config_files_location.cpp.

References JB_DEFAULT_SYSCONFDIR.

Referenced by BOOST_AUTO_TEST_CASE(), jb::config_files_locations_base::config_files_locations_base(), and jb::config_files_locations< getenv_functor, validator_functor >::find_configuration_file().