本文整理汇总了C++中request::get_component_type方法的典型用法代码示例。如果您正苦于以下问题:C++ request::get_component_type方法的具体用法?C++ request::get_component_type怎么用?C++ request::get_component_type使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类request
的用法示例。
在下文中一共展示了request::get_component_type方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: resolve_id
response component_namespace::resolve_id(
request const& req
, error_code& ec
)
{ // {{{ resolve_id implementation
// parameters
component_id_type key = req.get_component_type();
// If the requested component type is a derived type, use only its derived
// part for the lookup.
if (key != components::get_base_type(key))
key = components::get_derived_type(key);
std::lock_guard<mutex_type> l(mutex_);
factory_table_type::const_iterator it = factories_.find(key)
, end = factories_.end();
// REVIEW: Should we differentiate between these two cases? Should we
// throw an exception if it->second.empty()? It should be impossible.
if (it == end || it->second.empty())
{
LAGAS_(info) << (boost::format(
"component_namespace::resolve_id, key(%1%), localities(0)")
% key);
if (&ec != &throws)
ec = make_success_code();
return response(component_ns_resolve_id
, std::vector<boost::uint32_t>());
}
else
{
std::vector<boost::uint32_t> p;
prefixes_type const& prefixes = it->second;
prefixes_type::const_iterator pit = prefixes.begin()
, pend = prefixes.end();
for (; pit != pend; ++pit)
p.push_back(*pit);
LAGAS_(info) << (boost::format(
"component_namespace::resolve_id, key(%1%), localities(%2%)")
% key % prefixes.size());
if (&ec != &throws)
ec = make_success_code();
return response(component_ns_resolve_id, p);
}
} // }}}
示例2: get_component_type_name
response component_namespace::get_component_type_name(
request const& req
, error_code& ec
)
{ // {{{ get_component_type_name implementation
components::component_type t = req.get_component_type();
std::lock_guard<mutex_type> l(mutex_);
std::string result;
if (t == components::component_invalid) {
result = "component_invalid";
}
else if (components::get_derived_type(t) == 0) {
result = get_component_name(component_ids_.right, t);
}
else if (components::get_derived_type(t) != 0) {
result = get_component_name(component_ids_.right,
components::get_derived_type(t));
result += "/";
result += get_component_name(component_ids_.right,
components::get_base_type(t));
}
if (result.empty())
{
LAGAS_(info) << (boost::format(
"component_namespace::get_component_typename, \
key(%1%/%2%), response(no_success)")
% int(components::get_derived_type(t)) %
int(components::get_base_type(t)));
if (&ec != &throws)
ec = make_success_code();
return response(component_ns_get_component_type_name, no_success);
}