Skip to content
This repository was archived by the owner on Aug 5, 2022. It is now read-only.

Commit 861a700

Browse files
committed
Formatting remote-processor code with clang-format
Signed-off-by: Thomas Cahuzac <[email protected]>
1 parent 3d78081 commit 861a700

13 files changed

+115
-163
lines changed

remote-processor/AnswerMessage.cpp

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*
1+
/*
22
* Copyright (c) 2011-2014, Intel Corporation
33
* All rights reserved.
44
*
@@ -34,26 +34,17 @@
3434

3535
using std::string;
3636

37-
CAnswerMessage::CAnswerMessage(const string& strAnswer, bool bSuccess) :
38-
base(bSuccess ? MsgType::ESuccessAnswer : MsgType::EFailureAnswer),
39-
_strAnswer(strAnswer)
37+
CAnswerMessage::CAnswerMessage(const string &strAnswer, bool bSuccess)
38+
: base(bSuccess ? MsgType::ESuccessAnswer : MsgType::EFailureAnswer), _strAnswer(strAnswer)
4039
{
4140
}
4241

43-
CAnswerMessage::CAnswerMessage()
44-
{
45-
}
42+
CAnswerMessage::CAnswerMessage() {}
4643

4744
// Answer
48-
void CAnswerMessage::setAnswer(const string& strAnswer)
49-
{
50-
_strAnswer = strAnswer;
51-
}
45+
void CAnswerMessage::setAnswer(const string &strAnswer) { _strAnswer = strAnswer; }
5246

53-
const string& CAnswerMessage::getAnswer() const
54-
{
55-
return _strAnswer;
56-
}
47+
const string &CAnswerMessage::getAnswer() const { return _strAnswer; }
5748

5849
// Status
5950
bool CAnswerMessage::success() const

remote-processor/AnswerMessage.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*
1+
/*
22
* Copyright (c) 2011-2014, Intel Corporation
33
* All rights reserved.
44
*
@@ -36,14 +36,15 @@
3636
class REMOTE_PROCESSOR_EXPORT CAnswerMessage : public CMessage
3737
{
3838
public:
39-
CAnswerMessage(const std::string& strAnswer, bool bSuccess);
39+
CAnswerMessage(const std::string &strAnswer, bool bSuccess);
4040
CAnswerMessage();
4141

4242
// Answer
43-
const std::string& getAnswer() const;
43+
const std::string &getAnswer() const;
4444

4545
// Status
4646
bool success() const;
47+
4748
private:
4849
// Fill data to send
4950
virtual void fillDataToSend();
@@ -54,9 +55,8 @@ class REMOTE_PROCESSOR_EXPORT CAnswerMessage : public CMessage
5455
*/
5556
virtual size_t getDataSize() const;
5657
// Answer
57-
void setAnswer(const std::string& strAnswer);
58+
void setAnswer(const std::string &strAnswer);
5859

5960
// Answer
6061
std::string _strAnswer;
6162
};
62-

remote-processor/BackgroundRemoteProcessorServerBuilder.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*
1+
/*
22
* Copyright (c) 2011-2014, Intel Corporation
33
* All rights reserved.
44
*
@@ -35,8 +35,10 @@ class BackgroundRemoteProcessorServer final : public IRemoteProcessorServerInter
3535
{
3636
public:
3737
BackgroundRemoteProcessorServer(uint16_t uiPort,
38-
std::unique_ptr<IRemoteCommandHandler> &commandHandler) :
39-
_server(uiPort), mCommandHandler(std::move(commandHandler)) {}
38+
std::unique_ptr<IRemoteCommandHandler> &commandHandler)
39+
: _server(uiPort), mCommandHandler(std::move(commandHandler))
40+
{
41+
}
4042

4143
~BackgroundRemoteProcessorServer() { stop(); }
4244

@@ -46,9 +48,8 @@ class BackgroundRemoteProcessorServer final : public IRemoteProcessorServerInter
4648
return false;
4749
}
4850
try {
49-
mServerSuccess = std::async(std::launch::async,
50-
&CRemoteProcessorServer::process, &_server,
51-
std::ref(*mCommandHandler));
51+
mServerSuccess = std::async(std::launch::async, &CRemoteProcessorServer::process,
52+
&_server, std::ref(*mCommandHandler));
5253
} catch (std::exception &e) {
5354
error = "Could not create a remote processor thread: " + std::string(e.what());
5455
return false;
@@ -57,7 +58,8 @@ class BackgroundRemoteProcessorServer final : public IRemoteProcessorServerInter
5758
return true;
5859
}
5960

60-
bool stop() override {
61+
bool stop() override
62+
{
6163
_server.stop();
6264
return mServerSuccess.get();
6365
}
@@ -67,4 +69,3 @@ class BackgroundRemoteProcessorServer final : public IRemoteProcessorServerInter
6769
std::unique_ptr<IRemoteCommandHandler> mCommandHandler;
6870
std::future<bool> mServerSuccess;
6971
};
70-

remote-processor/Message.cpp

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -35,29 +35,20 @@
3535

3636
using std::string;
3737

38-
CMessage::CMessage(MsgType ucMsgId) :
39-
_ucMsgId(ucMsgId), _uiIndex(0)
40-
{
41-
}
38+
CMessage::CMessage(MsgType ucMsgId) : _ucMsgId(ucMsgId), _uiIndex(0) {}
4239

43-
CMessage::CMessage() :
44-
_ucMsgId(MsgType::EInvalid), _uiIndex(0)
45-
{
46-
}
40+
CMessage::CMessage() : _ucMsgId(MsgType::EInvalid), _uiIndex(0) {}
4741

4842
// Msg Id
49-
CMessage::MsgType CMessage::getMsgId() const
50-
{
51-
return _ucMsgId;
52-
}
43+
CMessage::MsgType CMessage::getMsgId() const { return _ucMsgId; }
5344

5445
bool CMessage::isValidAccess(size_t offset, size_t size) const
5546
{
5647
return offset + size <= getMessageDataSize();
5748
}
5849

5950
// Data
60-
void CMessage::writeData(const void* pvData, size_t size)
51+
void CMessage::writeData(const void *pvData, size_t size)
6152
{
6253
assert(isValidAccess(_uiIndex, size));
6354

@@ -70,7 +61,7 @@ void CMessage::writeData(const void* pvData, size_t size)
7061
_uiIndex += size;
7162
}
7263

73-
void CMessage::readData(void* pvData, size_t size)
64+
void CMessage::readData(void *pvData, size_t size)
7465
{
7566
assert(isValidAccess(_uiIndex, size));
7667

@@ -83,7 +74,7 @@ void CMessage::readData(void* pvData, size_t size)
8374
_uiIndex += size;
8475
}
8576

86-
void CMessage::writeString(const string& strData)
77+
void CMessage::writeString(const string &strData)
8778
{
8879
// Size
8980
uint32_t size = static_cast<uint32_t>(strData.length());
@@ -94,7 +85,7 @@ void CMessage::writeString(const string& strData)
9485
writeData(strData.c_str(), size);
9586
}
9687

97-
void CMessage::readString(string& strData)
88+
void CMessage::readString(string &strData)
9889
{
9990
// Size
10091
uint32_t uiSize;
@@ -114,20 +105,17 @@ void CMessage::readString(string& strData)
114105
strData = string.data();
115106
}
116107

117-
size_t CMessage::getStringSize(const string& strData) const
108+
size_t CMessage::getStringSize(const string &strData) const
118109
{
119110
// Return string length plus room to store its length
120111
return strData.length() + sizeof(uint32_t);
121112
}
122113

123114
// Remaining data size
124-
size_t CMessage::getRemainingDataSize() const
125-
{
126-
return getMessageDataSize() - _uiIndex;
127-
}
115+
size_t CMessage::getRemainingDataSize() const { return getMessageDataSize() - _uiIndex; }
128116

129117
// Send/Receive
130-
CMessage::Result CMessage::serialize(asio::ip::tcp::socket &socket, bool bOut, string& strError)
118+
CMessage::Result CMessage::serialize(asio::ip::tcp::socket &socket, bool bOut, string &strError)
131119
{
132120
if (bOut) {
133121
asio::error_code ec;

remote-processor/Message.h

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,9 @@
3636

3737
#include <remote_processor_export.h>
3838

39-
4039
class REMOTE_PROCESSOR_EXPORT CMessage : private utility::NonCopyable
4140
{
4241
public:
43-
4442
enum class MsgType : std::uint8_t
4543
{
4644
ECommandRequest,
@@ -52,7 +50,8 @@ class REMOTE_PROCESSOR_EXPORT CMessage : private utility::NonCopyable
5250
CMessage();
5351
virtual ~CMessage() = default;
5452

55-
enum Result {
53+
enum Result
54+
{
5655
success,
5756
peerDisconnected,
5857
error
@@ -81,32 +80,32 @@ class REMOTE_PROCESSOR_EXPORT CMessage : private utility::NonCopyable
8180
* @param[in] pvData pointer to the data array
8281
* @param[in] uiSize array size in bytes
8382
*/
84-
void writeData(const void* pvData, size_t uiSize);
83+
void writeData(const void *pvData, size_t uiSize);
8584

8685
/** Read raw data from the message
8786
*
8887
* @param[out] pvData pointer to the data array
8988
* @param[in] uiSize array size in bytes
9089
*/
91-
void readData(void* pvData, size_t uiSize);
90+
void readData(void *pvData, size_t uiSize);
9291

9392
/** Write string to the message
9493
*
9594
* @param[in] strData the string to write
9695
*/
97-
void writeString(const std::string& strData);
96+
void writeString(const std::string &strData);
9897

9998
/** Write string to the message
10099
*
101100
* @param[out] strData the string to read to
102101
*/
103-
void readString(std::string& strData);
102+
void readString(std::string &strData);
104103

105104
/** @return string length plus room to store its length
106105
*
107106
* @param[in] strData the string to get the size from
108107
*/
109-
size_t getStringSize(const std::string& strData) const;
108+
size_t getStringSize(const std::string &strData) const;
110109

111110
/** @return remaining data size to read or to write depending on the context
112111
* (request: write, answer: read)

remote-processor/RemoteCommand.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*
1+
/*
22
* Copyright (c) 2011-2014, Intel Corporation
33
* All rights reserved.
44
*
@@ -37,17 +37,17 @@ class IRemoteCommand
3737
{
3838
public:
3939
// Command Name
40-
virtual const std::string& getCommand() const = 0;
40+
virtual const std::string &getCommand() const = 0;
4141

4242
// Arguments
43-
virtual void addArgument(const std::string& strArgument) = 0;
43+
virtual void addArgument(const std::string &strArgument) = 0;
4444
virtual size_t getArgumentCount() const = 0;
45-
virtual const std::string& getArgument(size_t argument) const = 0;
45+
virtual const std::string &getArgument(size_t argument) const = 0;
4646
/** Get all the arguments in a vector
4747
*
4848
* @returns a reference to a vector containing all the arguments.
4949
*/
50-
virtual const std::vector<std::string>& getArguments() const = 0;
50+
virtual const std::vector<std::string> &getArguments() const = 0;
5151
virtual const std::string packArguments(size_t startArgument, size_t nbArguments) const = 0;
5252

5353
protected:

remote-processor/RemoteCommandHandler.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*
1+
/*
22
* Copyright (c) 2011-2014, Intel Corporation
33
* All rights reserved.
44
*
@@ -36,7 +36,8 @@ class IRemoteCommandHandler
3636
{
3737
public:
3838
// Return true on success, fill result in any cases
39-
virtual bool remoteCommandProcess(const IRemoteCommand& remoteCommand, std::string& strResult) = 0;
39+
virtual bool remoteCommandProcess(const IRemoteCommand &remoteCommand,
40+
std::string &strResult) = 0;
4041

4142
virtual ~IRemoteCommandHandler() {}
4243
};

0 commit comments

Comments
 (0)