Rosetta Utilities  2014.35
Namespaces | Macros | Typedefs | Functions
exit.hh File Reference

Program exit functions and macros. More...

#include <string>

Namespaces

 utility
 unresizable vector whose size is known at compile time, which may be allocated on the stack, and which indexes from 1.
 

Macros

#define utility_exit()   utility::exit( __FILE__, __LINE__ )
 Macro function wrappers for utility::exit. More...
 
#define utility_exit_with_message(m)   utility::exit( __FILE__, __LINE__, m )
 Exit with file + line + message. More...
 
#define utility_exit_with_status(s)   utility::exit( __FILE__, __LINE__, s )
 Exit with file + line + status. More...
 
#define utility_exit_with_message_status(m, s)   utility::exit( __FILE__, __LINE__, m, s )
 Exit with file + line + message + status. More...
 
#define runtime_assert(_Expression)
 Assert that the condition holds. Evaluated for both debug and release builds. More...
 
#define runtime_assert_msg(_Expression, msg)
 Assert that the condition holds. Evaluated for both debug and release builds. More...
 
#define runtime_assert_string_msg(_Expression, msg)
 Assert that the condition holds. Evaluated for both debug and release builds. More...
 
#define NORETURN
 

Typedefs

typedef void(* utility::UtilityExitCallBack )(void)
 

Functions

void utility::exit (std::string const &file, int const line, std::string const &message, int const status)
 Exit with file + line + message + optional status. More...
 
int utility::cond_exit (bool condition, std::string const &file, int const line, std::string const &message, int const status)
 Conditional Exit with file + line + message + optional status. More...
 
void utility::exit (std::string const &file, int const line, int const status=1) NORETURN
 Exit with file + line + optional status. More...
 
void utility::exit (int const status, std::string const &file, int const line)
 Exit with file + line + status. More...
 
void utility::set_main_exit_callback (UtilityExitCallBack=0)
 Set call back funtion that will be called on utility::exit. Use this function to overload default behavior of sys.exit to more appropriate to your application Defaut value for callback function is 0, whicth mean no sys exit is called. More...
 
void utility::add_exit_callback (UtilityExitCallBack)
 Add additional callback function that will be called before standard exit(…) is executed. [Note: do not confuse this function with 'set_main_exit_callback' which is replacing the end behavior of exit(…)]. More...
 
void utility::remove_exit_callback (UtilityExitCallBack)
 Remove additional callback function that was previously added by using add_exit_callback. More...
 

Detailed Description

Program exit functions and macros.

Author
David Kim (dekim.nosp@m.@u.w.nosp@m.ashin.nosp@m.gton.nosp@m..edu)
Sergey Lyskov (Serge.nosp@m.y.Ly.nosp@m.skov@.nosp@m.jhu..nosp@m.edu)
Stuart G. Mentzer (Stuar.nosp@m.t_Me.nosp@m.ntzer.nosp@m.@obj.nosp@m.exx.c.nosp@m.om)
Note
The point of these is:
  • Show the file and line number where the exit originates
  • Optionally show a message about why the exit occurred
  • Provide a core dump on Linux/UNIX so a post-mortem backtrace can be performed
  • Provide macro functions to add the file and line for you
Break on utility::exit when debugging to allow you to get a backtrace from the point of exit

Macro Definition Documentation

#define NORETURN
#define runtime_assert (   _Expression)
Value:
if ( !(_Expression) ) { \
utility::cond_exit(_Expression, __FILE__, __LINE__, #_Expression); \
}
int cond_exit(bool condition, std::string const &file, int const line, std::string const &message, int const status)
Conditional Exit with file + line + message + optional status.
Definition: exit.cc:177

Assert that the condition holds. Evaluated for both debug and release builds.

Referenced by utility::options::VariantOption< VectorOption >::activate(), utility::options::VariantOption< VectorOption >::active(), utility::options::VariantOption< VectorOption >::cl_value(), utility::options::VariantOption< VectorOption >::clear(), basic::MetricValueBase::clone(), utility::options::VariantOption< VectorOption >::code(), numeric::MultiDimensionalHistogram::collapse(), numeric::comma_seperated_string_to_xyz(), utility::options::VariantOption< VectorOption >::deactivate(), utility::options::VariantOption< VectorOption >::default_size(), utility::options::VariantOption< VectorOption >::description(), utility::options::VariantOption< VectorOption >::id(), utility::options::VariantOption< VectorOption >::identifier(), numeric::jacobi(), utility::options::VariantOption< VectorOption >::key(), utility::make_tag_with_dashes(), numeric::MultiDimensionalHistogram::mean_squared_error(), utility::options::VariantOption< VectorOption >::n_default_value(), utility::options::VariantOption< VectorOption >::n_value(), utility::options::VariantOption< VectorOption >::name(), utility::options::VariantOption< VectorOption >::operator Option &(), utility::options::VariantOption< VectorOption >::operator Option *(), utility::options::VariantOption< VectorOption >::operator Option const &(), utility::options::VariantOption< VectorOption >::operator Option const *(), utility::options::VariantOption< VectorOption >::operator()(), utility::options::OptionCollection::operator()(), utility::options::operator<(), utility::options::OptionCollection::operator[](), utility::options::OptionCollection::prefix(), utility::options::ResidueChainVectorOption::resnum_and_chain(), utility::options::OptionCollection::set_option_value_cl(), utility::options::OptionCollection::set_option_value_file(), utility::options::VariantOption< VectorOption >::size(), basic::options::start_file(), utility::options::OptionCollection::suffix(), utility::options::OptionCollection::trim(), utility::options::OptionCollection::trimmed(), numeric::random::WeightedSampler::update_cumulative_distribution(), utility::options::VariantOption< VectorOption >::user(), utility::file::PathName::vol(), and utility::options::OptionCollection::wrapped().

#define runtime_assert_msg (   _Expression,
  msg 
)
Value:
if ( !(_Expression) ) { \
utility::cond_exit(_Expression, __FILE__, __LINE__, #_Expression " MSG:" msg ); \
}
int cond_exit(bool condition, std::string const &file, int const line, std::string const &message, int const status)
Conditional Exit with file + line + message + optional status.
Definition: exit.cc:177

Assert that the condition holds. Evaluated for both debug and release builds.

#define runtime_assert_string_msg (   _Expression,
  msg 
)
Value:
if ( !(_Expression) ) { \
utility::cond_exit(_Expression, __FILE__, __LINE__, msg ); \
}
int cond_exit(bool condition, std::string const &file, int const line, std::string const &message, int const status)
Conditional Exit with file + line + message + optional status.
Definition: exit.cc:177

Assert that the condition holds. Evaluated for both debug and release builds.

Referenced by numeric::principal_components_and_eigenvalues_ndimensions().

#define utility_exit ( )    utility::exit( __FILE__, __LINE__ )
#define utility_exit_with_message (   m)    utility::exit( __FILE__, __LINE__, m )

Exit with file + line + message.

Note
The m argument is a message string

Referenced by numeric::expression_parser::ArithmeticScanner::add_function(), numeric::expression_parser::ArithmeticScanner::add_variable(), numeric::expression_parser::SimpleExpressionCreator::add_variable(), numeric::MathVector< Real >::assert_valid_position(), utility::lua::LuaObject::begin(), utility::sql_database::session::begin_transaction(), basic::database::insert_statement_generator::InsertGenerator::bind_row_data(), basic::database::check_statement_sanity(), utility::sql_database::session::commit_transaction(), basic::sampling::SphereSampler::covering_radius_degrees(), basic::resource_manager::ResourceManagerFactory::create_resource_manager_from_options_system(), basic::resource_manager::LazyResourceManager::create_resources(), numeric::random::createRG(), utility::sql_database::database_mode_from_name(), basic::database::db_partition_from_options(), numeric::interpolation::Histogram< typename, typename >::derivative(), numeric::interpolation::Histogram< typename, typename >::derivative_linear(), basic::message_listening::DbMoverMessageListener::deserialize_data(), utility::tag::Tag::die_for_unaccessed_options(), numeric::expression_parser::BinaryExpression::e1(), numeric::expression_parser::BinaryExpression::e2(), utility::io::ozstream::enable_MPI_reroute(), numeric::expression_parser::UnaryExpression::ex(), utility::factory::WidgetFactory< Creator >::factory_register(), basic::resource_manager::ResourceLocatorFactory::factory_register(), basic::resource_manager::ResourceOptionsFactory::factory_register(), basic::resource_manager::FallbackConfigurationFactory::factory_register(), basic::resource_manager::ResourceLoaderFactory::factory_register(), basic::resource_manager::ResourceManager::find_resource(), basic::resource_manager::LazyResourceManager::find_resource(), basic::resource_manager::LazyResourceManager::find_resource_tag_by_job_tag(), utility::sql_database::session::force_commit_transaction(), utility::graph::RingEdgeAnnotationVisitor< Graph, EdgeMap, PathMap >::forward_or_cross_edge(), basic::resource_manager::ResourceManager::free_resource(), utility::Factory< T >::from_string(), utility::from_string(), numeric::expression_parser::ArithmeticASTFunction::function(), numeric::RocCurve::generate_roc_curve(), basic::resource_manager::LazyResourceManager::get_count_of_jobs_associated_with_resource_tag(), utility::sql_database::DatabaseSessionManager::get_db_session(), basic::database::get_db_session(), basic::resource_manager::LazyResourceManager::get_job_options(), basic::message_listening::MessageListenerFactory::get_listener(), basic::options::get_option(), basic::resource_manager::LazyResourceManager::get_resource_tags_for_job_tag(), utility::sql_database::DatabaseSessionManager::get_session_mysql(), utility::sql_database::DatabaseSessionManager::get_session_postgres(), utility::sql_database::DatabaseSessionManager::get_session_sqlite3(), basic::svd::SVD_Solver::get_svd_solution(), numeric::expression_parser::SimpleExpressionCreator::get_variable(), numeric::expression_parser::ExpressionCreator::handle_function_expression(), numeric::expression_parser::BooleanExpressionCreator::handle_function_expression(), numeric::expression_parser::ExpressionCreator::handle_variable_expression(), numeric::expression_parser::SimpleExpressionCreator::handle_variable_expression(), utility::lua::LuaIterator::ikey(), numeric::geometry::hashing::xyzStripeHash::init(), numeric::geometry::hashing::xyzStripeHashWithMeta< float >::init(), basic::database::insert_or_ignore(), numeric::RocCurve::insert_point(), numeric::interpolation::Histogram< typename, typename >::interpolate(), numeric::interpolation::Histogram< typename, typename >::interpolate_linear(), numeric::MathMatrix< Real >::IsValidPosition(), numeric::expression_parser::ArithmeticASTValue::literal_value(), numeric::interpolation::Histogram< typename, typename >::maximum(), numeric::interpolation::Histogram< typename, typename >::minimum(), utility::sql_database::name_from_database_mode(), utility::sql_database::name_from_transaction_mode(), basic::message_listening::name_to_listener_tag(), basic::sampling::SphereSampler::num_sample(), utility::lua::LuaObject::operator bool(), utility::lua::LuaIterator::operator!=(), utility::lua::LuaIterator::operator*(), utility::lua::LuaIterator::operator++(), utility::lua::LuaIterator::operator->(), basic::svd::SVD_Solver::operator=(), utility::lua::LuaIterator::operator==(), utility::lua::LuaObject::operator[](), numeric::expression_parser::ArithmeticASTExpression::parse(), numeric::expression_parser::ArithmeticASTFunction::parse(), numeric::expression_parser::ArithmeticASTTerm::parse(), numeric::expression_parser::ArithmeticASTFactor::parse(), numeric::expression_parser::ArithmeticASTValue::parse(), basic::database::parse_database_connection(), numeric::expression_parser::TokenSet::pop(), basic::database::schema_generator::DbText::print(), basic::database::schema_generator::Index::print(), basic::database::schema_generator::ForeignKey::print(), basic::database::schema_generator::Column::print(), basic::database::schema_generator::DbTextKey::print(), basic::database::schema_generator::DbBigInt::print(), basic::database::schema_generator::DbDouble::print(), basic::database::schema_generator::DbReal::print(), basic::database::schema_generator::DbUUID::print(), numeric::read_probabilities_or_die(), basic::sampling::SphereSampler::read_sphere_data(), utility::ReadFromFileOrDie(), utility::Factory< T >::register_string(), utility::replace_environment_variables(), basic::message_listening::request_data_from_head_node(), numeric::expression_parser::ArithmeticASTRestExpression::rest_expression_token(), numeric::expression_parser::ArithmeticASTRestTerm::rest_term_token(), basic::svd::SVD_Solver::run_decomp_svd(), basic::svd::SVD_Solver::run_score_svd_on_matrix(), basic::svd::SVD_Solver::run_score_svd_without_solving(), basic::svd::SVD_Solver::run_solve_svd(), basic::database::safely_prepare_statement(), basic::database::safely_read_from_database(), basic::database::safely_write_to_database(), basic::sampling::SphereSampler::sample_offset(), numeric::geometry::hashing::xyzStripeHash::sanity_check(), numeric::geometry::hashing::xyzStripeHashWithMeta< float >::sanity_check(), numeric::expression_parser::ArithmeticScanner::scan(), numeric::expression_parser::ArithmeticScanner::scan_identifier(), numeric::expression_parser::ArithmeticScanner::scan_literal(), basic::message_listening::send_data_to_head_node(), basic::svd::SVD_Solver::set_matrix_A(), basic::options::set_option(), numeric::interpolation::Histogram< typename, typename >::set_params(), basic::svd::SVD_Solver::set_vector_b(), utility::lua::LuaObject::size(), utility::lua::LuaIterator::skey(), numeric::interpolation::spline_from_file(), basic::options::start_files(), utility::string_split(), basic::svd::SVD_Solver::SVD_Solver(), basic::svd::SVD_Solver::svdcmp(), basic::database::table_exists(), basic::database::schema_generator::Schema::table_init_statements(), basic::database::schema_generator::Schema::table_schema_statements(), utility::lua::LuaObject::to(), numeric::expression_parser::TokenSet::top(), basic::TracerToFile::TracerToFile(), utility::sql_database::transaction_mode_from_name(), numeric::expression_parser::ArithmeticASTValue::variable_name(), numeric::expression_parser::ASTPrinter::visit(), numeric::expression_parser::ExpressionCreator::visit(), and basic::database::insert_statement_generator::InsertGenerator::write_to_database().

#define utility_exit_with_message_status (   m,
 
)    utility::exit( __FILE__, __LINE__, m, s )

Exit with file + line + message + status.

Note
The m argument is a message string
The s argument is a status value
#define utility_exit_with_status (   s)    utility::exit( __FILE__, __LINE__, s )

Exit with file + line + status.

Note
The s argument is a status value