Skip to content
This repository has been archived by the owner on Aug 9, 2019. It is now read-only.

Commit

Permalink
refactor: rename INTERNAL_START to INTERNAL_SEND_START
Browse files Browse the repository at this point in the history
  • Loading branch information
larroy committed May 12, 2014
1 parent a76db64 commit 1d0d0fa
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 21 deletions.
15 changes: 9 additions & 6 deletions src/cs/core/coder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ void decode(const jsoncons::json& json, Unknown& msg)
msg.m_content = json_os.str();
}

void decode(const jsoncons::json& json, InternalStart& msg)
void decode(const jsoncons::json& json, InternalSendStart& msg)
{
msg.m_share_id = json["share_id"].as_string();
}

void decode(const jsoncons::json& json, Ping& msg)
Expand Down Expand Up @@ -228,9 +229,11 @@ void encode(const Unknown& msg, jsoncons::json& json)
assert(0);
}

void encode(const InternalStart& msg, jsoncons::json& json)
void encode(const InternalSendStart& msg, jsoncons::json& json)
{
using namespace jsoncons;
encode_type(msg, json);
json["share_id"] = msg.m_share_id;
}

void encode(const Ping& msg, jsoncons::json& json)
Expand Down Expand Up @@ -434,7 +437,7 @@ friend class Message;

protected:
void visit(const Unknown&) override;
void visit(const InternalStart&) override;
void visit(const InternalSendStart&) override;
void visit(const Ping&) override;
void visit(const Greeting&) override;
void visit(const Start&) override;
Expand Down Expand Up @@ -469,9 +472,9 @@ try
unique_ptr<Message> msg;
switch(type)
{
case MType::INTERNAL_START:
case MType::INTERNAL_SEND_START:
{
auto xmsg = make_unique<InternalStart>();
auto xmsg = make_unique<InternalSendStart>();
decode(json, *xmsg);
msg = move(xmsg);
break;
Expand Down Expand Up @@ -698,7 +701,7 @@ void JSONCoder::visit(const Unknown&)
assert(0);
}

void JSONCoder::visit(const InternalStart& x)
void JSONCoder::visit(const InternalSendStart& x)
{
ENCXX;
}
Expand Down
6 changes: 3 additions & 3 deletions src/cs/core/message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ mtype_str_table_t mtype_str_table_init()
{
mtype_str_table_t res;
res[SC(MType::UNKNOWN)] = "unknown";
res[SC(MType::INTERNAL_START)] = "__internal_start";
res[SC(MType::INTERNAL_SEND_START)] = "__internal_send_start";
res[SC(MType::PING)] = "ping";
res[SC(MType::GREETING)] = "greeting";
res[SC(MType::START)] = "start";
Expand Down Expand Up @@ -72,8 +72,8 @@ MType mtype_from_string(const std::string& type)
if (type == "unknown")
return MType::UNKNOWN;

if (type == "__internal_start")
return MType::INTERNAL_START;
if (type == "__internal_send_start")
return MType::INTERNAL_SEND_START;

if (type == "ping")
return MType::PING;
Expand Down
10 changes: 5 additions & 5 deletions src/cs/core/message.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ enum class MType: unsigned
UNKNOWN = 0,

// Internal messages
INTERNAL_START,
INTERNAL_SEND_START,

PING,
GREETING,
Expand Down Expand Up @@ -97,7 +97,7 @@ struct MFile

// forward declaration of message classes to avoid circular dependency below
class Unknown;
class InternalStart;
class InternalSendStart;
class Ping;
class Greeting;
class Start;
Expand All @@ -121,7 +121,7 @@ class ConstMessageVisitor
public:
virtual ~ConstMessageVisitor() {};
virtual void visit(const Unknown&) = 0;
virtual void visit(const InternalStart&) = 0;
virtual void visit(const InternalSendStart&) = 0;
virtual void visit(const Ping&) = 0;
virtual void visit(const Greeting&) = 0;
virtual void visit(const Start&) = 0;
Expand All @@ -146,7 +146,7 @@ class MutatingMessageVisitor
public:
virtual ~MutatingMessageVisitor() {};
virtual void visit(Unknown&) = 0;
virtual void visit(InternalStart&) = 0;
virtual void visit(InternalSendStart&) = 0;
virtual void visit(Ping&) = 0;
virtual void visit(Greeting&) = 0;
virtual void visit(Start&) = 0;
Expand Down Expand Up @@ -245,7 +245,7 @@ class Unknown: public MessageImpl<Unknown, MType::UNKNOWN>
/**
* Internal message to start the ClearSkiesProtocol and send a greeting
*/
class InternalStart: public MessageImpl<InternalStart, MType::INTERNAL_START>
class InternalSendStart: public MessageImpl<InternalSendStart, MType::INTERNAL_SEND_START>
{
public:
/// the share id of the initiated connection
Expand Down
2 changes: 1 addition & 1 deletion src/cs/core/protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class MessageHandler_INITIAL: public MessageHandler
throw;
}

void visit(const msg::InternalStart& msg) override
void visit(const msg::InternalSendStart& msg) override
{
share::Share& share = r_protocol.share(msg.m_share_id);
UNUSED(share);
Expand Down
2 changes: 1 addition & 1 deletion src/cs/core/protocol.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class MessageHandler: public msg::ConstMessageVisitor
{
throw ProtocolError(fs("Can't handle message type Unknown on state: " << static_cast<unsigned>(m_state)));
}
void visit(const msg::InternalStart&) override
void visit(const msg::InternalSendStart&) override
{
throw ProtocolError(fs("Can't handle message type Unknown on state: " << static_cast<unsigned>(m_state)));
}
Expand Down
10 changes: 5 additions & 5 deletions test/message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ using namespace cs::core::msg;
BOOST_AUTO_TEST_CASE(MessageTest_type_from_str)
{
BOOST_CHECK(mtype_from_string("unknown") == MType::UNKNOWN);
BOOST_CHECK(mtype_from_string("__internal_start") == MType::INTERNAL_START);
BOOST_CHECK(mtype_from_string("__internal_send_start") == MType::INTERNAL_SEND_START);
BOOST_CHECK(mtype_from_string("ping") == MType::PING);
BOOST_CHECK(mtype_from_string("greeting") == MType::GREETING);
BOOST_CHECK(mtype_from_string("start") == MType::START);
Expand All @@ -45,7 +45,7 @@ BOOST_AUTO_TEST_CASE(MessageTest_type_from_str)
BOOST_AUTO_TEST_CASE(MessageTest_type_to_str)
{
BOOST_CHECK(mtype_to_string(MType::UNKNOWN) == "unknown");
BOOST_CHECK(mtype_to_string(MType::INTERNAL_START) == "__internal_start");
BOOST_CHECK(mtype_to_string(MType::INTERNAL_SEND_START) == "__internal_send_start");
BOOST_CHECK(mtype_to_string(MType::PING) == "ping");
BOOST_CHECK(mtype_to_string(MType::GREETING) == "greeting");
BOOST_CHECK(mtype_to_string(MType::START) == "start");
Expand Down Expand Up @@ -89,10 +89,10 @@ BOOST_AUTO_TEST_CASE(MessageTest_type_unknown_defaults)
check_message_defaults(m, MType::UNKNOWN);
}

BOOST_AUTO_TEST_CASE(MessageTest_type_internal_start_defaults)
BOOST_AUTO_TEST_CASE(MessageTest_type_internal_send_start_defaults)
{
InternalStart m;
check_message_defaults(m, MType::INTERNAL_START);
InternalSendStart m;
check_message_defaults(m, MType::INTERNAL_SEND_START);
}

BOOST_AUTO_TEST_CASE(MessageTest_type_ping_defaults)
Expand Down

0 comments on commit 1d0d0fa

Please sign in to comment.