[Bug 1551] Redux: NS_LOG_COMPONENT_DEFINE inside or outside of ns3 namespace?

This commit is contained in:
Peter D. Barnes, Jr.
2014-09-26 15:51:00 -07:00
parent 3611bd11a5
commit bfdb6ef10a
675 changed files with 1328 additions and 1354 deletions

View File

@@ -21,10 +21,10 @@
#include "inet-socket-address.h"
#include "ns3/log.h"
NS_LOG_COMPONENT_DEFINE ("AddressUtils");
namespace ns3 {
NS_LOG_COMPONENT_DEFINE ("AddressUtils");
void WriteTo (Buffer::Iterator &i, Ipv4Address ad)
{
NS_LOG_FUNCTION (&i << &ad);

View File

@@ -23,10 +23,15 @@
#include "ns3/fatal-error.h"
#include "ns3/log.h"
namespace ns3 {
NS_LOG_COMPONENT_DEFINE ("DataRate");
static bool
DoParse (const std::string s, uint64_t *v)
ATTRIBUTE_HELPER_CPP (DataRate); //!< Macro to make help make data-rate an ns-3 attribute
/* static */
bool
DataRate::DoParse (const std::string s, uint64_t *v)
{
NS_LOG_FUNCTION (s << v);
std::string::size_type n = s.find_first_not_of ("0123456789.");
@@ -179,11 +184,6 @@ DoParse (const std::string s, uint64_t *v)
return true;
}
namespace ns3 {
ATTRIBUTE_HELPER_CPP (DataRate); //!< Macro to make help make data-rate an ns-3 attribute
DataRate::DataRate ()
: m_bps (0)
{
@@ -260,7 +260,7 @@ std::istream &operator >> (std::istream &is, DataRate &rate)
std::string value;
is >> value;
uint64_t v;
bool ok = DoParse (value, &v);
bool ok = DataRate::DoParse (value, &v);
if (!ok)
{
is.setstate (std::ios_base::failbit);

View File

@@ -159,6 +159,26 @@ public:
uint64_t GetBitRate () const;
private:
/**
* \brief Parse a string representing a DataRate into an uint64_t
*
* Allowed unit representations include all combinations of
*
* * An SI prefix: k, K, M, G
* * Decimal or kibibit (as in "Kibps", meaning 1024 bps)
* * Bits or bytes (8 bits)
* * "bps" or "/s"
*
* \param [in] s The string representation, including unit
* \param [in,out] v The location to put the value, in bits/sec.
* \return true if parsing was successful.
*/
static bool DoParse (const std::string s, uint64_t *v);
// Uses DoParse
friend std::istream &operator >> (std::istream &is, DataRate &rate);
uint64_t m_bps; //!< data rate [bps]
};

View File

@@ -21,10 +21,10 @@
#include "ns3/uinteger.h"
#include "drop-tail-queue.h"
NS_LOG_COMPONENT_DEFINE ("DropTailQueue");
namespace ns3 {
NS_LOG_COMPONENT_DEFINE ("DropTailQueue");
NS_OBJECT_ENSURE_REGISTERED (DropTailQueue);
TypeId DropTailQueue::GetTypeId (void)

View File

@@ -73,10 +73,10 @@
#include "ns3/string.h"
#include "ns3/pointer.h"
NS_LOG_COMPONENT_DEFINE ("ErrorModel");
namespace ns3 {
NS_LOG_COMPONENT_DEFINE ("ErrorModel");
NS_OBJECT_ENSURE_REGISTERED (ErrorModel);
TypeId ErrorModel::GetTypeId (void)

View File

@@ -26,10 +26,10 @@
#include "ethernet-header.h"
#include "address-utils.h"
NS_LOG_COMPONENT_DEFINE ("EthernetHeader");
namespace ns3 {
NS_LOG_COMPONENT_DEFINE ("EthernetHeader");
NS_OBJECT_ENSURE_REGISTERED (EthernetHeader);
EthernetHeader::EthernetHeader (bool hasPreamble)

View File

@@ -24,10 +24,10 @@
#include "ethernet-trailer.h"
#include "crc32.h"
NS_LOG_COMPONENT_DEFINE ("EthernetTrailer");
namespace ns3 {
NS_LOG_COMPONENT_DEFINE ("EthernetTrailer");
NS_OBJECT_ENSURE_REGISTERED (EthernetTrailer);
EthernetTrailer::EthernetTrailer ()

View File

@@ -20,10 +20,10 @@
#include "flow-id-tag.h"
#include "ns3/log.h"
NS_LOG_COMPONENT_DEFINE ("FlowIdTag");
namespace ns3 {
NS_LOG_COMPONENT_DEFINE ("FlowIdTag");
NS_OBJECT_ENSURE_REGISTERED (FlowIdTag);
TypeId

View File

@@ -22,10 +22,10 @@
#include "ns3/assert.h"
#include "ns3/log.h"
NS_LOG_COMPONENT_DEFINE ("InetSocketAddress");
namespace ns3 {
NS_LOG_COMPONENT_DEFINE ("InetSocketAddress");
InetSocketAddress::InetSocketAddress (Ipv4Address ipv4, uint16_t port)
: m_ipv4 (ipv4),
m_port (port)

View File

@@ -22,11 +22,11 @@
#include "inet6-socket-address.h"
#include "ns3/log.h"
NS_LOG_COMPONENT_DEFINE ("Inet6SocketAddress");
namespace ns3
{
NS_LOG_COMPONENT_DEFINE ("Inet6SocketAddress");
Inet6SocketAddress::Inet6SocketAddress (Ipv6Address ipv6, uint16_t port)
: m_ipv6 (ipv6),
m_port (port)

View File

@@ -23,10 +23,10 @@
#include "ipv4-address.h"
#include "ns3/assert.h"
NS_LOG_COMPONENT_DEFINE ("Ipv4Address");
namespace ns3 {
NS_LOG_COMPONENT_DEFINE ("Ipv4Address");
#define ASCII_DOT (0x2e)
#define ASCII_ZERO (0x30)
#define ASCII_SLASH (0x2f)

View File

@@ -52,10 +52,10 @@
#include "mac64-address.h"
#include "ipv6-address.h"
NS_LOG_COMPONENT_DEFINE ("Ipv6Address");
namespace ns3 {
NS_LOG_COMPONENT_DEFINE ("Ipv6Address");
#ifdef __cplusplus
extern "C"
{ /* } */

View File

@@ -23,10 +23,10 @@
#include "ns3/log.h"
#include <string>
NS_LOG_COMPONENT_DEFINE ("LlcSnalHeader");
namespace ns3 {
NS_LOG_COMPONENT_DEFINE ("LlcSnalHeader");
NS_OBJECT_ENSURE_REGISTERED (LlcSnapHeader);
LlcSnapHeader::LlcSnapHeader ()

View File

@@ -26,10 +26,10 @@
#include <iostream>
#include <cstring>
NS_LOG_COMPONENT_DEFINE ("Mac16Address");
namespace ns3 {
NS_LOG_COMPONENT_DEFINE ("Mac16Address");
ATTRIBUTE_HELPER_CPP (Mac16Address); //!< Macro to make help make class an ns-3 attribute
#define ASCII_a (0x41)

View File

@@ -25,10 +25,10 @@
#include <iostream>
#include <cstring>
NS_LOG_COMPONENT_DEFINE ("Mac48Address");
namespace ns3 {
NS_LOG_COMPONENT_DEFINE ("Mac48Address");
ATTRIBUTE_HELPER_CPP (Mac48Address); //!< Macro to make help make class an ns-3 attribute
#define ASCII_a (0x41)

View File

@@ -25,10 +25,10 @@
#include <iostream>
#include <cstring>
NS_LOG_COMPONENT_DEFINE ("Mac64Address");
namespace ns3 {
NS_LOG_COMPONENT_DEFINE ("Mac64Address");
ATTRIBUTE_HELPER_CPP (Mac64Address); //!< Macro to make help make class an ns-3 attribute
#define ASCII_a (0x41)

View File

@@ -22,10 +22,10 @@
#include "ns3/abort.h"
#include <fstream>
NS_LOG_COMPONENT_DEFINE ("OutputStreamWrapper");
namespace ns3 {
NS_LOG_COMPONENT_DEFINE ("OutputStreamWrapper");
OutputStreamWrapper::OutputStreamWrapper (std::string filename, std::ios::openmode filemode)
: m_destroyable (true)
{

View File

@@ -24,10 +24,10 @@
#include "packet-burst.h"
#include "ns3/log.h"
NS_LOG_COMPONENT_DEFINE ("PacketBurst");
namespace ns3 {
NS_LOG_COMPONENT_DEFINE ("PacketBurst");
NS_OBJECT_ENSURE_REGISTERED (PacketBurst);
TypeId

View File

@@ -29,7 +29,6 @@ using namespace ns3;
NS_LOG_COMPONENT_DEFINE ("PacketDataCalculators");
//--------------------------------------------------------------
//----------------------------------------------
PacketCounterCalculator::PacketCounterCalculator()

View File

@@ -28,10 +28,10 @@
#include "ns3/config.h"
#include "ns3/trace-source-accessor.h"
NS_LOG_COMPONENT_DEFINE ("PacketProbe");
namespace ns3 {
NS_LOG_COMPONENT_DEFINE ("PacketProbe");
NS_OBJECT_ENSURE_REGISTERED (PacketProbe);
TypeId

View File

@@ -21,10 +21,10 @@
#include "ns3/net-device.h"
#include "ns3/log.h"
NS_LOG_COMPONENT_DEFINE ("PacketSocketAddress");
namespace ns3 {
NS_LOG_COMPONENT_DEFINE ("PacketSocketAddress");
PacketSocketAddress::PacketSocketAddress ()
{
NS_LOG_FUNCTION (this);

View File

@@ -33,10 +33,10 @@
#include <cstdlib>
#include <cstdio>
NS_LOG_COMPONENT_DEFINE ("PacketSocketClient");
namespace ns3 {
NS_LOG_COMPONENT_DEFINE ("PacketSocketClient");
NS_OBJECT_ENSURE_REGISTERED (PacketSocketClient);
TypeId

View File

@@ -22,10 +22,10 @@
#include "ns3/log.h"
#include "packet-socket.h"
NS_LOG_COMPONENT_DEFINE ("PacketSocketFactory");
namespace ns3 {
NS_LOG_COMPONENT_DEFINE ("PacketSocketFactory");
NS_OBJECT_ENSURE_REGISTERED (PacketSocketFactory);
TypeId

View File

@@ -33,10 +33,10 @@
#include <cstdlib>
#include <cstdio>
NS_LOG_COMPONENT_DEFINE ("PacketSocketServer");
namespace ns3 {
NS_LOG_COMPONENT_DEFINE ("PacketSocketServer");
NS_OBJECT_ENSURE_REGISTERED (PacketSocketServer);
TypeId

View File

@@ -29,10 +29,10 @@
#include <algorithm>
NS_LOG_COMPONENT_DEFINE ("PacketSocket");
namespace ns3 {
NS_LOG_COMPONENT_DEFINE ("PacketSocket");
NS_OBJECT_ENSURE_REGISTERED (PacketSocket);
TypeId

View File

@@ -28,8 +28,6 @@
#include "ns3/log.h"
#include "packetbb.h"
NS_LOG_COMPONENT_DEFINE ("PacketBB");
static const uint8_t VERSION = 0;
/* Packet flags */
static const uint8_t PHAS_SEQ_NUM = 0x8;
@@ -58,6 +56,8 @@ static const uint8_t TIS_MULTIVALUE = 0x04;
namespace ns3 {
NS_LOG_COMPONENT_DEFINE ("PacketBB");
NS_OBJECT_ENSURE_REGISTERED (PbbPacket);
PbbTlvBlock::PbbTlvBlock (void)

View File

@@ -22,10 +22,10 @@
#include "ns3/header.h"
#include "pcap-file-wrapper.h"
NS_LOG_COMPONENT_DEFINE ("PcapFileWrapper");
namespace ns3 {
NS_LOG_COMPONENT_DEFINE ("PcapFileWrapper");
NS_OBJECT_ENSURE_REGISTERED (PcapFileWrapper);
TypeId

View File

@@ -33,10 +33,10 @@
// adding any ns-3 specific constructs such as Packet to this file.
//
NS_LOG_COMPONENT_DEFINE ("PcapFile");
namespace ns3 {
NS_LOG_COMPONENT_DEFINE ("PcapFile");
const uint32_t MAGIC = 0xa1b2c3d4; /**< Magic number identifying standard pcap file format */
const uint32_t SWAPPED_MAGIC = 0xd4c3b2a1; /**< Looks this way if byte swapping is required */

View File

@@ -20,10 +20,10 @@
#include "ns3/trace-source-accessor.h"
#include "queue.h"
NS_LOG_COMPONENT_DEFINE ("Queue");
namespace ns3 {
NS_LOG_COMPONENT_DEFINE ("Queue");
NS_OBJECT_ENSURE_REGISTERED (Queue);
TypeId

View File

@@ -23,10 +23,10 @@
#include "ns3/log.h"
#include "radiotap-header.h"
NS_LOG_COMPONENT_DEFINE ("RadiotapHeader");
namespace ns3 {
NS_LOG_COMPONENT_DEFINE ("RadiotapHeader");
NS_OBJECT_ENSURE_REGISTERED (RadiotapHeader);
RadiotapHeader::RadiotapHeader()

View File

@@ -65,10 +65,10 @@
#include "ns3/random-variable-stream.h"
#include "red-queue.h"
NS_LOG_COMPONENT_DEFINE ("RedQueue");
namespace ns3 {
NS_LOG_COMPONENT_DEFINE ("RedQueue");
NS_OBJECT_ENSURE_REGISTERED (RedQueue);
TypeId RedQueue::GetTypeId (void)

View File

@@ -24,10 +24,10 @@
#include "ns3/node.h"
#include "ns3/log.h"
NS_LOG_COMPONENT_DEFINE ("SimpleChannel");
namespace ns3 {
NS_LOG_COMPONENT_DEFINE ("SimpleChannel");
NS_OBJECT_ENSURE_REGISTERED (SimpleChannel);
TypeId

View File

@@ -30,10 +30,10 @@
#include "ns3/simulator.h"
#include "ns3/drop-tail-queue.h"
NS_LOG_COMPONENT_DEFINE ("SimpleNetDevice");
namespace ns3 {
NS_LOG_COMPONENT_DEFINE ("SimpleNetDevice");
/**
* \brief Internal tag to store source, destination and protocol of each packet.
*/