Skip to content

Commit

Permalink
batch fix coding style problems
Browse files Browse the repository at this point in the history
by command
find . -iname "*.h" -o -iname "*.cc"  | xargs clang-format-3.9 -i -style=Google
  • Loading branch information
startcode committed Jul 20, 2017
1 parent 9995eed commit 2230b47
Show file tree
Hide file tree
Showing 190 changed files with 1,418 additions and 1,421 deletions.
12 changes: 6 additions & 6 deletions modules/canbus/can_client/can_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class CanClient {
* @param parameter CAN card parameters to initialize the CAN client.
* @return If the initialization is successful.
*/
virtual bool Init(const CANCardParameter& parameter) = 0;
virtual bool Init(const CANCardParameter &parameter) = 0;

/**
* @brief Start the CAN client.
Expand All @@ -120,8 +120,8 @@ class CanClient {
* @return The status of the sending action which is defined by
* apollo::common::ErrorCode.
*/
virtual apollo::common::ErrorCode Send(const std::vector<CanFrame>& frames,
int32_t* const frame_num) = 0;
virtual apollo::common::ErrorCode Send(const std::vector<CanFrame> &frames,
int32_t *const frame_num) = 0;

/**
* @brief Send a single message.
Expand All @@ -130,7 +130,7 @@ class CanClient {
* apollo::common::ErrorCode.
*/
virtual apollo::common::ErrorCode SendSingleFrame(
const std::vector<CanFrame>& frames) {
const std::vector<CanFrame> &frames) {
CHECK_EQ(frames.size(), 1);
int32_t n = 1;
return Send(frames, &n);
Expand All @@ -143,8 +143,8 @@ class CanClient {
* @return The status of the receiving action which is defined by
* apollo::common::ErrorCode.
*/
virtual apollo::common::ErrorCode Receive(std::vector<CanFrame>* const frames,
int32_t* const frame_num) = 0;
virtual apollo::common::ErrorCode Receive(std::vector<CanFrame> *const frames,
int32_t *const frame_num) = 0;

/**
* @brief Get the error string.
Expand Down
6 changes: 3 additions & 3 deletions modules/canbus/can_client/can_client_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ CanClientFactory::CanClientFactory() {}

void CanClientFactory::RegisterCanClients() {
Register(CANCardParameter::FAKE_CAN,
[]() -> CanClient* { return new can::FakeCanClient(); });
[]() -> CanClient * { return new can::FakeCanClient(); });
#if USE_ESD_CAN
Register(CANCardParameter::ESD_CAN,
[]() -> CanClient* { return new can::EsdCanClient(); });
[]() -> CanClient * { return new can::EsdCanClient(); });
#endif
}

std::unique_ptr<CanClient> CanClientFactory::CreateCANClient(
const CANCardParameter& parameter) {
const CANCardParameter &parameter) {
auto factory = CreateObject(parameter.brand());
if (!factory) {
AERROR << "Failed to create can client with parameter: "
Expand Down
2 changes: 1 addition & 1 deletion modules/canbus/can_client/can_client_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class CanClientFactory
* @param parameter The parameter to create the CAN client.
* @return A pointer to the created CAN client.
*/
std::unique_ptr<CanClient> CreateCANClient(const CANCardParameter& parameter);
std::unique_ptr<CanClient> CreateCANClient(const CANCardParameter &parameter);

private:
DECLARE_SINGLETON(CanClientFactory);
Expand Down
2 changes: 1 addition & 1 deletion modules/canbus/can_client/can_client_factory_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace apollo {
namespace canbus {

TEST(CanClientFactoryTest, CreateCanClient) {
auto* can_factory = CanClientFactory::instance();
auto *can_factory = CanClientFactory::instance();
EXPECT_TRUE(can_factory != nullptr);

can_factory->RegisterCanClients();
Expand Down
26 changes: 13 additions & 13 deletions modules/canbus/can_client/can_client_tool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ struct TestCanParam {
int32_t send_lost_cnt = 0;
int32_t send_time = 0;
int32_t recv_time = 0;
CanClient* can_client = nullptr;
CanClient *can_client = nullptr;

TestCanParam() = default;

Expand All @@ -72,11 +72,11 @@ struct TestCanParam {

class CanAgent {
public:
explicit CanAgent(TestCanParam* param_ptr) : param_ptr_(param_ptr) {}
explicit CanAgent(TestCanParam *param_ptr) : param_ptr_(param_ptr) {}

TestCanParam* param_ptr() { return param_ptr_; }
TestCanParam *param_ptr() { return param_ptr_; }

CanAgent* other_agent() { return other_agent_; }
CanAgent *other_agent() { return other_agent_; }

bool Start() {
thread_recv_.reset(new std::thread([this] { RecvThreadFunc(); }));
Expand All @@ -98,8 +98,8 @@ class CanAgent {
using ::apollo::common::time::micros;
using ::apollo::common::ErrorCode;
AINFO << "Send thread starting...";
TestCanParam* param = param_ptr();
CanClient* client = param->can_client;
TestCanParam *param = param_ptr();
CanClient *client = param->can_client;
std::vector<CanFrame> frames;
frames.resize(MAX_CAN_SEND_FRAME_LEN);

Expand Down Expand Up @@ -167,7 +167,7 @@ class CanAgent {
return;
}

void AddOtherAgent(CanAgent* agent) { other_agent_ = agent; }
void AddOtherAgent(CanAgent *agent) { other_agent_ = agent; }

bool is_receiving() { return is_receiving_; }

Expand All @@ -183,8 +183,8 @@ class CanAgent {
using ::apollo::common::time::micros;
using ::apollo::common::ErrorCode;
AINFO << "Receive thread starting...";
TestCanParam* param = param_ptr();
CanClient* client = param->can_client;
TestCanParam *param = param_ptr();
CanClient *client = param->can_client;
int64_t start = 0;
std::vector<CanFrame> buf;

Expand Down Expand Up @@ -238,16 +238,16 @@ class CanAgent {
private:
bool is_receiving_ = false;
bool is_sending_finish_ = false;
CanAgent* other_agent_ = nullptr;
TestCanParam* param_ptr_ = nullptr;
CanAgent *other_agent_ = nullptr;
TestCanParam *param_ptr_ = nullptr;
std::unique_ptr<std::thread> thread_recv_;
std::unique_ptr<std::thread> thread_send_;
};

} // namespace canbus
} // namespace apollo

int main(int32_t argc, char** argv) {
int main(int32_t argc, char **argv) {
google::InitGoogleLogging(argv[0]);
google::ParseCommandLineFlags(&argc, &argv, true);

Expand All @@ -261,7 +261,7 @@ int main(int32_t argc, char** argv) {
std::shared_ptr<TestCanParam> param_ptr_a(new TestCanParam());
std::shared_ptr<TestCanParam> param_ptr_b(new TestCanParam());

auto* can_client_factory = CanClientFactory::instance();
auto *can_client_factory = CanClientFactory::instance();
can_client_factory->RegisterCanClients();

if (!::apollo::common::util::GetProtoFromFile(FLAGS_can_client_conf_file_a,
Expand Down
10 changes: 5 additions & 5 deletions modules/canbus/can_client/esd/esd_can_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class EsdCanClient : public CanClient {
* @param parameter CAN card parameters to initialize the CAN client.
* @return If the initialization is successful.
*/
bool Init(const CANCardParameter& parameter) override;
bool Init(const CANCardParameter &parameter) override;

/**
* @brief Destructor
Expand All @@ -76,8 +76,8 @@ class EsdCanClient : public CanClient {
* @return The status of the sending action which is defined by
* apollo::common::ErrorCode.
*/
apollo::common::ErrorCode Send(const std::vector<CanFrame>& frames,
int32_t* const frame_num) override;
apollo::common::ErrorCode Send(const std::vector<CanFrame> &frames,
int32_t *const frame_num) override;

/**
* @brief Receive messages
Expand All @@ -86,8 +86,8 @@ class EsdCanClient : public CanClient {
* @return The status of the receiving action which is defined by
* apollo::common::ErrorCode.
*/
apollo::common::ErrorCode Receive(std::vector<CanFrame>* const frames,
int32_t* const frame_num) override;
apollo::common::ErrorCode Receive(std::vector<CanFrame> *const frames,
int32_t *const frame_num) override;

/**
* @brief Get the error string.
Expand Down
6 changes: 3 additions & 3 deletions modules/canbus/can_client/esd/esd_can_client_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ TEST(EsdCanClientTest, simple_test) {
std::vector<CanFrame> frames;
int32_t num = 0;
EXPECT_EQ(esd_can_client.Send(frames, &num),
ErrorCode::CAN_CLIENT_ERROR_SEND_FAILED);
ErrorCode::CAN_CLIENT_ERROR_SEND_FAILED);
EXPECT_EQ(esd_can_client.Receive(&frames, &num),
ErrorCode::CAN_CLIENT_ERROR_RECV_FAILED);
ErrorCode::CAN_CLIENT_ERROR_RECV_FAILED);
CanFrame can_frame;
frames.push_back(can_frame);
EXPECT_EQ(esd_can_client.SendSingleFrame(frames),
ErrorCode::CAN_CLIENT_ERROR_SEND_FAILED);
ErrorCode::CAN_CLIENT_ERROR_SEND_FAILED);
esd_can_client.Stop();
}

Expand Down
10 changes: 5 additions & 5 deletions modules/canbus/can_client/fake/fake_can_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ namespace can {

using apollo::common::ErrorCode;

bool FakeCanClient::Init(const CANCardParameter& param) { return true; }
bool FakeCanClient::Init(const CANCardParameter &param) { return true; }

ErrorCode FakeCanClient::Start() { return ErrorCode::OK; }

void FakeCanClient::Stop() {}

ErrorCode FakeCanClient::Send(const std::vector<CanFrame>& frames,
int32_t* const frame_num) {
ErrorCode FakeCanClient::Send(const std::vector<CanFrame> &frames,
int32_t *const frame_num) {
if (frame_num == nullptr) {
AERROR << "frame_num pointer is null";
return ErrorCode::CAN_CLIENT_ERROR_BASE;
Expand All @@ -50,8 +50,8 @@ ErrorCode FakeCanClient::Send(const std::vector<CanFrame>& frames,
return ErrorCode::OK;
}

ErrorCode FakeCanClient::Receive(std::vector<CanFrame>* const frames,
int32_t* const frame_num) {
ErrorCode FakeCanClient::Receive(std::vector<CanFrame> *const frames,
int32_t *const frame_num) {
if (frame_num == nullptr || frames == nullptr) {
AERROR << "frames or frame_num pointer is null";
return ErrorCode::CAN_CLIENT_ERROR_BASE;
Expand Down
10 changes: 5 additions & 5 deletions modules/canbus/can_client/fake/fake_can_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class FakeCanClient : public CanClient {
* @param parameter CAN card parameters to initialize the CAN client.
* @return If the initialization is successful.
*/
bool Init(const CANCardParameter& param) override;
bool Init(const CANCardParameter &param) override;

/**
* @brief Destructor
Expand All @@ -78,8 +78,8 @@ class FakeCanClient : public CanClient {
* @return The status of the sending action which is defined by
* apollo::common::ErrorCode.
*/
apollo::common::ErrorCode Send(const std::vector<CanFrame>& frames,
int32_t* const frame_num) override;
apollo::common::ErrorCode Send(const std::vector<CanFrame> &frames,
int32_t *const frame_num) override;

/**
* @brief Receive messages
Expand All @@ -88,8 +88,8 @@ class FakeCanClient : public CanClient {
* @return The status of the receiving action which is defined by
* apollo::common::ErrorCode.
*/
apollo::common::ErrorCode Receive(std::vector<CanFrame>* frames,
int32_t* const frame_num) override;
apollo::common::ErrorCode Receive(std::vector<CanFrame> *frames,
int32_t *const frame_num) override;

/**
* @brief Get the error string.
Expand Down
6 changes: 3 additions & 3 deletions modules/canbus/can_comm/can_receiver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace canbus {

using ::apollo::common::ErrorCode;

ErrorCode CanReceiver::Init(CanClient* can_client, MessageManager* pt_manager,
ErrorCode CanReceiver::Init(CanClient *can_client, MessageManager *pt_manager,
bool enable_log) {
can_client_ = can_client;
pt_manager_ = pt_manager;
Expand Down Expand Up @@ -82,10 +82,10 @@ void CanReceiver::RecvThreadFunc() {
}
receive_none_count = 0;

for (const auto& frame : buf) {
for (const auto &frame : buf) {
uint8_t len = frame.len;
uint32_t uid = frame.id;
const uint8_t* data = frame.data;
const uint8_t *data = frame.data;
struct timeval timestamp;
timestamp.tv_sec = frame.timestamp.tv_sec;
timestamp.tv_usec = frame.timestamp.tv_usec;
Expand Down
8 changes: 4 additions & 4 deletions modules/canbus/can_comm/can_receiver.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ class CanReceiver {
* @param enable_log If log the essential information during running.
* @return An error code indicating the status of this initialization.
*/
::apollo::common::ErrorCode Init(CanClient* can_client,
MessageManager* pt_manager, bool enable_log);
::apollo::common::ErrorCode Init(CanClient *can_client,
MessageManager *pt_manager, bool enable_log);

/**
* @brief Get the working status of this CAN receiver.
Expand Down Expand Up @@ -91,8 +91,8 @@ class CanReceiver {
std::unique_ptr<std::thread> thread_;
bool is_running_ = false;
// CanClient, MessageManager pointer life is managed by outer program
CanClient* can_client_ = nullptr;
MessageManager* pt_manager_ = nullptr;
CanClient *can_client_ = nullptr;
MessageManager *pt_manager_ = nullptr;
bool enable_log_ = false;
bool is_init_ = false;

Expand Down
14 changes: 7 additions & 7 deletions modules/canbus/can_comm/can_sender.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ const uint32_t kSenderInterval = 6000;
std::mutex SenderMessage::mutex_;

SenderMessage::SenderMessage(const uint32_t message_id,
ProtocolData* protocol_data)
ProtocolData *protocol_data)
: SenderMessage(message_id, protocol_data, false) {}

SenderMessage::SenderMessage(const uint32_t message_id,
ProtocolData* protocol_data, bool init_with_one)
ProtocolData *protocol_data, bool init_with_one)
: message_id_(message_id), protocol_data_(protocol_data) {
if (init_with_one) {
for (int32_t i = 0; i < protocol_data->GetLength(); ++i) {
Expand Down Expand Up @@ -100,7 +100,7 @@ void CanSender::PowerSendThreadFunc() {
tm_start = ::apollo::common::time::AsInt64<micros>(Clock::Now());
new_delta_period = INIT_PERIOD;

for (auto& message : send_messages_) {
for (auto &message : send_messages_) {
bool need_send = NeedSend(message, delta_period);
message.UpdateCurrPeriod(delta_period);
new_delta_period = std::min(new_delta_period, message.curr_period());
Expand Down Expand Up @@ -133,7 +133,7 @@ void CanSender::PowerSendThreadFunc() {
AINFO << "Can client sender thread stopped!";
}

ErrorCode CanSender::Init(CanClient* can_client, bool enable_log) {
ErrorCode CanSender::Init(CanClient *can_client, bool enable_log) {
if (is_init_) {
AERROR << "Duplicated Init request.";
return ErrorCode::CANBUS_ERROR;
Expand All @@ -148,7 +148,7 @@ ErrorCode CanSender::Init(CanClient* can_client, bool enable_log) {
return ErrorCode::OK;
}

void CanSender::AddMessage(uint32_t message_id, ProtocolData* protocol_data,
void CanSender::AddMessage(uint32_t message_id, ProtocolData *protocol_data,
bool init_with_one) {
if (protocol_data == nullptr) {
AERROR << "invalid protocol data.";
Expand All @@ -171,7 +171,7 @@ ErrorCode CanSender::Start() {
}

void CanSender::Update() {
for (auto& message : send_messages_) {
for (auto &message : send_messages_) {
message.Update();
}
}
Expand All @@ -195,7 +195,7 @@ bool CanSender::IsRunning() const { return is_running_; }

bool CanSender::enable_log() const { return enable_log_; }

bool CanSender::NeedSend(const SenderMessage& msg, const int32_t delta_period) {
bool CanSender::NeedSend(const SenderMessage &msg, const int32_t delta_period) {
return msg.curr_period() <= delta_period;
}

Expand Down
Loading

0 comments on commit 2230b47

Please sign in to comment.