Home | History | Annotate | Download | only in message
      1 // Copyright 2012 Google Inc. All Rights Reserved.
      2 //
      3 // Licensed under the Apache License, Version 2.0 (the "License");
      4 // you may not use this file except in compliance with the License.
      5 // You may obtain a copy of the License at
      6 //
      7 //     http://www.apache.org/licenses/LICENSE-2.0
      8 //
      9 // Unless required by applicable law or agreed to in writing, software
     10 // distributed under the License is distributed on an "AS IS" BASIS,
     11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     12 // See the License for the specific language governing permissions and
     13 // limitations under the License.
     14 
     15 #ifndef POLO_PAIRING_MESSAGE_POLOMESSAGE_H_
     16 #define POLO_PAIRING_MESSAGE_POLOMESSAGE_H_
     17 
     18 #include <string>
     19 #include "polo/util/macros.h"
     20 
     21 namespace polo {
     22 namespace pairing {
     23 namespace message {
     24 
     25 // An abstract polo message.
     26 class PoloMessage {
     27  public:
     28   // The possible polo message types.
     29   enum PoloMessageType {
     30     kUnknown = 0,
     31     kPairingRequest = 10,
     32     kPairingRequestAck = 11,
     33     kOptions = 20,
     34     kConfiguration = 30,
     35     kConfigurationAck = 31,
     36     kSecret = 40,
     37     kSecretAck = 41,
     38   };
     39 
     40   // Creates a new polo message of the given message type. Subclasses should
     41   // provided their corresponding message type.
     42   // @param message_type the type of this message
     43   explicit PoloMessage(PoloMessageType message_type);
     44 
     45   virtual ~PoloMessage() {}
     46 
     47   // Gets the type of this message.
     48   PoloMessageType message_type() const;
     49 
     50   // Gets a string representation of this message.
     51   virtual std::string ToString() const = 0;
     52 
     53  private:
     54   PoloMessageType message_type_;
     55 
     56   DISALLOW_COPY_AND_ASSIGN(PoloMessage);
     57 };
     58 
     59 }  // namespace message
     60 }  // namespace pairing
     61 }  // namespace polo
     62 
     63 #endif  // POLO_PAIRING_MESSAGE_POLOMESSAGE_H_
     64