vg
tools for working with variation graphs
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
vg::Explainer Class Reference

#include <explainer.hpp>

Inheritance diagram for vg::Explainer:
vg::DiagramExplainer vg::DotDumpExplainer< T > vg::ProblemDumpExplainer vg::SubgraphExplainer vg::TSVExplainer

Public Member Functions

 Explainer (bool enabled)
 Construct an Explainer that will save to one or more files. More...
 
virtual ~Explainer ()
 Close out the files being explained to. More...
 
 operator bool () const
 

Static Public Member Functions

static void set_context (const std::string &context)
 
static void clear_context ()
 Clear the current per-thread context. More...
 

Static Public Attributes

static bool save_explanations = false
 

Protected Member Functions

bool explaining () const
 Function to check if we should be explaining. More...
 

Static Protected Member Functions

static size_t get_new_explanation_number ()
 
static std::string make_filename (const std::string &base_name, const std::string &extension)
 

Protected Attributes

size_t explanation_number
 What number explanation are we? Distinguishes different objects. More...
 
bool enabled
 Determines if this explainer should generate explanations. More...
 

Static Protected Attributes

static std::atomic< size_t > next_explanation_number {0}
 Counter used to give different explanations their own unique filenames. More...
 
static thread_local size_t next_context_explanation_number {0}
 
static thread_local std::string current_context = ""
 Current thing (possibly a read name) being explained (for organizing into directories) More...
 

Detailed Description

Base explainer class. Handles making sure each explanation has a different unique number. Also provides support for organizing explanations into per-read directories.

Constructor & Destructor Documentation

◆ Explainer()

vg::Explainer::Explainer ( bool  enabled)

Construct an Explainer that will save to one or more files.

◆ ~Explainer()

vg::Explainer::~Explainer ( )
virtual

Close out the files being explained to.

Member Function Documentation

◆ clear_context()

void vg::Explainer::clear_context ( )
static

Clear the current per-thread context.

◆ explaining()

bool vg::Explainer::explaining ( ) const
inlineprotected

Function to check if we should be explaining.

◆ get_new_explanation_number()

size_t vg::Explainer::get_new_explanation_number ( )
staticprotected

Helper to get a new explanation number, either from the global counter, or within a thread-local context.

◆ make_filename()

std::string vg::Explainer::make_filename ( const std::string &  base_name,
const std::string &  extension 
)
staticprotected

Helper to create a filename accounting for any assigned per-thread context.

If current_context is set, ensures there is a directory for that context, and puts the file there.

Returns the full path to use for opening the file.

◆ operator bool()

vg::Explainer::operator bool ( ) const
inline

Conversion to bool so you can use an explainer as a condition on code to write to it.

◆ set_context()

void vg::Explainer::set_context ( const std::string &  context)
static

Set a per-thread context for organizing explanations. Within a context, explanations are numbed from 0 (so contexts may not be re-used, or collisions will occur). The context may not be empty.

Member Data Documentation

◆ current_context

thread_local std::string vg::Explainer::current_context = ""
staticprotected

Current thing (possibly a read name) being explained (for organizing into directories)

◆ enabled

bool vg::Explainer::enabled
protected

Determines if this explainer should generate explanations.

◆ explanation_number

size_t vg::Explainer::explanation_number
protected

What number explanation are we? Distinguishes different objects.

◆ next_context_explanation_number

thread_local size_t vg::Explainer::next_context_explanation_number {0}
staticprotected

Counter used to give different explanations their own unique filenames within a per-thread context.

◆ next_explanation_number

std::atomic< size_t > vg::Explainer::next_explanation_number {0}
staticprotected

Counter used to give different explanations their own unique filenames.

◆ save_explanations

bool vg::Explainer::save_explanations = false
static

Determine if explanations should be generated.

Should be set once at the start of the program; should not be toggled while explanations are being saved or other system state (like contexts) are being used.


The documentation for this class was generated from the following files: