00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 00012 00013 00014 00015 00016 00017 00018 00019 00020 00021 00022 00023 00024 00025 00026 00027 00028 00029 00030 00031 00032 00033 00034 00035 00036 00037 00038 00039 00040 #include "jaus/core/control/setauthority.h" 00041 00042 using namespace JAUS; 00043 00044 00053 SetAuthority::SetAuthority(const Address& dest, const Address& src) : Message(SET_AUTHORITY, dest, src) 00054 { 00055 mAuthorityCode = 0; 00056 } 00057 00058 00064 SetAuthority::SetAuthority(const SetAuthority& message) : Message(SET_AUTHORITY) 00065 { 00066 *this = message; 00067 } 00068 00069 00075 SetAuthority::~SetAuthority() 00076 { 00077 } 00078 00079 00091 int SetAuthority::WriteMessageBody(Packet& packet) const 00092 { 00093 int expected = BYTE_SIZE; 00094 int written = 0; 00095 00096 written += packet.Write(mAuthorityCode); 00097 00098 return expected == written ? written : -1; 00099 } 00100 00101 00113 int SetAuthority::ReadMessageBody(const Packet& packet) 00114 { 00115 int expected = BYTE_SIZE; 00116 int read = 0; 00117 00118 read += packet.Read(mAuthorityCode); 00119 00120 return expected == read ? read : -1; 00121 } 00122 00123 00129 void SetAuthority::ClearMessageBody() 00130 { 00131 mAuthorityCode = 0; 00132 } 00133 00134 00142 int SetAuthority::RunTestCase() const 00143 { 00144 int result = 0; 00145 00146 Packet packet; 00147 SetAuthority msg1, msg2; 00148 msg1.SetAuthorityCode(1); 00149 00150 if( msg1.WriteMessageBody(packet) != -1 && 00151 msg2.ReadMessageBody(packet) != -1 && 00152 msg1.GetAuthorityCode() == msg2.GetAuthorityCode()) 00153 { 00154 result = 1; 00155 } 00156 00157 return result; 00158 } 00159 00160 00166 SetAuthority& SetAuthority::operator=(const SetAuthority& message) 00167 { 00168 if(this != &message) 00169 { 00170 CopyHeaderData(&message); 00171 mAuthorityCode = message.mAuthorityCode; 00172 } 00173 return *this; 00174 } 00175 00176 00177 /* End of File */