8 #define DRIPLINE_API_EXPORTS 16 LOGGER(
rclog,
"return_codes" );
23 f_description( a_description )
90 void add_return_code(
unsigned a_value,
const std::string& a_name,
const std::string& a_description )
92 static std::vector< std::unique_ptr<custom_return_code_registrar> > f_rc_registrars;
104 catch(
const scarab::error& )
112 std::vector< unsigned > return_codes;
113 scarab::indexed_factory< unsigned, return_code >* the_factory = scarab::indexed_factory< unsigned, return_code >::get_instance();
114 LDEBUG(
rclog,
"factory is at: " << the_factory );
115 for(
auto code_entry = the_factory->begin(); code_entry != the_factory->end(); ++code_entry )
117 return_codes.push_back( code_entry->first );
124 std::map< unsigned, std::unique_ptr<return_code> > the_return_codes;
125 scarab::indexed_factory< unsigned, return_code >* the_factory = scarab::indexed_factory< unsigned, return_code >::get_instance();
126 for(
auto code_entry = the_factory->begin(); code_entry != the_factory->end(); ++code_entry )
128 the_return_codes.emplace( std::make_pair(
130 std::unique_ptr<return_code>( code_entry->second->create() )
133 return the_return_codes;
147 scarab::indexed_factory< unsigned, return_code >::get_instance()->remove_class(
f_value );
152 scarab::indexed_factory< unsigned, return_code >::get_instance()->register_class(
f_value,
this );
Base class for return codes.
void register_class() const
virtual ~custom_return_code_registrar()
std::map< unsigned, std::unique_ptr< return_code > > get_return_codes_map()
virtual unsigned rc_value() const
Stores a copy of the return-code value, name, and description, either as a custom return-code or copy...
virtual unsigned rc_value() const =0
std::ostream & operator<<(std::ostream &a_os, op_t an_op)
Pass the integer-equivalent of a message-operation enum to an ostream.
std::string f_description
virtual std::string rc_name() const =0
bool check_and_add_return_code(unsigned a_value, const std::string &a_name, const std::string &a_description)
virtual std::string rc_description() const
static scarab::logger rclog("return_codes")
custom_return_code_registrar(const unsigned &a_value, const std::string &a_name, const std::string &a_description)
void add_return_code(unsigned a_value, const std::string &a_name, const std::string &a_description)
Helper function to add a return code (primarily for python binding); scarab::error will be thrown if ...
copy_code(unsigned a_value, const std::string &a_name, const std::string &a_description)
virtual std::string rc_name() const
#define IMPLEMENT_DL_RET_CODE(name, the_value, description)
return_code * create() const
virtual std::string rc_description() const =0
bool operator==(const message &a_lhs, const message &a_rhs)
std::vector< unsigned > get_return_code_values()
std::string f_description