提交 b39f0033 编写于 作者: T TeslaZhao

fix bad code style by clang-format

上级 57fc2a09
......@@ -25,12 +25,14 @@ namespace predictor {
//////////////// DECLARE INTERFACE ////////////////
#define DECLARE_FACTORY_OBJECT(D, B) \
static int regist(const std::string& tag) { \
FactoryDerive<D, B>* factory = new (std::nothrow) FactoryDerive<D, B>();\
FactoryDerive<D, B>* factory = new (std::nothrow) FactoryDerive<D, B>(); \
if (factory == NULL || \
FactoryPool<B>::instance().register_factory(tag, factory) != 0) { \
char err_str[ERROR_STRING_LEN]; \
snprintf(err_str, ERROR_STRING_LEN - 1, \
"Failed regist factory: %s in macro!", #D); \
snprintf(err_str, \
ERROR_STRING_LEN - 1, \
"Failed regist factory: %s in macro!", \
#D); \
RAW_LOG(FATAL, err_str); \
return -1; \
} \
......@@ -58,8 +60,11 @@ namespace predictor {
::baidu::paddle_serving::predictor::FactoryPool<B>::instance() \
.register_factory(#D, factory) != 0) { \
char err_str[ERROR_STRING_LEN]; \
snprintf(err_str, ERROR_STRING_LEN - 1, \
"Failed regist factory: %s->%s in macro!", #D, #B); \
snprintf(err_str, \
ERROR_STRING_LEN - 1, \
"Failed regist factory: %s->%s in macro!", \
#D, \
#B); \
RAW_LOG(FATAL, err_str); \
return; \
} \
......@@ -76,13 +81,21 @@ namespace predictor {
if (factory == NULL || \
::baidu::paddle_serving::predictor::FactoryPool<B>::instance() \
.register_factory(N, factory) != 0) { \
snprintf(err_str, ERROR_STRING_LEN - 1, \
"Failed regist factory: %s->%s, tag: %s in macro!", #D, #B, N); \
snprintf(err_str, \
ERROR_STRING_LEN - 1, \
"Failed regist factory: %s->%s, tag: %s in macro!", \
#D, \
#B, \
N); \
RAW_LOG(FATAL, err_str); \
return; \
} \
snprintf(err_str, ERROR_STRING_LEN - 1, \
"Succ regist factory: %s->%s, tag: %s in macro!", #D, #B, N); \
snprintf(err_str, \
ERROR_STRING_LEN - 1, \
"Succ regist factory: %s->%s, tag: %s in macro!", \
#D, \
#B, \
N); \
RAW_LOG(WARNING, err_str); \
return; \
}
......@@ -115,8 +128,10 @@ class FactoryPool {
typename std::map<std::string, FactoryBase<B>*>::iterator it =
_pool.find(tag);
if (it != _pool.end()) {
snprintf(err_str, ERROR_STRING_LEN - 1,
"Insert duplicate with tag: %s", tag.c_str());
snprintf(err_str,
ERROR_STRING_LEN - 1,
"Insert duplicate with tag: %s",
tag.c_str());
RAW_LOG(FATAL, err_str);
return -1;
}
......@@ -124,14 +139,18 @@ class FactoryPool {
std::pair<typename std::map<std::string, FactoryBase<B>*>::iterator, bool>
r = _pool.insert(std::make_pair(tag, factory));
if (!r.second) {
snprintf(err_str, ERROR_STRING_LEN - 1,
"Failed insert new factory with: %s", tag.c_str());
snprintf(err_str,
ERROR_STRING_LEN - 1,
"Failed insert new factory with: %s",
tag.c_str());
RAW_LOG(FATAL, err_str);
return -1;
}
snprintf(err_str, ERROR_STRING_LEN - 1,
"Succ insert one factory, tag: %s, base type %s", tag.c_str(),
snprintf(err_str,
ERROR_STRING_LEN - 1,
"Succ insert one factory, tag: %s, base type %s",
tag.c_str(),
typeid(B).name());
RAW_LOG(INFO, err_str);
return 0;
......@@ -142,8 +161,10 @@ class FactoryPool {
_pool.find(tag);
if (it == _pool.end() || it->second == NULL) {
char err_str[ERROR_STRING_LEN];
snprintf(err_str, ERROR_STRING_LEN - 1,
"Not found factory pool, tag: %s, pool size %u", tag.c_str(),
snprintf(err_str,
ERROR_STRING_LEN - 1,
"Not found factory pool, tag: %s, pool size %u",
tag.c_str(),
_pool.size());
RAW_LOG(FATAL, err_str);
return NULL;
......
......@@ -63,8 +63,8 @@ class OpRepository {
void regist_op(std::string op_type) {
_repository[op_type] = &OpFactory<OP_TYPE>::instance();
char err_str[ERROR_STRING_LEN];
snprintf(err_str, ERROR_STRING_LEN - 1, "Succ regist op: %s",
op_type.c_str());
snprintf(
err_str, ERROR_STRING_LEN - 1, "Succ regist op: %s", op_type.c_str());
RAW_LOG(INFO, err_str);
}
......
......@@ -28,12 +28,16 @@ namespace predictor {
::baidu::paddle_serving::predictor::FormatServiceManager::instance() \
.regist_service(svr_name, svr); \
if (ret != 0) { \
snprintf(err_str, ERROR_STRING_LEN - 1, "Failed regist service[%s][%s]", \
snprintf(err_str, \
ERROR_STRING_LEN - 1, \
"Failed regist service[%s][%s]", \
svr_name.c_str(), \
typeid(svr).name()); \
RAW_LOG(ERROR, err_str); \
} else { \
snprintf(err_str, ERROR_STRING_LEN - 1, "Success regist service[%s][%s]", \
snprintf(err_str, \
ERROR_STRING_LEN - 1, \
"Success regist service[%s][%s]", \
svr_name.c_str(), \
typeid(svr).name()); \
RAW_LOG(INFO, err_str); \
......@@ -47,7 +51,9 @@ class FormatServiceManager {
int regist_service(const std::string& svr_name, Service* svr) {
char err_str[ERROR_STRING_LEN];
if (_service_map.find(svr_name) != _service_map.end()) {
snprintf(err_str, ERROR_STRING_LEN - 1, "Service[%s][%s] already exist!",
snprintf(err_str,
ERROR_STRING_LEN - 1,
"Service[%s][%s] already exist!",
svr_name.c_str(),
typeid(svr).name());
RAW_LOG(ERROR, err_str);
......@@ -57,14 +63,18 @@ class FormatServiceManager {
std::pair<boost::unordered_map<std::string, Service*>::iterator, bool> ret;
ret = _service_map.insert(std::make_pair(svr_name, svr));
if (ret.second == false) {
snprintf(err_str, ERROR_STRING_LEN - 1, "Service[%s][%s] insert failed!",
snprintf(err_str,
ERROR_STRING_LEN - 1,
"Service[%s][%s] insert failed!",
svr_name.c_str(),
typeid(svr).name());
RAW_LOG(ERROR, err_str);
return -1;
}
snprintf(err_str, ERROR_STRING_LEN - 1, "Service[%s] insert successfully!",
snprintf(err_str,
ERROR_STRING_LEN - 1,
"Service[%s] insert successfully!",
svr_name.c_str());
RAW_LOG(INFO, err_str);
return 0;
......@@ -74,8 +84,10 @@ class FormatServiceManager {
char err_str[ERROR_STRING_LEN];
boost::unordered_map<std::string, Service*>::iterator res;
if ((res = _service_map.find(svr_name)) == _service_map.end()) {
snprintf(err_str, ERROR_STRING_LEN - 1,
"Service[%s] not found in service manager!", svr_name.c_str());
snprintf(err_str,
ERROR_STRING_LEN - 1,
"Service[%s] not found in service manager!",
svr_name.c_str());
RAW_LOG(WARNING, err_str);
return NULL;
}
......
......@@ -62,7 +62,8 @@ class WeightedRandomRender : public EndpointRouterBase {
// together.
if (FactoryPool<EndpointRouterBase>::instance().register_factory(
"WeightedRandomRender", factory) != 0) {
RAW_LOG(INFO, "Factory has been registed: \
RAW_LOG(INFO,
"Factory has been registed: \
WeightedRandomRender->EndpointRouterBase.");
}
......
......@@ -33,10 +33,13 @@ namespace brpc = baidu::rpc;
do { \
Factory<D, B>* factory = new (std::nothrow) Factory<D, B>(); \
if (factory == NULL || \
FactoryPool<B>::instance().register_factory(#D, factory) != 0) {\
FactoryPool<B>::instance().register_factory(#D, factory) != 0) { \
char err_str[ERROR_STRING_LEN]; \
snprintf(err_str, ERROR_STRING_LEN - 1, \
"Failed regist factory: %s->%s in macro!", #D, #B); \
snprintf(err_str, \
ERROR_STRING_LEN - 1, \
"Failed regist factory: %s->%s in macro!", \
#D, \
#B); \
RAW_LOG(ERROR, err_str); \
return E; \
} \
......@@ -48,8 +51,10 @@ namespace brpc = baidu::rpc;
if (factory == NULL || \
FactoryPool<B>::instance().register_factory(tag, factory) != 0) { \
char err_str[ERROR_STRING_LEN]; \
snprintf(err_str, ERROR_STRING_LEN - 1, \
"Failed regist factory: %s in macro!", #D); \
snprintf(err_str, \
ERROR_STRING_LEN - 1, \
"Failed regist factory: %s in macro!", \
#D); \
RAW_LOG(ERROR, err_str); \
return -1; \
} \
......@@ -69,13 +74,16 @@ namespace brpc = baidu::rpc;
__attribute__((constructor)) static void PDS_STR_CAT(GlobalRegistObject, \
__LINE__)(void) { \
::baidu::paddle_serving::sdk_cpp::Factory<D, B>* factory = \
new (::std::nothrow)::baidu::paddle_serving::sdk_cpp::Factory<D, B>();\
new (::std::nothrow)::baidu::paddle_serving::sdk_cpp::Factory<D, B>(); \
if (factory == NULL || \
::baidu::paddle_serving::sdk_cpp::FactoryPool<B>::instance() \
.register_factory(#D, factory) != 0) { \
char err_str[ERROR_STRING_LEN]; \
snprintf(err_str, ERROR_STRING_LEN - 1, \
"Failed regist factory: %s->%s in macro!", #D, #B); \
snprintf(err_str, \
ERROR_STRING_LEN - 1, \
"Failed regist factory: %s->%s in macro!", \
#D, \
#B); \
RAW_LOG(ERROR, err_str); \
return; \
} \
......@@ -86,13 +94,17 @@ namespace brpc = baidu::rpc;
__attribute__((constructor)) static void PDS_STR_CAT(GlobalRegistObject, \
__LINE__)(void) { \
::baidu::paddle_serving::sdk_cpp::Factory<D, B>* factory = \
new (::std::nothrow)::baidu::paddle_serving::sdk_cpp::Factory<D, B>();\
new (::std::nothrow)::baidu::paddle_serving::sdk_cpp::Factory<D, B>(); \
if (factory == NULL || \
::baidu::paddle_serving::sdk_cpp::FactoryPool<B>::instance() \
.register_factory(T, factory) != 0) { \
char err_str[ERROR_STRING_LEN]; \
snprintf(err_str, ERROR_STRING_LEN - 1, \
"Failed regist factory: %s->%s, tag %s in macro!", #D, #B, T); \
snprintf(err_str, \
ERROR_STRING_LEN - 1, \
"Failed regist factory: %s->%s, tag %s in macro!", \
#D, \
#B, \
T); \
RAW_LOG(ERROR, err_str); \
return; \
} \
......@@ -121,8 +133,11 @@ namespace brpc = baidu::rpc;
::baidu::paddle_serving::sdk_cpp::Stub>::instance() \
.register_factory(T, factory) != 0) { \
char err_str[ERROR_STRING_LEN]; \
snprintf(err_str, ERROR_STRING_LEN - 1, \
"Failed regist factory: %s->Stub, tag: %s in macro!", #D, T); \
snprintf(err_str, \
ERROR_STRING_LEN - 1, \
"Failed regist factory: %s->Stub, tag: %s in macro!", \
#D, \
T); \
RAW_LOG(ERROR, err_str); \
return; \
} \
......@@ -161,8 +176,10 @@ class FactoryPool {
_pool.find(tag);
if (it != _pool.end()) {
char err_str[ERROR_STRING_LEN];
snprintf(err_str, ERROR_STRING_LEN - 1,
"Insert duplicate with tag: %s", tag.c_str());
snprintf(err_str,
ERROR_STRING_LEN - 1,
"Insert duplicate with tag: %s",
tag.c_str());
RAW_LOG(ERROR, err_str);
return -1;
}
......@@ -171,8 +188,10 @@ class FactoryPool {
r = _pool.insert(std::make_pair(tag, factory));
if (!r.second) {
char err_str[ERROR_STRING_LEN];
snprintf(err_str, ERROR_STRING_LEN - 1,
"Failed insert new factory with: %s", tag.c_str());
snprintf(err_str,
ERROR_STRING_LEN - 1,
"Failed insert new factory with: %s",
tag.c_str());
RAW_LOG(ERROR, err_str);
return -1;
}
......@@ -185,9 +204,11 @@ class FactoryPool {
_pool.find(tag);
if (it == _pool.end() || it->second == NULL) {
char err_str[ERROR_STRING_LEN];
snprintf(err_str, ERROR_STRING_LEN - 1,
snprintf(err_str,
ERROR_STRING_LEN - 1,
"Not found factory pool, tag: %s, pool size: %u",
tag.c_str(), _pool.size());
tag.c_str(),
_pool.size());
RAW_LOG(ERROR, err_str);
return NULL;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册