Spinning Topp Logo BlackTopp Studios
inc
systemaddress.h
1 // © Copyright 2010 - 2016 BlackTopp Studios Inc.
2 /* This file is part of The Mezzanine Engine.
3 
4  The Mezzanine Engine is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  The Mezzanine Engine is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with The Mezzanine Engine. If not, see <http://www.gnu.org/licenses/>.
16 */
17 /* The original authors have included a copy of the license specified above in the
18  'Docs' folder. See 'gpl.txt'
19 */
20 /* We welcome the use of the Mezzanine engine to anyone, including companies who wish to
21  Build professional software and charge for their product.
22 
23  However there are some practical restrictions, so if your project involves
24  any of the following you should contact us and we will try to work something
25  out:
26  - DRM or Copy Protection of any kind(except Copyrights)
27  - Software Patents You Do Not Wish to Freely License
28  - Any Kind of Linking to Non-GPL licensed Works
29  - Are Currently In Violation of Another Copyright Holder's GPL License
30  - If You want to change our code and not add a few hundred MB of stuff to
31  your distribution
32 
33  These and other limitations could cause serious legal problems if you ignore
34  them, so it is best to simply contact us or the Free Software Foundation, if
35  you have any questions.
36 
37  Joseph Toppi - toppij@gmail.com
38  John Blackwood - makoenergy02@gmail.com
39 */
40 
41 #ifndef _networksystemaddress_h
42 #define _networksystemaddress_h
43 
44 #include "Network/ipaddress.h"
45 
46 namespace Mezzanine
47 {
48  namespace Network
49  {
50  ///////////////////////////////////////////////////////////////////////////////
51  /// @brief A simple class that stores a complete set of information for establishing connections.
52  ///////////////////////////////////////
54  {
55  protected:
56  /// @internal
57  /// @brief The IPAddress of the target system.
59  /// @internal
60  /// @brief The (optional) IPv6 Flow value, used for routing IPv6 packets.
62  /// @internal
63  /// @brief The (optional) IPv6 Scope-ID, used to describe the reach of the address.
65  /// @internal
66  /// @brief The open port of the target system.
68  public:
69  ///////////////////////////////////////////////////////////////////////////////
70  // Construction and Destruction
71 
72  /// @brief Class constructor.
73  SystemAddress();
74  /// @brief IP constructor.
75  /// @param TargetAddress The IP address of the target.
76  SystemAddress(const IPAddress& TargetAddress);
77  /// @brief Port constructor.
78  /// @param TargetPort The port of the target in Host-Byte-Order.
79  /// @param NBO Whether or not the passed in port number is already in Network-Byte-Order.
80  SystemAddress(const UInt16 TargetPort, const Boole NBO = false);
81  /// @brief Descriptive constructor.
82  /// @param TargetAddress The IP address of the target.
83  /// @param TargetPort The port of the target in Host-Byte-Order.
84  /// @param NBO Whether or not the passed in port number is already in Network-Byte-Order.
85  SystemAddress(const IPAddress& TargetAddress, const UInt16 TargetPort, const Boole NBO = false);
86  /// @brief Copy constructor.
87  /// @param Other The other SystemAddress to copy from.
88  SystemAddress(const SystemAddress& Other);
89  /// @brief Class destructor.
90  ~SystemAddress();
91 
92  ///////////////////////////////////////////////////////////////////////////////
93  // Utility
94 
95  /// @brief Sets the IP portion of the target system address.
96  /// @param TargetAddress The IP address of the target.
97  void SetAddress(const IPAddress& TargetAddress);
98  /// @brief Gets the IP portion of the target system address.
99  /// @return Returns a const reference to an IPAddress of the target system.
100  const IPAddress& GetAddress() const;
101  /// @brief Gets the IP portion of the target system address.
102  /// @return Returns a const reference to an IPAddress of the target system.
103  IPAddress& GetAddress();
104  /// @brief Sets the flow information to be used.
105  /// @param Flow The flow value to use for determining packet routing.
106  void SetV6Flow(const UInt32 Flow);
107  /// @brief Gets the flow information to be used for routing packets to the target system.
108  /// @return Returns a UInt32 representing the flow information for IPv6 transmissions.
109  UInt32 GetV6Flow() const;
110  /// @brief Sets the scope-id for the address.
111  /// @param Scope The scope-id to be used for local IPv6 devices.
112  void SetV6Scope(const UInt32 Scope);
113  /// @brief Gets the scope-id for the address.
114  /// @return Returns a UInt32 representing the scope-id for the IPv6 address.
115  UInt32 GetV6Scope() const;
116  /// @brief Sets the Port portion of the target system address.
117  /// @param TargetPort The port of the target.
118  /// @param NBO Whether or not the passed in port number is already in Network-Byte-Order.
119  void SetPort(const UInt16 TargetPort, const Boole NBO = false);
120  /// @brief Gets the Port portion of the target system address.
121  /// @param NBO Whether or not the returned port number should be returned in Network-Byte-Order.
122  /// @return Returns a UInt16 storing the port of the target system.
123  UInt16 GetPort(const Boole NBO = false) const;
124 
125  ///////////////////////////////////////////////////////////////////////////////
126  // Operators
127 
128  /// @brief Assignment operator.
129  /// @param Other The other SystemAddress to be copied from.
130  void operator=(const SystemAddress& Other);
131 
132  /// @brief Equality operator.
133  /// @param Other The other SystemAddress to compare to.
134  /// @return Returns true if the two SystemAddress' are identical, false otherwise.
135  Boole operator==(const SystemAddress& Other) const;
136  /// @brief Inequality operator.
137  /// @param Other The other SystemAddress to compare to.
138  /// @return Returns false if the two SystemAddress' are identical, true otherwise.
139  Boole operator!=(const SystemAddress& Other) const;
140 
141  ///////////////////////////////////////////////////////////////////////////////
142  // Serialization
143 
144  /// @brief Convert this class to an XML::Node ready for serialization.
145  /// @param ParentNode The point in the XML hierarchy that this SystemAddress should be appended to.
146  void ProtoSerialize(XML::Node& ParentNode) const;
147  /// @brief Take the data stored in an XML Node and overwrite this object with it.
148  /// @param SelfRoot An XML::Node containing the data to populate this class with.
149  void ProtoDeSerialize(const XML::Node& SelfRoot);
150 
151  /// @brief Get the name of the the XML tag the SystemAddress class will leave behind as its instances are serialized.
152  /// @return A string containing the name of this class.
153  static String GetSerializableName();
154  };//SystemAddress
155  }//Network
156 }//Mezzanine
157 
158 #endif
bool Boole
Generally acts a single bit, true or false.
Definition: datatypes.h:173
UInt32 V6Flow
The (optional) IPv6 Flow value, used for routing IPv6 packets.
Definition: systemaddress.h:61
uint16_t UInt16
An 16-bit unsigned integer.
Definition: datatypes.h:122
A light-weight handle for manipulating nodes in DOM tree.
Definition: node.h:89
uint32_t UInt32
An 32-bit unsigned integer.
Definition: datatypes.h:126
This is a simple class for representing IP addresses used throughout the Network subsystem.
Definition: ipaddress.h:57
UInt32 V6Scope
The (optional) IPv6 Scope-ID, used to describe the reach of the address.
Definition: systemaddress.h:64
IPAddress Address
The IPAddress of the target system.
Definition: systemaddress.h:58
UInt16 Port
The open port of the target system.
Definition: systemaddress.h:67
#define MEZZ_LIB
Some platforms require special decorations to denote what is exported/imported in a share library...
The bulk of the engine components go in this namspace.
Definition: actor.cpp:56
std::string String
A datatype used to a series of characters.
Definition: datatypes.h:159
A simple class that stores a complete set of information for establishing connections.
Definition: systemaddress.h:53