diff --git a/samples/main-callback.cc b/samples/main-callback.cc index 13d298d52..ca409def2 100644 --- a/samples/main-callback.cc +++ b/samples/main-callback.cc @@ -6,16 +6,16 @@ using namespace ns3; static double -cb_one (double a, double b) +cbOne (double a, double b) { - std::cout << "invoke cb_one a=" << a << ", b=" << b << std::endl; + std::cout << "invoke cbOne a=" << a << ", b=" << b << std::endl; return a; } class MyCb { public: - int cb_two (double a) { - std::cout << "invoke cb_two a=" << a << std::endl; + int cbTwo (double a) { + std::cout << "invoke cbTwo a=" << a << std::endl; return -5; } }; @@ -27,32 +27,32 @@ int main (int argc, char *argv[]) // first arg type: double // second arg type: double Callback one; - // build callback instance which points to cb_one function - one = make_callback (&cb_one); + // build callback instance which points to cbOne function + one = makeCallback (&cbOne); // this is not a null callback - assert (!one.is_null ()); - // invoke cb_one function through callback instance - double ret_one; - ret_one = one (10.0, 20.0); + assert (!one.isNull ()); + // invoke cbOne function through callback instance + double retOne; + retOne = one (10.0, 20.0); // return type: int // first arg type: double Callback two; MyCb cb; - // build callback instance which points to MyCb::cb_two - two = make_callback (&MyCb::cb_two, &cb); + // build callback instance which points to MyCb::cbTwo + two = makeCallback (&MyCb::cbTwo, &cb); // this is not a null callback - assert (!two.is_null ()); - // invoke MyCb::cb_two through callback instance - int ret_two; - ret_two = two (10.0); + assert (!two.isNull ()); + // invoke MyCb::cbTwo through callback instance + int retTwo; + retTwo = two (10.0); - two = make_null_callback (); + two = makeNullCallback (); // invoking a null callback is just like // invoking a null function pointer: // it will crash. - //int ret_two_null = two (20.0); - assert (two.is_null ()); + //int retTwoNull = two (20.0); + assert (two.isNull ()); return 0; } diff --git a/samples/main-packet.cc b/samples/main-packet.cc index f3b4540bf..e9088f05f 100644 --- a/samples/main-packet.cc +++ b/samples/main-packet.cc @@ -12,13 +12,13 @@ public: MyChunk (); virtual ~MyChunk (); - void set_data (uint16_t data); - uint16_t get_data (void) const; + void setData (uint16_t data); + uint16_t getData (void) const; private: virtual void print (std::ostream *os) const; - virtual void add_to (Buffer *buffer) const; - virtual void peek_from (Buffer const *buffer); - virtual void remove_from (Buffer *buffer); + virtual void addTo (Buffer *buffer) const; + virtual void peekFrom (Buffer const *buffer); + virtual void removeFrom (Buffer *buffer); uint16_t m_data; }; @@ -33,35 +33,35 @@ MyChunk::print (std::ostream *os) const *os << "MyChunk data=" << m_data << std::endl; } void -MyChunk::add_to (Buffer *buffer) const +MyChunk::addTo (Buffer *buffer) const { // reserve 2 bytes at head of buffer - buffer->add_at_start (2); + buffer->addAtStart (2); Buffer::Iterator i = buffer->begin (); // serialize in head of buffer - i.write_hton_u16 (m_data); + i.writeHtonU16 (m_data); } void -MyChunk::peek_from (Buffer const *buffer) +MyChunk::peekFrom (Buffer const *buffer) { Buffer::Iterator i = buffer->begin (); // deserialize from head of buffer - m_data = i.read_ntoh_u16 (); + m_data = i.readNtohU16 (); } void -MyChunk::remove_from (Buffer *buffer) +MyChunk::removeFrom (Buffer *buffer) { // remove deserialized data - buffer->remove_at_start (2); + buffer->removeAtStart (2); } void -MyChunk::set_data (uint16_t data) +MyChunk::setData (uint16_t data) { m_data = data; } uint16_t -MyChunk::get_data (void) const +MyChunk::getData (void) const { return m_data; } @@ -79,9 +79,9 @@ receive (Packet p) MyChunk my; p.peek (&my); p.remove (&my); - std::cout << "received data=" << my.get_data () << std::endl; - struct MyTag my_tag; - p.peek_tag (&my_tag); + std::cout << "received data=" << my.getData () << std::endl; + struct MyTag myTag; + p.peekTag (&myTag); } @@ -89,12 +89,12 @@ int main (int argc, char *argv[]) { Packet p; MyChunk my; - my.set_data (2); + my.setData (2); std::cout << "send data=2" << std::endl; p.add (&my); - struct MyTag my_tag; - my_tag.m_streamId = 5; - p.add_tag (&my_tag); + struct MyTag myTag; + myTag.m_streamId = 5; + p.addTag (&myTag); receive (p); return 0; } diff --git a/samples/main-simulator.cc b/samples/main-simulator.cc index d0636805d..6fb87f46f 100644 --- a/samples/main-simulator.cc +++ b/samples/main-simulator.cc @@ -9,18 +9,18 @@ class MyModel { public: void start (void); private: - void deal_with_event (double event_value); + void dealWithEvent (double eventValue); }; void MyModel::start (void) { - Simulator::schedule (Time::rel_s (10.0), - &MyModel::deal_with_event, + Simulator::schedule (Time::relS (10.0), + &MyModel::dealWithEvent, this, Simulator::now ().s ()); } void -MyModel::deal_with_event (double value) +MyModel::dealWithEvent (double value) { std::cout << "Member method received event at " << Simulator::now ().s () << "s started at " << value << "s" << std::endl; @@ -39,7 +39,7 @@ int main (int argc, char *argv[]) { MyModel model; - Simulator::schedule (Time::abs_s (10.0), &random_function, &model); + Simulator::schedule (Time::absS (10.0), &random_function, &model); Simulator::run (); diff --git a/samples/main-trace.cc b/samples/main-trace.cc index 0c783f155..17b2c6c47 100644 --- a/samples/main-trace.cc +++ b/samples/main-trace.cc @@ -15,15 +15,15 @@ StreamTracer c; CallbackTracer d; void -register_all_trace_sources (TraceContainer *container) +registerAllTraceSources (TraceContainer *container) { - container->register_callback ("source-a", &a); - container->register_ui_variable ("source-b", &b); - container->register_stream ("source-c", &c); - container->register_callback ("source-d", &d); + container->registerCallback ("source-a", &a); + container->registerUiVariable ("source-b", &b); + container->registerStream ("source-c", &c); + container->registerCallback ("source-d", &d); } void -generate_trace_events (void) +generateTraceEvents (void) { // log en empty packet a (Packet ()); @@ -36,26 +36,26 @@ generate_trace_events (void) } void -variable_event (uint64_t old, uint64_t cur) +variableEvent (uint64_t old, uint64_t cur) {} void -callback_event (double a, int b) +callbackEvent (double a, int b) {} int main (int argc, char *argv[]) { TraceContainer traces; - register_all_trace_sources (&traces); + registerAllTraceSources (&traces); PcapWriter pcap; pcap.open ("trace-test.log"); - pcap.write_header_ethernet (); - traces.set_callback ("source-a", - make_callback (&PcapWriter::write_packet, &pcap)); - traces.set_ui_variable_callback ("source-b", make_callback (&variable_event)); - traces.set_stream ("source-c", &std::cout); - traces.set_callback ("source-d", make_callback (&callback_event)); - generate_trace_events (); + pcap.writeHeaderEthernet (); + traces.setCallback ("source-a", + makeCallback (&PcapWriter::writePacket, &pcap)); + traces.setUiVariableCallback ("source-b", makeCallback (&variableEvent)); + traces.setStream ("source-c", &std::cout); + traces.setCallback ("source-d", makeCallback (&callbackEvent)); + generateTraceEvents (); return 0; } diff --git a/src/common/buffer.cc b/src/common/buffer.cc index 364351db7..f90ae16d7 100644 --- a/src/common/buffer.cc +++ b/src/common/buffer.cc @@ -32,18 +32,18 @@ uint32_t Buffer::m_maxTotalAddStart = 0; uint32_t Buffer::m_maxTotalAddEnd = 0; struct Buffer::BufferData * -Buffer::allocate (uint32_t req_size, uint32_t req_start) +Buffer::allocate (uint32_t reqSize, uint32_t reqStart) { - if (req_size == 0) { - req_size = 1; + if (reqSize == 0) { + reqSize = 1; } - assert (req_size >= 1); - uint32_t size = req_size - 1 + sizeof (struct Buffer::BufferData); + assert (reqSize >= 1); + uint32_t size = reqSize - 1 + sizeof (struct Buffer::BufferData); uint8_t *b = new uint8_t [size]; struct BufferData *data = reinterpret_cast(b); - data->m_size = req_size; - data->m_initialStart = req_start; - data->m_dirtyStart = req_start; + data->m_size = reqSize; + data->m_initialStart = reqStart; + data->m_dirtyStart = reqStart; data->m_dirtySize = 0; data->m_count = 1; return data; @@ -118,45 +118,45 @@ namespace ns3 { void -Buffer::add_at_start (uint32_t start) +Buffer::addAtStart (uint32_t start) { assert (m_start <= m_data->m_initialStart); - bool is_dirty = m_data->m_count > 1 && m_start > m_data->m_dirtyStart; - if (m_start >= start && !is_dirty) { + bool isDirty = m_data->m_count > 1 && m_start > m_data->m_dirtyStart; + if (m_start >= start && !isDirty) { /* enough space in the buffer and not dirty. */ m_start -= start; m_size += start; - } else if (m_size + start <= m_data->m_size && !is_dirty) { + } else if (m_size + start <= m_data->m_size && !isDirty) { /* enough space but need to move data around to fit new data */ - memmove (m_data->m_data + start, get_start (), m_size); + memmove (m_data->m_data + start, getStart (), m_size); assert (start > m_start); m_data->m_initialStart += start; m_start = 0; m_size += start; } else if (m_start < start) { /* not enough space in buffer */ - uint32_t new_size = m_size + start; - struct Buffer::BufferData *new_data = Buffer::allocate (new_size, 0); - memcpy (new_data->m_data + start, get_start (), m_size); - new_data->m_initialStart = m_data->m_initialStart + start; + uint32_t newSize = m_size + start; + struct Buffer::BufferData *newData = Buffer::allocate (newSize, 0); + memcpy (newData->m_data + start, getStart (), m_size); + newData->m_initialStart = m_data->m_initialStart + start; m_data->m_count--; if (m_data->m_count == 0) { Buffer::deallocate (m_data); } - m_data = new_data; + m_data = newData; m_start = 0; - m_size = new_size; + m_size = newSize; } else { /* enough space in the buffer but it is dirty ! */ - assert (is_dirty); - struct Buffer::BufferData *new_data = Buffer::create (); - memcpy (new_data->m_data + m_start, get_start (), m_size); - new_data->m_initialStart = m_data->m_initialStart; + assert (isDirty); + struct Buffer::BufferData *newData = Buffer::create (); + memcpy (newData->m_data + m_start, getStart (), m_size); + newData->m_initialStart = m_data->m_initialStart; m_data->m_count--; if (m_data->m_count == 0) { recycle (m_data); } - m_data = new_data; + m_data = newData; m_start -= start; m_size += start; } @@ -164,75 +164,75 @@ Buffer::add_at_start (uint32_t start) m_data->m_dirtyStart = m_start; m_data->m_dirtySize = m_size; // update m_maxTotalAddStart - uint32_t added_at_start; + uint32_t addedAtStart; if (m_data->m_initialStart > m_start) { - added_at_start = m_data->m_initialStart - m_start; + addedAtStart = m_data->m_initialStart - m_start; } else { - added_at_start = 0; + addedAtStart = 0; } - if (added_at_start > m_maxTotalAddStart) { - m_maxTotalAddStart = added_at_start; + if (addedAtStart > m_maxTotalAddStart) { + m_maxTotalAddStart = addedAtStart; } TRACE ("start add="< BufferDataList; - inline uint8_t *get_start (void) const; + inline uint8_t *getStart (void) const; void transform_intoRealBuffer (void) const; static void recycle (struct Buffer::BufferData *data); static struct Buffer::BufferData *create (void); @@ -371,9 +371,9 @@ Buffer::Buffer () assert (m_start <= m_data->m_size); } -Buffer::Buffer (uint32_t data_size) +Buffer::Buffer (uint32_t dataSize) : m_data (Buffer::create ()), - m_zeroAreaSize (data_size), + m_zeroAreaSize (dataSize), m_start (m_maxTotalAddStart), m_size (0) { @@ -423,13 +423,13 @@ Buffer::~Buffer () uint8_t * -Buffer::get_start (void) const +Buffer::getStart (void) const { return m_data->m_data + m_start; } uint32_t -Buffer::get_size (void) const +Buffer::getSize (void) const { return m_size + m_zeroAreaSize; } @@ -442,7 +442,7 @@ Buffer::begin (void) const Buffer::Iterator Buffer::end (void) const { - return Buffer::Iterator (this, get_size ()); + return Buffer::Iterator (this, getSize ()); } @@ -456,7 +456,7 @@ Buffer::Iterator::Iterator () Buffer::Iterator::Iterator (Buffer const*buffer, uint32_t current) : m_zeroStart (buffer->m_data->m_initialStart-buffer->m_start), m_zeroEnd (m_zeroStart+buffer->m_zeroAreaSize), - m_dataEnd (buffer->get_size ()), + m_dataEnd (buffer->getSize ()), m_current (current), m_data (buffer->m_data->m_data+buffer->m_start) {} @@ -486,7 +486,7 @@ Buffer::Iterator::prev (uint32_t delta) m_current -= delta; } int32_t -Buffer::Iterator::get_distance_from (Iterator const &o) const +Buffer::Iterator::getDistanceFrom (Iterator const &o) const { assert (m_data == o.m_data); int32_t start = m_current; @@ -495,18 +495,18 @@ Buffer::Iterator::get_distance_from (Iterator const &o) const } bool -Buffer::Iterator::is_end (void) const +Buffer::Iterator::isEnd (void) const { return m_current == m_dataEnd; } bool -Buffer::Iterator::is_start (void) const +Buffer::Iterator::isStart (void) const { return m_current == 0; } uint32_t -Buffer::Iterator::get_index (uint32_t n) +Buffer::Iterator::getIndex (uint32_t n) { assert ( (m_current + n <= m_dataEnd) && @@ -530,58 +530,58 @@ Buffer::Iterator::write (Iterator start, Iterator end) assert (start.m_current <= end.m_current); assert (m_data != start.m_data); uint32_t size = end.m_current - start.m_current; - uint8_t *src = start.m_data + start.get_index (size); - uint8_t *dest = m_data + get_index (size); + uint8_t *src = start.m_data + start.getIndex (size); + uint8_t *dest = m_data + getIndex (size); memcpy (dest, src, size); m_current += size; } void -Buffer::Iterator::write_u8 (uint8_t data, uint32_t len) +Buffer::Iterator::writeU8 (uint8_t data, uint32_t len) { - uint8_t *current = m_data + get_index (len); + uint8_t *current = m_data + getIndex (len); memset (current, data, len); m_current += len; } void -Buffer::Iterator::write_u8 (uint8_t data) +Buffer::Iterator::writeU8 (uint8_t data) { - m_data[get_index (1)] = data; + m_data[getIndex (1)] = data; m_current++; } void -Buffer::Iterator::write_u16 (uint16_t data) +Buffer::Iterator::writeU16 (uint16_t data) { - uint16_t *buffer = (uint16_t *)(m_data + get_index (2)); + uint16_t *buffer = (uint16_t *)(m_data + getIndex (2)); *buffer = data; m_current += 2; } void -Buffer::Iterator::write_u32 (uint32_t data) +Buffer::Iterator::writeU32 (uint32_t data) { - uint32_t *buffer = (uint32_t *)(m_data + get_index (4)); + uint32_t *buffer = (uint32_t *)(m_data + getIndex (4)); *buffer = data; m_current += 4; } void -Buffer::Iterator::write_u64 (uint64_t data) +Buffer::Iterator::writeU64 (uint64_t data) { - uint64_t *buffer = (uint64_t *)(m_data + get_index (8)); + uint64_t *buffer = (uint64_t *)(m_data + getIndex (8)); *buffer = data; m_current += 8; } void -Buffer::Iterator::write_hton_u16 (uint16_t data) +Buffer::Iterator::writeHtonU16 (uint16_t data) { - uint8_t *current = m_data + get_index (2); + uint8_t *current = m_data + getIndex (2); *(current+0) = (data >> 8) & 0xff; *(current+1) = (data >> 0) & 0xff; m_current += 2; } void -Buffer::Iterator::write_hton_u32 (uint32_t data) +Buffer::Iterator::writeHtonU32 (uint32_t data) { - uint8_t *current = m_data + get_index (4); + uint8_t *current = m_data + getIndex (4); *(current+0) = (data >> 24) & 0xff; *(current+1) = (data >> 16) & 0xff; *(current+2) = (data >> 8) & 0xff; @@ -589,9 +589,9 @@ Buffer::Iterator::write_hton_u32 (uint32_t data) m_current += 4; } void -Buffer::Iterator::write_hton_u64 (uint64_t data) +Buffer::Iterator::writeHtonU64 (uint64_t data) { - uint8_t *current = m_data + get_index (8); + uint8_t *current = m_data + getIndex (8); *(current+0) = (data >> 56) & 0xff; *(current+1) = (data >> 48) & 0xff; *(current+2) = (data >> 40) & 0xff; @@ -605,43 +605,43 @@ Buffer::Iterator::write_hton_u64 (uint64_t data) void Buffer::Iterator::write (uint8_t const*buffer, uint16_t size) { - uint8_t *current = m_data + get_index (size); + uint8_t *current = m_data + getIndex (size); memcpy (current, buffer, size); m_current += size; } uint8_t -Buffer::Iterator::read_u8 (void) +Buffer::Iterator::readU8 (void) { - uint8_t data = m_data[get_index(1)]; + uint8_t data = m_data[getIndex(1)]; m_current++; return data; } uint16_t -Buffer::Iterator::read_u16 (void) +Buffer::Iterator::readU16 (void) { - uint16_t *buffer = reinterpret_cast(m_data + get_index (2)); + uint16_t *buffer = reinterpret_cast(m_data + getIndex (2)); m_current += 2; return *buffer; } uint32_t -Buffer::Iterator::read_u32 (void) +Buffer::Iterator::readU32 (void) { - uint32_t *buffer = reinterpret_cast(m_data + get_index (4)); + uint32_t *buffer = reinterpret_cast(m_data + getIndex (4)); m_current += 4; return *buffer; } uint64_t -Buffer::Iterator::read_u64 (void) +Buffer::Iterator::readU64 (void) { - uint64_t *buffer = reinterpret_cast(m_data + get_index (8)); + uint64_t *buffer = reinterpret_cast(m_data + getIndex (8)); m_current += 8; return *buffer; } uint16_t -Buffer::Iterator::read_ntoh_u16 (void) +Buffer::Iterator::readNtohU16 (void) { - uint8_t *current = m_data + get_index (2); + uint8_t *current = m_data + getIndex (2); uint16_t retval = 0; retval |= static_cast (current[0]) << 8; retval |= static_cast (current[1]) << 0; @@ -649,9 +649,9 @@ Buffer::Iterator::read_ntoh_u16 (void) return retval; } uint32_t -Buffer::Iterator::read_ntoh_u32 (void) +Buffer::Iterator::readNtohU32 (void) { - uint8_t *current = m_data + get_index (4); + uint8_t *current = m_data + getIndex (4); uint32_t retval = 0; retval |= static_cast (current[0]) << 24; retval |= static_cast (current[1]) << 16; @@ -661,9 +661,9 @@ Buffer::Iterator::read_ntoh_u32 (void) return retval; } uint64_t -Buffer::Iterator::read_ntoh_u64 (void) +Buffer::Iterator::readNtohU64 (void) { - uint8_t *current = m_data + get_index (8); + uint8_t *current = m_data + getIndex (8); uint64_t retval = 0; retval |= static_cast (current[0]) << 56; retval |= static_cast (current[1]) << 48; @@ -679,7 +679,7 @@ Buffer::Iterator::read_ntoh_u64 (void) void Buffer::Iterator::read (uint8_t *buffer, uint16_t size) { - uint8_t *current = m_data + get_index (size); + uint8_t *current = m_data + getIndex (size); memcpy (buffer, current, size); m_current += size; } diff --git a/src/common/callback-tracer.h b/src/common/callback-tracer.h index 0ac603a2f..4cccf25fe 100644 --- a/src/common/callback-tracer.h +++ b/src/common/callback-tracer.h @@ -41,36 +41,36 @@ class CallbackTracer : public CallbackTracerBase{ public: CallbackTracer () : m_callback () {} - void set_callback (Callback callback) { + void setCallback (Callback callback) { m_callback = callback; } void operator() (void) { - if (!m_callback.is_null ()) { + if (!m_callback.isNull ()) { m_callback (); } } void operator() (T1 a1) { - if (!m_callback.is_null ()) { + if (!m_callback.isNull ()) { m_callback (a1); } } void operator() (T1 a1, T2 a2) { - if (!m_callback.is_null ()) { + if (!m_callback.isNull ()) { m_callback (a1,a2); } } void operator() (T1 a1, T2 a2, T3 a3) { - if (!m_callback.is_null ()) { + if (!m_callback.isNull ()) { m_callback (a1,a2,a3); } } void operator() (T1 a1, T2 a2, T3 a3, T4 a4) { - if (!m_callback.is_null ()) { + if (!m_callback.isNull ()) { m_callback (a1,a2,a3,a4); } } void operator() (T1 a1, T2 a2, T3 a3, T4 a4,T5 a5) { - if (!m_callback.is_null ()) { + if (!m_callback.isNull ()) { m_callback (a1,a2,a3,a4,a5); } } diff --git a/src/common/chunk-constant-data.cc b/src/common/chunk-constant-data.cc index 99a2c6c66..bd6d5a4f0 100644 --- a/src/common/chunk-constant-data.cc +++ b/src/common/chunk-constant-data.cc @@ -40,23 +40,23 @@ ChunkConstantData::print (std::ostream *os) const } void -ChunkConstantData::add_to (Buffer *buffer) const +ChunkConstantData::addTo (Buffer *buffer) const { - buffer->add_at_start (m_len); + buffer->addAtStart (m_len); #ifndef NDEBUG - buffer->begin ().write_u8 (m_data, m_len); + buffer->begin ().writeU8 (m_data, m_len); #endif } void -ChunkConstantData::peek_from (Buffer const *buffer) +ChunkConstantData::peekFrom (Buffer const *buffer) { - m_len = buffer->get_size (); - m_data = buffer->begin ().read_u8 (); + m_len = buffer->getSize (); + m_data = buffer->begin ().readU8 (); } void -ChunkConstantData::remove_from (Buffer *buffer) +ChunkConstantData::removeFrom (Buffer *buffer) { - buffer->remove_at_start (m_len); + buffer->removeAtStart (m_len); } diff --git a/src/common/chunk-constant-data.h b/src/common/chunk-constant-data.h index a2baf01dc..202bc278d 100644 --- a/src/common/chunk-constant-data.h +++ b/src/common/chunk-constant-data.h @@ -35,9 +35,9 @@ public: private: virtual void print (std::ostream *os) const; - virtual void add_to (Buffer *buffer) const; - virtual void peek_from (Buffer const *buffer); - virtual void remove_from (Buffer *buffer); + virtual void addTo (Buffer *buffer) const; + virtual void peekFrom (Buffer const *buffer); + virtual void removeFrom (Buffer *buffer); uint32_t m_len; uint8_t m_data; }; diff --git a/src/common/chunk.cc b/src/common/chunk.cc index a3723dc5b..a665601ca 100644 --- a/src/common/chunk.cc +++ b/src/common/chunk.cc @@ -35,19 +35,19 @@ Chunk::print (std::ostream &os) const void Chunk::add (Buffer *buffer) const { - add_to (buffer); + addTo (buffer); } void Chunk::peek (Buffer const *buffer) { - peek_from (buffer); + peekFrom (buffer); m_mustPeekBeforeRemove = true; } void Chunk::remove (Buffer *buffer) { assert (m_mustPeekBeforeRemove); - remove_from (buffer); + removeFrom (buffer); m_mustPeekBeforeRemove = false; } diff --git a/src/common/chunk.h b/src/common/chunk.h index 3561cef04..4d25f20cf 100644 --- a/src/common/chunk.h +++ b/src/common/chunk.h @@ -64,13 +64,13 @@ private: * - reserve room for its serialized representation in the input buffer * - serialize itself in this reserved room */ - virtual void add_to (Buffer *buffer) const = 0; + virtual void addTo (Buffer *buffer) const = 0; /** * \param buffer the buffer from which the protocol header must * deserialize itself. * */ - virtual void peek_from (Buffer const *buffer) = 0; + virtual void peekFrom (Buffer const *buffer) = 0; /** * \param buffer the buffer from which the protocol header * must remove itself. @@ -79,7 +79,7 @@ private: * from the input buffer. This method does not need to deserialize * the data itself. */ - virtual void remove_from (Buffer *buffer) = 0; + virtual void removeFrom (Buffer *buffer) = 0; }; std::ostream& operator<< (std::ostream& os, Chunk const& chunk); diff --git a/src/common/data-writer.cc b/src/common/data-writer.cc index 0591fecb3..8859746a1 100644 --- a/src/common/data-writer.cc +++ b/src/common/data-writer.cc @@ -82,11 +82,11 @@ void DataWriterPrivate::write (uint8_t *buffer, uint32_t size) { while (size > 0) { - uint32_t to_copy = min (BUFFER_SIZE - m_current, size); - memcpy (m_data + m_current, buffer, to_copy); - size -= to_copy; - m_current += to_copy; - buffer += to_copy; + uint32_t toCopy = min (BUFFER_SIZE - m_current, size); + memcpy (m_data + m_current, buffer, toCopy); + size -= toCopy; + m_current += toCopy; + buffer += toCopy; if (m_current == BUFFER_SIZE) { ssize_t written = 0; written = ::write (m_fd, m_data, BUFFER_SIZE); diff --git a/src/common/f-variable-tracer.h b/src/common/f-variable-tracer.h index 43233a5e1..427f7deda 100644 --- a/src/common/f-variable-tracer.h +++ b/src/common/f-variable-tracer.h @@ -39,13 +39,13 @@ public: ~FVariableTracerBase () {} - void set_callback(ChangeNotifyCallback callback) { + void setCallback(ChangeNotifyCallback callback) { m_callback = callback; } protected: - void notify (double old_val, double new_val) { - if (old_val != new_val && !m_callback.is_null ()) { - m_callback (old_val, new_val); + void notify (double oldVal, double newVal) { + if (oldVal != newVal && !m_callback.isNull ()) { + m_callback (oldVal, newVal); } } private: diff --git a/src/common/packet.cc b/src/common/packet.cc index 181e49098..60bccaf22 100644 --- a/src/common/packet.cc +++ b/src/common/packet.cc @@ -36,16 +36,16 @@ Packet::Packet (Buffer buffer, Tags tags) Packet -Packet::create_fragment (uint32_t start, uint32_t length) const +Packet::createFragment (uint32_t start, uint32_t length) const { - Buffer tmp = m_buffer.create_fragment (start, length); + Buffer tmp = m_buffer.createFragment (start, length); return Packet (tmp, m_tags); } uint32_t -Packet::get_size (void) const +Packet::getSize (void) const { - return m_buffer.get_size (); + return m_buffer.getSize (); } void @@ -70,58 +70,58 @@ Packet::remove (Chunk *chunk) void Packet::write (PacketReadWriteCallback callback) const { - uint8_t *data = m_buffer.peek_data (); - uint32_t to_write = get_size (); - callback (data, to_write); + uint8_t *data = m_buffer.peekData (); + uint32_t toWrite = getSize (); + callback (data, toWrite); } void -Packet::add_at_end (Packet packet) +Packet::addAtEnd (Packet packet) { Buffer src = packet.m_buffer; - m_buffer.add_at_end (src.get_size ()); - Buffer::Iterator dest_start = m_buffer.end (); - dest_start.prev (src.get_size ()); - dest_start.write (src.begin (), src.end ()); + m_buffer.addAtEnd (src.getSize ()); + Buffer::Iterator destStart = m_buffer.end (); + destStart.prev (src.getSize ()); + destStart.write (src.begin (), src.end ()); /** * XXX: we might need to merge the tag list of the * other packet into the current packet. */ } void -Packet::add_at_end (Packet packet, uint32_t start, uint32_t size) +Packet::addAtEnd (Packet packet, uint32_t start, uint32_t size) { - assert (packet.get_size () <= start + size); + assert (packet.getSize () <= start + size); Buffer src = packet.m_buffer; - m_buffer.add_at_end (src.get_size ()); - Buffer::Iterator dest_start = m_buffer.end (); - dest_start.prev (size); - Buffer::Iterator src_start = src.begin (); - src_start.next (start); - Buffer::Iterator src_end = src_start; - src_end.next (size); - dest_start.write (src_start, src_end); + m_buffer.addAtEnd (src.getSize ()); + Buffer::Iterator destStart = m_buffer.end (); + destStart.prev (size); + Buffer::Iterator srcStart = src.begin (); + srcStart.next (start); + Buffer::Iterator srcEnd = srcStart; + srcEnd.next (size); + destStart.write (srcStart, srcEnd); /** * XXX: we might need to merge the tag list of the * other packet into the current packet. */ } void -Packet::remove_at_end (uint32_t size) +Packet::removeAtEnd (uint32_t size) { - m_buffer.remove_at_end (size); + m_buffer.removeAtEnd (size); } void -Packet::remove_at_start (uint32_t size) +Packet::removeAtStart (uint32_t size) { - m_buffer.remove_at_start (size); + m_buffer.removeAtStart (size); } void -Packet::remove_all_tags (void) +Packet::removeAllTags (void) { - m_tags.remove_all (); + m_tags.removeAll (); } }; // namespace ns3 diff --git a/src/common/packet.h b/src/common/packet.h index ccd5e08dc..fffbfbb1a 100644 --- a/src/common/packet.h +++ b/src/common/packet.h @@ -34,25 +34,25 @@ public: typedef Callback PacketReadWriteCallback; Packet (); Packet (uint32_t size); - Packet create_fragment (uint32_t start, uint32_t length) const; - uint32_t get_size (void) const; + Packet createFragment (uint32_t start, uint32_t length) const; + uint32_t getSize (void) const; void add (Chunk *chunk); void peek (Chunk *chunk) const; void remove (Chunk *chunk); template - void add_tag (T const *tag); + void addTag (T const *tag); template - bool remove_tag (T *tag); + bool removeTag (T *tag); template - bool peek_tag (T *tag) const; + bool peekTag (T *tag) const; template - bool update_tag (T const*tag); - void remove_all_tags (void); + bool updateTag (T const*tag); + void removeAllTags (void); void write (PacketReadWriteCallback callback) const; - void add_at_end (Packet packet); - void add_at_end (Packet packet, uint32_t offset, uint32_t size); - void remove_at_end (uint32_t size); - void remove_at_start (uint32_t size); + void addAtEnd (Packet packet); + void addAtEnd (Packet packet, uint32_t offset, uint32_t size); + void removeAtEnd (uint32_t size); + void removeAtStart (uint32_t size); private: Packet (Buffer buffer, Tags tags); @@ -65,22 +65,22 @@ private: namespace ns3 { template -void Packet::add_tag (T const*tag) +void Packet::addTag (T const*tag) { m_tags.add (tag); } template -bool Packet::remove_tag (T *tag) +bool Packet::removeTag (T *tag) { return m_tags.remove (tag); } template -bool Packet::peek_tag (T *tag) const +bool Packet::peekTag (T *tag) const { return m_tags.peek (tag); } template -bool Packet::update_tag (T const*tag) +bool Packet::updateTag (T const*tag) { return m_tags.update (tag); } diff --git a/src/common/pcap-writer.cc b/src/common/pcap-writer.cc index 5ab20e832..f48527fc6 100644 --- a/src/common/pcap-writer.cc +++ b/src/common/pcap-writer.cc @@ -39,7 +39,7 @@ enum { PcapWriter::PcapWriter () { m_writer = 0; - m_writeCallback = make_callback (&PcapWriter::write_data, this); + m_writeCallback = makeCallback (&PcapWriter::writeData, this); } PcapWriter::~PcapWriter () { @@ -54,7 +54,7 @@ PcapWriter::open (char const *name) } void -PcapWriter::write_header_ethernet (void) +PcapWriter::writeHeaderEthernet (void) { write_32 (0xa1b2c3d4); write_16 (2); @@ -66,7 +66,7 @@ PcapWriter::write_header_ethernet (void) } void -PcapWriter::write_packet (Packet const packet) +PcapWriter::writePacket (Packet const packet) { if (m_writer != 0) { uint64_t current = Simulator::now ().us (); @@ -74,14 +74,14 @@ PcapWriter::write_packet (Packet const packet) uint64_t us = current % 1000000; write_32 (s & 0xffffffff); write_32 (us & 0xffffffff); - write_32 (packet.get_size ()); - write_32 (packet.get_size ()); + write_32 (packet.getSize ()); + write_32 (packet.getSize ()); packet.write (m_writeCallback); } } void -PcapWriter::write_data (uint8_t *buffer, uint32_t size) +PcapWriter::writeData (uint8_t *buffer, uint32_t size) { m_writer->write (buffer, size); } diff --git a/src/common/pcap-writer.h b/src/common/pcap-writer.h index 52235ff85..dbfeeeecb 100644 --- a/src/common/pcap-writer.h +++ b/src/common/pcap-writer.h @@ -53,15 +53,15 @@ public: * that the content of the file will Packets with * Ethernet/LLC/SNAP encapsulation. */ - void write_header_ethernet (void); + void writeHeaderEthernet (void); /** * \param packet packet to write to output file */ - void write_packet (Packet const packet); + void writePacket (Packet const packet); private: - void write_data (uint8_t *buffer, uint32_t size); + void writeData (uint8_t *buffer, uint32_t size); void write_32 (uint32_t data); void write_16 (uint16_t data); SystemFile *m_writer; diff --git a/src/common/si-variable-tracer.h b/src/common/si-variable-tracer.h index bd4c1527c..bd20f620a 100644 --- a/src/common/si-variable-tracer.h +++ b/src/common/si-variable-tracer.h @@ -39,13 +39,13 @@ public: ~SiVariableTracerBase () {} - void set_callback(ChangeNotifyCallback callback) { + void setCallback(ChangeNotifyCallback callback) { m_callback = callback; } protected: - void notify (int64_t old_val, int64_t new_val) { - if (old_val != new_val && !m_callback.is_null ()) { - m_callback (old_val, new_val); + void notify (int64_t oldVal, int64_t newVal) { + if (oldVal != newVal && !m_callback.isNull ()) { + m_callback (oldVal, newVal); } } private: diff --git a/src/common/stream-tracer-test.cc b/src/common/stream-tracer-test.cc index 46862a5d8..3d744f7d3 100644 --- a/src/common/stream-tracer-test.cc +++ b/src/common/stream-tracer-test.cc @@ -29,21 +29,21 @@ namespace { class TestStreamTracer : public ns3::Test { public: TestStreamTracer (); - virtual bool run_tests (void); + virtual bool runTests (void); }; -static TestStreamTracer g_test_stream; +static TestStreamTracer gTestStream; TestStreamTracer::TestStreamTracer () : Test ("StreamTracer") {} bool -TestStreamTracer::run_tests (void) +TestStreamTracer::runTests (void) { bool ok = true; ns3::StreamTracer trace; - //trace.set_stream (&std::cout); + //trace.setStream (&std::cout); trace << 1; trace << " X "; trace << 1.0; diff --git a/src/common/stream-tracer.h b/src/common/stream-tracer.h index 36d0ca43f..ef2f07bdc 100644 --- a/src/common/stream-tracer.h +++ b/src/common/stream-tracer.h @@ -60,7 +60,7 @@ public: /** * \param os the output stream to store */ - void set_stream (std::ostream * os) { + void setStream (std::ostream * os) { m_os = os; } private: diff --git a/src/common/tags.cc b/src/common/tags.cc index 6abcbf5fd..28f31da5a 100644 --- a/src/common/tags.cc +++ b/src/common/tags.cc @@ -23,25 +23,25 @@ namespace ns3 { -TagsPrettyPrinterRegistry::PrettyPrinters TagsPrettyPrinterRegistry::g_pretty_printers; +TagsPrettyPrinterRegistry::PrettyPrinters TagsPrettyPrinterRegistry::gPrettyPrinters; void TagsPrettyPrinterRegistry::record (uint32_t uid, void (*cb) (uint8_t [Tags::SIZE], std::ostream &)) { - for (PrettyPrintersI i = g_pretty_printers.begin (); - i != g_pretty_printers.end (); i++) { + for (PrettyPrintersI i = gPrettyPrinters.begin (); + i != gPrettyPrinters.end (); i++) { if (i->first == uid) { i->second = cb; return; } } - g_pretty_printers.push_back (std::make_pair (uid, cb)); + gPrettyPrinters.push_back (std::make_pair (uid, cb)); } void -TagsPrettyPrinterRegistry::pretty_print (uint32_t uid, uint8_t buf[Tags::SIZE], std::ostream &os) +TagsPrettyPrinterRegistry::prettyPrint (uint32_t uid, uint8_t buf[Tags::SIZE], std::ostream &os) { - for (PrettyPrintersI i = g_pretty_printers.begin (); - i != g_pretty_printers.end (); i++) { + for (PrettyPrintersI i = gPrettyPrinters.begin (); + i != gPrettyPrinters.end (); i++) { if (i->first == uid) { if (i->second == 0) { os << "tag uid="<m_next; - g_n_free--; + if (gFree != 0) { + retval = gFree; + gFree = gFree->m_next; + gN_free--; } else { retval = new struct Tags::TagData (); } @@ -85,19 +85,19 @@ Tags::alloc_data (void) } void -Tags::free_data (struct TagData *data) +Tags::freeData (struct TagData *data) { - if (g_n_free > 1000) { + if (gN_free > 1000) { delete data; return; } - g_n_free++; - data->m_next = g_free; - g_free = data; + gN_free++; + data->m_next = gFree; + gFree = data; } #else struct Tags::TagData * -Tags::alloc_data (void) +Tags::allocData (void) { struct Tags::TagData *retval; retval = new struct Tags::TagData (); @@ -105,7 +105,7 @@ Tags::alloc_data (void) } void -Tags::free_data (struct TagData *data) +Tags::freeData (struct TagData *data) { delete data; } @@ -124,7 +124,7 @@ Tags::remove (uint32_t id) return false; } struct TagData *start = 0; - struct TagData **prev_next = &start; + struct TagData **prevNext = &start; for (struct TagData *cur = m_next; cur != 0; cur = cur->m_next) { if (cur->m_id == id) { /** @@ -135,16 +135,16 @@ Tags::remove (uint32_t id) */ continue; } - struct TagData *copy = alloc_data (); + struct TagData *copy = allocData (); copy->m_id = cur->m_id; copy->m_count = 1; copy->m_next = 0; memcpy (copy->m_data, cur->m_data, Tags::SIZE); - *prev_next = copy; - prev_next = ©->m_next; + *prevNext = copy; + prevNext = ©->m_next; } - *prev_next = 0; - remove_all (); + *prevNext = 0; + removeAll (); m_next = start; return true; } @@ -155,21 +155,21 @@ Tags::update (uint8_t const*buffer, uint32_t id) if (!remove (id)) { return false; } - struct TagData *new_start = alloc_data (); - new_start->m_count = 1; - new_start->m_next = 0; - new_start->m_id = id; - memcpy (new_start->m_data, buffer, Tags::SIZE); - new_start->m_next = m_next; - m_next = new_start; + struct TagData *newStart = allocData (); + newStart->m_count = 1; + newStart->m_next = 0; + newStart->m_id = id; + memcpy (newStart->m_data, buffer, Tags::SIZE); + newStart->m_next = m_next; + m_next = newStart; return true; } void -Tags::pretty_print (std::ostream &os) +Tags::prettyPrint (std::ostream &os) { for (struct TagData *cur = m_next; cur != 0; cur = cur->m_next) { - TagsPrettyPrinterRegistry::pretty_print (cur->m_id, cur->m_data, os); + TagsPrettyPrinterRegistry::prettyPrint (cur->m_id, cur->m_data, os); } } @@ -188,42 +188,42 @@ class TagsTest : Test { public: TagsTest (); virtual ~TagsTest (); - virtual bool run_tests (void); + virtual bool runTests (void); }; -struct my_tag_a { +struct myTagA { uint8_t a; }; -struct my_tag_b { +struct myTagB { uint32_t b; }; -struct my_tag_c { +struct myTagC { uint8_t c [Tags::SIZE]; }; -struct my_invalid_tag { +struct myInvalidTag { uint8_t invalid [Tags::SIZE+1]; }; static void -my_tag_a_pretty_printer_cb (struct my_tag_a *a, std::ostream &os) +myTagAPrettyPrinterCb (struct myTagA *a, std::ostream &os) { - os << "struct my_tag_a, a="<<(uint32_t)a->a< callback); /** * \param name the name of the target event source @@ -77,21 +77,21 @@ public: * This method targets only event sources which are variables of any signed * integer type. */ - void set_si_variable_callback (char const *name, Callback callback); + void setSiVariableCallback (char const *name, Callback callback); /** * \param name the name of the target event source * \param callback the callback being connected to the target event source * * This method targets only event sources which are variables of any double type. */ - void set_f_variable_callback (char const *name, Callback callback); + void setFVariableCallback (char const *name, Callback callback); /** * \param name the name of the target event source * \param os the output stream being connected to the source trace stream * * This method targets only event sources which are of type StreamTracer. */ - void set_stream (char const *name, std::ostream *os); + void setStream (char const *name, std::ostream *os); /** * \param name the name of the target event source @@ -100,7 +100,7 @@ public: * This method targets only event sources which are of type CallbackTracer */ template - void set_callback (char const *name, Callback callback); + void setCallback (char const *name, Callback callback); /** * \param name the name of the target event source * \param callback the callback being connected to the target event source. @@ -108,7 +108,7 @@ public: * This method targets only event sources which are of type CallbackTracer */ template - void set_callback (char const *name, Callback callback); + void setCallback (char const *name, Callback callback); /** * \param name the name of the target event source * \param callback the callback being connected to the target event source. @@ -116,7 +116,7 @@ public: * This method targets only event sources which are of type CallbackTracer */ template - void set_callback (char const *name, Callback callback); + void setCallback (char const *name, Callback callback); /** * \param name the name of the target event source * \param callback the callback being connected to the target event source. @@ -124,7 +124,7 @@ public: * This method targets only event sources which are of type CallbackTracer */ template - void set_callback (char const *name, Callback callback); + void setCallback (char const *name, Callback callback); /** * \param name the name of the target event source * \param callback the callback being connected to the target event source. @@ -132,7 +132,7 @@ public: * This method targets only event sources which are of type CallbackTracer */ template - void set_callback (char const *name, Callback callback); + void setCallback (char const *name, Callback callback); /** * \param name the name of the registered event source @@ -140,28 +140,28 @@ public: * * This method registers only event sources of type "unsigned integer". */ - void register_ui_variable (char const *name, UiVariableTracerBase *var); + void registerUiVariable (char const *name, UiVariableTracerBase *var); /** * \param name the name of the registered event source * \param var the event source being registered * * This method registers only event sources of type "signed integer". */ - void register_si_variable (char const *name, SiVariableTracerBase *var); + void registerSiVariable (char const *name, SiVariableTracerBase *var); /** * \param name the name of the registered event source * \param var the event source being registered * * This method registers only event sources of type "double". */ - void register_f_variable (char const *name, FVariableTracerBase *var); + void registerFVariable (char const *name, FVariableTracerBase *var); /** * \param name the name of the registered event source * \param stream the event source being registered * * This method registers only event sources of type StreamTracer. */ - void register_stream (char const *name, StreamTracer *stream); + void registerStream (char const *name, StreamTracer *stream); /** * \param name the name of the registeref event source @@ -169,12 +169,12 @@ public: * * This method registers only event sources of type CallbackTracer */ - void register_callback (char const *name, CallbackTracerBase*tracer); + void registerCallback (char const *name, CallbackTracerBase*tracer); /** * Print the list of registered event sources in this container only. */ - void print_debug (void); + void printDebug (void); private: typedef std::list > UiList; typedef std::list >::iterator UiListI; @@ -204,11 +204,11 @@ namespace ns3 { template void -TraceContainer::set_callback (char const *name, Callback callback) +TraceContainer::setCallback (char const *name, Callback callback) { for (CallbackListI i = m_callbackList.begin (); i != m_callbackList.end (); i++) { if (i->second == name) { - static_cast *> (i->first)->set_callback (callback); + static_cast *> (i->first)->setCallback (callback); return; } } @@ -218,11 +218,11 @@ TraceContainer::set_callback (char const *name, Callback callback) } template void -TraceContainer::set_callback (char const *name, Callback callback) +TraceContainer::setCallback (char const *name, Callback callback) { for (CallbackListI i = m_callbackList.begin (); i != m_callbackList.end (); i++) { if (i->second == name) { - static_cast *> (i->first)->set_callback (callback); + static_cast *> (i->first)->setCallback (callback); return; } } @@ -232,11 +232,11 @@ TraceContainer::set_callback (char const *name, Callback callback) } template void -TraceContainer::set_callback (char const *name, Callback callback) +TraceContainer::setCallback (char const *name, Callback callback) { for (CallbackListI i = m_callbackList.begin (); i != m_callbackList.end (); i++) { if (i->second == name) { - static_cast *> (i->first)->set_callback (callback); + static_cast *> (i->first)->setCallback (callback); return; } } @@ -246,11 +246,11 @@ TraceContainer::set_callback (char const *name, Callback callback } template void -TraceContainer::set_callback (char const *name, Callback callback) +TraceContainer::setCallback (char const *name, Callback callback) { for (CallbackListI i = m_callbackList.begin (); i != m_callbackList.end (); i++) { if (i->second == name) { - static_cast *> (i->first)->set_callback (callback); + static_cast *> (i->first)->setCallback (callback); return; } } @@ -260,11 +260,11 @@ TraceContainer::set_callback (char const *name, Callback callb } template void -TraceContainer::set_callback (char const *name, Callback callback) +TraceContainer::setCallback (char const *name, Callback callback) { for (CallbackListI i = m_callbackList.begin (); i != m_callbackList.end (); i++) { if (i->second == name) { - static_cast *> (i->first)->set_callback (callback); + static_cast *> (i->first)->setCallback (callback); return; } } diff --git a/src/common/ui-variable-tracer.h b/src/common/ui-variable-tracer.h index 9db34bfcf..4792b47b6 100644 --- a/src/common/ui-variable-tracer.h +++ b/src/common/ui-variable-tracer.h @@ -33,7 +33,7 @@ public: UiVariableTracerBase () : m_callback () {} - /* We don't want to copy the base callback. Only set_callback on + /* We don't want to copy the base callback. Only setCallback on * a specific instance will do something to it. */ UiVariableTracerBase (UiVariableTracerBase const &o) : m_callback () {} @@ -42,13 +42,13 @@ public: } ~UiVariableTracerBase () {} - void set_callback(ChangeNotifyCallback callback) { + void setCallback(ChangeNotifyCallback callback) { m_callback = callback; } protected: - void notify (uint64_t old_val, uint64_t new_val) { - if (old_val != new_val && !m_callback.is_null ()) { - m_callback (old_val, new_val); + void notify (uint64_t oldVal, uint64_t newVal) { + if (oldVal != newVal && !m_callback.isNull ()) { + m_callback (oldVal, newVal); } } private: diff --git a/src/common/variable-tracer-test.cc b/src/common/variable-tracer-test.cc index cdae3c752..65ffe1fa1 100644 --- a/src/common/variable-tracer-test.cc +++ b/src/common/variable-tracer-test.cc @@ -29,24 +29,24 @@ namespace ns3 { class Foo { public: - void notify (uint64_t old_val, uint64_t new_val) {} + void notify (uint64_t oldVal, uint64_t newVal) {} }; class VariableTracerTest: public Test { public: VariableTracerTest (); - void run_unsigned_tests (void); - void run_signed_unsigned_tests (void); - virtual bool run_tests (void); + void runUnsignedTests (void); + void runSignedUnsignedTests (void); + virtual bool runTests (void); }; void -VariableTracerTest::run_unsigned_tests (void) +VariableTracerTest::runUnsignedTests (void) { UiVariableTracer var, ovar, tmp; uint32_t utmp; Foo *foo = new Foo (); - var.set_callback (make_callback (&Foo::notify, foo)); + var.setCallback (makeCallback (&Foo::notify, foo)); var = 10; ovar = var; @@ -198,7 +198,7 @@ VariableTracerTest::run_unsigned_tests (void) } void -VariableTracerTest::run_signed_unsigned_tests (void) +VariableTracerTest::runSignedUnsignedTests (void) { unsigned short utmp = 10; unsigned int uitmp = 7; @@ -234,10 +234,10 @@ VariableTracerTest::run_signed_unsigned_tests (void) } bool -VariableTracerTest::run_tests (void) +VariableTracerTest::runTests (void) { - run_unsigned_tests (); - run_signed_unsigned_tests (); + runUnsignedTests (); + runSignedUnsignedTests (); return true; } @@ -245,7 +245,7 @@ VariableTracerTest::run_tests (void) VariableTracerTest::VariableTracerTest () : Test ("VariableTracer") {} -static VariableTracerTest g_variable_tracer_test; +static VariableTracerTest gVariableTracerTest; }; // namespace ns3 diff --git a/src/core/callback-test.cc b/src/core/callback-test.cc index b64af3832..b07aacb82 100644 --- a/src/core/callback-test.cc +++ b/src/core/callback-test.cc @@ -27,23 +27,23 @@ namespace ns3 { -static bool g_test5 = false; -static bool g_test6 = false; -static bool g_test7 = false; +static bool gTest5 = false; +static bool gTest6 = false; +static bool gTest7 = false; void test5 (void) { - g_test5 = true; + gTest5 = true; } void test6 (int) { - g_test6 = true; + gTest6 = true; } int test7 (int a) { - g_test7 = true; + gTest7 = true; return a; } @@ -55,9 +55,9 @@ private: bool m_test4; public: CallbackTest (); - virtual bool run_tests (void); + virtual bool runTests (void); void reset (void); - bool is_wrong (void); + bool isWrong (void); void test1 (void); int test2 (void); void test3 (double a); @@ -101,15 +101,15 @@ CallbackTest::test8 (Callback callback) callback (3); } bool -CallbackTest::is_wrong (void) +CallbackTest::isWrong (void) { if (!m_test1 || !m_test2 || !m_test3 || !m_test4 || - !g_test5 || - !g_test6 || - !g_test7) { + !gTest5 || + !gTest6 || + !gTest7) { return true; } return false; @@ -122,14 +122,14 @@ CallbackTest::reset (void) m_test2 = false; m_test3 = false; m_test4 = false; - g_test5 = false; - g_test6 = false; - g_test7 = false; + gTest5 = false; + gTest6 = false; + gTest7 = false; } bool -CallbackTest::run_tests (void) +CallbackTest::runTests (void) { bool ok = true; @@ -158,19 +158,19 @@ CallbackTest::run_tests (void) f0 (1); g0 (1); - if (is_wrong ()) { + if (isWrong ()) { ok = false; } reset (); - A a1 = ns3::make_callback (&CallbackTest::test1, this); - B b1 = ns3::make_callback (&CallbackTest::test2, this); - C c1 = ns3::make_callback (&CallbackTest::test3, this); - D d1 = ns3::make_callback (&CallbackTest::test4, this); - E e1 = ns3::make_callback (&test5); - F f1 = ns3::make_callback (&test6); - G g1 = ns3::make_callback (&test7); + A a1 = ns3::makeCallback (&CallbackTest::test1, this); + B b1 = ns3::makeCallback (&CallbackTest::test2, this); + C c1 = ns3::makeCallback (&CallbackTest::test3, this); + D d1 = ns3::makeCallback (&CallbackTest::test4, this); + E e1 = ns3::makeCallback (&test5); + F f1 = ns3::makeCallback (&test6); + G g1 = ns3::makeCallback (&test7); a1 (); b1 (); @@ -184,13 +184,13 @@ CallbackTest::run_tests (void) Callback a2; - if (is_wrong ()) { + if (isWrong ()) { ok = false; } return ok; } -static CallbackTest g_callback_test; +static CallbackTest gCallbackTest; }; // namespace diff --git a/src/core/callback.h b/src/core/callback.h index 395e6a330..7c70b45c8 100644 --- a/src/core/callback.h +++ b/src/core/callback.h @@ -52,7 +52,7 @@ namespace ns3 { * implementation in that it does not use type lists to specify * and pass around the types of the callback arguments. * Of course, it also does not use copy-destruction semantics - * and relies on a reference list rather than auto_ptr to hold + * and relies on a reference list rather than autoPtr to hold * the pointer. */ class empty {}; @@ -168,8 +168,8 @@ private: template class MemPtrCallbackImpl : public CallbackImpl { public: - MemPtrCallbackImpl (OBJ_PTR const&obj_ptr, MEM_PTR mem_ptr) - : m_objPtr (obj_ptr), m_memPtr (mem_ptr) {} + MemPtrCallbackImpl (OBJ_PTR const&objPtr, MEM_PTR mem_ptr) + : m_objPtr (objPtr), m_memPtr (mem_ptr) {} virtual ~MemPtrCallbackImpl () {} R operator() (void) { return ((*m_objPtr).*m_memPtr) (); @@ -212,14 +212,14 @@ private: * - the sixth optional template argument represents * the type of the fifth argument to the callback. * - * Callback instances are built with the \ref make_callback + * Callback instances are built with the \ref makeCallback * template functions. Callback instances have POD semantics: * the memory they allocate is managed automatically, without * user intervention which allows you to pass around Callback * instances by value. * * Sample code which shows how to use this class template - * as well as the function templates \ref make_callback : + * as well as the function templates \ref makeCallback : * \include samples/main-callback.cc */ template - Callback (OBJ_PTR const &obj_ptr, MEM_PTR mem_ptr) - : m_impl (new MemPtrCallbackImpl (obj_ptr, mem_ptr)) + Callback (OBJ_PTR const &objPtr, MEM_PTR mem_ptr) + : m_impl (new MemPtrCallbackImpl (objPtr, mem_ptr)) {} Callback (ReferenceList *> const &impl) : m_impl (impl) {} - bool is_null (void) { + bool isNull (void) { return (m_impl.get () == 0)?true:false; } @@ -270,243 +270,243 @@ private: }; /** - * \defgroup make_callback make_callback + * \defgroup makeCallback makeCallback * */ /** - * \ingroup make_callback + * \ingroup makeCallback * \param mem_ptr class method member pointer - * \param obj_ptr class instance + * \param objPtr class instance * \return a wrapper Callback * Build Callbacks for class method members which takes no arguments * and potentially return a value. */ template -Callback make_callback (R (OBJ::*mem_ptr) (), OBJ *const obj_ptr) { - return Callback (obj_ptr, mem_ptr); +Callback makeCallback (R (OBJ::*mem_ptr) (), OBJ *const objPtr) { + return Callback (objPtr, mem_ptr); } /** - * \ingroup make_callback + * \ingroup makeCallback * \param mem_ptr class method member pointer - * \param obj_ptr class instance + * \param objPtr class instance * \return a wrapper Callback * Build Callbacks for class method members which takes one argument * and potentially return a value. */ template -Callback make_callback (R (OBJ::*mem_ptr) (T1), OBJ *const obj_ptr) { - return Callback (obj_ptr, mem_ptr); +Callback makeCallback (R (OBJ::*mem_ptr) (T1), OBJ *const objPtr) { + return Callback (objPtr, mem_ptr); } /** - * \ingroup make_callback + * \ingroup makeCallback * \param mem_ptr class method member pointer - * \param obj_ptr class instance + * \param objPtr class instance * \return a wrapper Callback * Build Callbacks for class method members which takes two arguments * and potentially return a value. */ template -Callback make_callback (R (OBJ::*mem_ptr) (T1,T2), OBJ *const obj_ptr) { - return Callback (obj_ptr, mem_ptr); +Callback makeCallback (R (OBJ::*mem_ptr) (T1,T2), OBJ *const objPtr) { + return Callback (objPtr, mem_ptr); } /** - * \ingroup make_callback + * \ingroup makeCallback * \param mem_ptr class method member pointer - * \param obj_ptr class instance + * \param objPtr class instance * \return a wrapper Callback * Build Callbacks for class method members which takes three arguments * and potentially return a value. */ template -Callback make_callback (R (OBJ::*mem_ptr) (T1,T2,T3), OBJ *const obj_ptr) { - return Callback (obj_ptr, mem_ptr); +Callback makeCallback (R (OBJ::*mem_ptr) (T1,T2,T3), OBJ *const objPtr) { + return Callback (objPtr, mem_ptr); } /** - * \ingroup make_callback + * \ingroup makeCallback * \param mem_ptr class method member pointer - * \param obj_ptr class instance + * \param objPtr class instance * \return a wrapper Callback * Build Callbacks for class method members which takes four arguments * and potentially return a value. */ template -Callback make_callback (R (OBJ::*mem_ptr) (T1,T2,T3,T4), OBJ *const obj_ptr) { - return Callback (obj_ptr, mem_ptr); +Callback makeCallback (R (OBJ::*mem_ptr) (T1,T2,T3,T4), OBJ *const objPtr) { + return Callback (objPtr, mem_ptr); } /** - * \ingroup make_callback + * \ingroup makeCallback * \param mem_ptr class method member pointer - * \param obj_ptr class instance + * \param objPtr class instance * \return a wrapper Callback * Build Callbacks for class method members which takes five arguments * and potentially return a value. */ template -Callback make_callback (R (OBJ::*mem_ptr) (T1,T2,T3,T4,T5), OBJ *const obj_ptr) { - return Callback (obj_ptr, mem_ptr); +Callback makeCallback (R (OBJ::*mem_ptr) (T1,T2,T3,T4,T5), OBJ *const objPtr) { + return Callback (objPtr, mem_ptr); } /** - * \ingroup make_callback - * \param fn_ptr function pointer + * \ingroup makeCallback + * \param fnPtr function pointer * \return a wrapper Callback * Build Callbacks for functions which takes no arguments * and potentially return a value. */ template -Callback make_callback (R (*fn_ptr) ()) { - return Callback (fn_ptr); +Callback makeCallback (R (*fnPtr) ()) { + return Callback (fnPtr); } /** - * \ingroup make_callback - * \param fn_ptr function pointer + * \ingroup makeCallback + * \param fnPtr function pointer * \return a wrapper Callback * Build Callbacks for functions which takes one argument * and potentially return a value. */ template -Callback make_callback (R (*fn_ptr) (T1)) { - return Callback (fn_ptr); +Callback makeCallback (R (*fnPtr) (T1)) { + return Callback (fnPtr); } /** - * \ingroup make_callback - * \param fn_ptr function pointer + * \ingroup makeCallback + * \param fnPtr function pointer * \return a wrapper Callback * Build Callbacks for functions which takes two arguments * and potentially return a value. */ template -Callback make_callback (R (*fn_ptr) (T1,T2)) { - return Callback (fn_ptr); +Callback makeCallback (R (*fnPtr) (T1,T2)) { + return Callback (fnPtr); } /** - * \ingroup make_callback - * \param fn_ptr function pointer + * \ingroup makeCallback + * \param fnPtr function pointer * \return a wrapper Callback * Build Callbacks for functions which takes three arguments * and potentially return a value. */ template -Callback make_callback (R (*fn_ptr) (T1,T2,T3)) { - return Callback (fn_ptr); +Callback makeCallback (R (*fnPtr) (T1,T2,T3)) { + return Callback (fnPtr); } /** - * \ingroup make_callback - * \param fn_ptr function pointer + * \ingroup makeCallback + * \param fnPtr function pointer * \return a wrapper Callback * Build Callbacks for functions which takes four arguments * and potentially return a value. */ template -Callback make_callback (R (*fn_ptr) (T1,T2,T3,T4)) { - return Callback (fn_ptr); +Callback makeCallback (R (*fnPtr) (T1,T2,T3,T4)) { + return Callback (fnPtr); } /** - * \ingroup make_callback - * \param fn_ptr function pointer + * \ingroup makeCallback + * \param fnPtr function pointer * \return a wrapper Callback * Build Callbacks for functions which takes five arguments * and potentially return a value. */ template -Callback make_callback (R (*fn_ptr) (T1,T2,T3,T4,T5)) { - return Callback (fn_ptr); +Callback makeCallback (R (*fnPtr) (T1,T2,T3,T4,T5)) { + return Callback (fnPtr); } /** - * \ingroup make_callback + * \ingroup makeCallback * \return a wrapper Callback * Build a null callback which takes no arguments * and potentially return a value. */ template -Callback make_null_callback (void) { +Callback makeNullCallback (void) { return Callback (); } /** - * \ingroup make_callback + * \ingroup makeCallback * \return a wrapper Callback * Build a null callback which takes one argument * and potentially return a value. */ template -Callback make_null_callback (void) { +Callback makeNullCallback (void) { return Callback (); } /** - * \ingroup make_callback + * \ingroup makeCallback * \return a wrapper Callback * Build a null callback which takes two arguments * and potentially return a value. */ template -Callback make_null_callback (void) { +Callback makeNullCallback (void) { return Callback (); } /** - * \ingroup make_callback + * \ingroup makeCallback * \return a wrapper Callback * Build a null callback which takes three arguments * and potentially return a value. */ template -Callback make_null_callback (void) { +Callback makeNullCallback (void) { return Callback (); } /** - * \ingroup make_callback + * \ingroup makeCallback * \return a wrapper Callback * Build a null callback which takes four arguments * and potentially return a value. */ template -Callback make_null_callback (void) { +Callback makeNullCallback (void) { return Callback (); } /** - * \ingroup make_callback + * \ingroup makeCallback * \return a wrapper Callback * Build a null callback which takes five arguments * and potentially return a value. */ template -Callback make_null_callback (void) { +Callback makeNullCallback (void) { return Callback (); } template -Callback make_bound_callback (R (*fn_ptr) (TX,T1), TX a) { +Callback makeBoundCallback (R (*fnPtr) (TX,T1), TX a) { ReferenceList*> impl = ReferenceList*> ( - new BoundFunctorCallbackImpl (fn_ptr, a) + new BoundFunctorCallbackImpl (fnPtr, a) ); return Callback (impl); } template -Callback make_bound_callback (R (*fn_ptr) (TX,T1,T2), TX a) { +Callback makeBoundCallback (R (*fnPtr) (TX,T1,T2), TX a) { ReferenceList*> impl = ReferenceList*> ( - new BoundFunctorCallbackImpl (fn_ptr, a) + new BoundFunctorCallbackImpl (fnPtr, a) ); return Callback (impl); } template -Callback make_bound_callback (R (*fn_ptr) (TX,T1,T2,T3,T4), TX a) { +Callback makeBoundCallback (R (*fnPtr) (TX,T1,T2,T3,T4), TX a) { ReferenceList*> impl = ReferenceList*> ( - new BoundFunctorCallbackImpl (fn_ptr, a) + new BoundFunctorCallbackImpl (fnPtr, a) ); return Callback (impl); } template -Callback make_bound_callback (R (*fn_ptr) (TX,T1,T2,T3,T4,T5), TX a) { +Callback makeBoundCallback (R (*fnPtr) (TX,T1,T2,T3,T4,T5), TX a) { ReferenceList*> impl = ReferenceList*> ( - new BoundFunctorCallbackImpl (fn_ptr, a) + new BoundFunctorCallbackImpl (fnPtr, a) ); return Callback (impl); } diff --git a/src/core/reference-list-test.cc b/src/core/reference-list-test.cc index 00ca9f9c9..71ea00cd9 100644 --- a/src/core/reference-list-test.cc +++ b/src/core/reference-list-test.cc @@ -51,7 +51,7 @@ public: class RefTest : public ns3::Test { public: RefTest (); - virtual bool run_tests (void); + virtual bool runTests (void); private: void test (ns3::ReferenceList); }; @@ -67,7 +67,7 @@ RefTest::test (ns3::ReferenceList a) } bool -RefTest::run_tests (void) +RefTest::runTests (void) { bool ok = true; @@ -113,7 +113,7 @@ RefTest::run_tests (void) } -static RefTest g_ref_test = RefTest (); +static RefTest gRefTest = RefTest (); }; // namespace diff --git a/src/core/reference-list.h b/src/core/reference-list.h index 1849e3154..d3054083b 100644 --- a/src/core/reference-list.h +++ b/src/core/reference-list.h @@ -52,7 +52,7 @@ public: { m_prev = this; m_next = this; - insert_self_in_other (o); + insertSelfInOther (o); } ReferenceList (ReferenceList const&o) : m_objPtr (), @@ -61,10 +61,10 @@ public: { m_prev = this; m_next = this; - insert_self_in_other (o); + insertSelfInOther (o); } - ReferenceList (OBJ_PTR const &obj_ptr) - : m_objPtr (obj_ptr), + ReferenceList (OBJ_PTR const &objPtr) + : m_objPtr (objPtr), m_prev (), m_next () { @@ -72,33 +72,33 @@ public: m_next = this; } ~ReferenceList () { - remove_from_list (); + removeFrom_list (); } ReferenceList & operator= (ReferenceList const&o) { - remove_from_list (); - insert_self_in_other (o); + removeFrom_list (); + insertSelfInOther (o); return *this; } OBJ_PTR operator-> () { return m_objPtr; } - void set (OBJ_PTR obj_ptr) { - remove_from_list (); - m_objPtr = obj_ptr; + void set (OBJ_PTR objPtr) { + removeFrom_list (); + m_objPtr = objPtr; } OBJ_PTR get (void) { // explicit conversion to raw pointer type. return m_objPtr; } private: - void insert_self_in_other (ReferenceList const&o) { + void insertSelfInOther (ReferenceList const&o) { m_prev = &o; m_next = o.m_next; m_next->m_prev = this; o.m_next = this; m_objPtr = o.m_objPtr; } - void remove_from_list (void) { + void removeFrom_list (void) { if (m_prev == this) { //assert (m_next == this); delete m_objPtr; diff --git a/src/core/test.cc b/src/core/test.cc index 7af109fea..dd0a998e2 100644 --- a/src/core/test.cc +++ b/src/core/test.cc @@ -51,7 +51,7 @@ TestManager::add (Test *test, char const *name) get ()->m_tests.push_back (std::make_pair (test, new std::string (name))); } void -TestManager::enable_verbose (void) +TestManager::enableVerbose (void) { get ()->m_verbose = true; } @@ -61,31 +61,31 @@ TestManager::failure (void) return std::cerr; } bool -TestManager::run_tests (void) +TestManager::runTests (void) { - return get ()->real_run_tests (); + return get ()->realRunTests (); } bool -TestManager::real_run_tests (void) +TestManager::realRunTests (void) { - bool is_success = true; + bool isSuccess = true; for (TestsCI i = m_tests.begin (); i != m_tests.end (); i++) { - std::string *test_name = (*i).second; - if (!(*i).first->run_tests ()) { - is_success = false; + std::string *testName = (*i).second; + if (!(*i).first->runTests ()) { + isSuccess = false; if (m_verbose) { - std::cerr << "FAIL " << *test_name << std::endl; + std::cerr << "FAIL " << *testName << std::endl; } } else { if (m_verbose) { - std::cerr << "PASS "<<*test_name << std::endl; + std::cerr << "PASS "<<*testName << std::endl; } } } - if (!is_success) { + if (!isSuccess) { std::cerr << "FAIL" << std::endl; } - return is_success; + return isSuccess; } Test::Test (char const *name) diff --git a/src/core/test.h b/src/core/test.h index f9f4d363d..5c09c37b4 100644 --- a/src/core/test.h +++ b/src/core/test.h @@ -38,7 +38,7 @@ public: Test (char const *name); virtual ~Test (); - virtual bool run_tests (void) = 0; + virtual bool runTests (void) = 0; protected: std::ostream &failure (void); @@ -48,15 +48,15 @@ class TestManager { public: // main methods the test runner is supposed to // invoke. - static void enable_verbose (void); - static bool run_tests (void); + static void enableVerbose (void); + static bool runTests (void); // helper methods static void add (Test *test, char const *name); static std::ostream &failure (void); private: static TestManager *get (void); - bool real_run_tests (void); + bool realRunTests (void); TestManager (); ~TestManager (); diff --git a/src/core/unix-system-file.cc b/src/core/unix-system-file.cc index ea2ad593f..ba7598298 100644 --- a/src/core/unix-system-file.cc +++ b/src/core/unix-system-file.cc @@ -82,11 +82,11 @@ void SystemFilePrivate::write (uint8_t *buffer, uint32_t size) { while (size > 0) { - uint32_t to_copy = min (BUFFER_SIZE - m_current, size); - memcpy (m_data + m_current, buffer, to_copy); - size -= to_copy; - m_current += to_copy; - buffer += to_copy; + uint32_t toCopy = min (BUFFER_SIZE - m_current, size); + memcpy (m_data + m_current, buffer, toCopy); + size -= toCopy; + m_current += toCopy; + buffer += toCopy; if (m_current == BUFFER_SIZE) { ssize_t written = 0; written = ::write (m_fd, m_data, BUFFER_SIZE); diff --git a/src/simulator/event-id.cc b/src/simulator/event-id.cc index 282b0fbb5..37c68a99c 100644 --- a/src/simulator/event-id.cc +++ b/src/simulator/event-id.cc @@ -40,22 +40,22 @@ EventId::cancel (void) Simulator::cancel (*this); } bool -EventId::is_expired (void) +EventId::isExpired (void) { - return Simulator::is_expired (*this); + return Simulator::isExpired (*this); } EventImpl * -EventId::get_event_impl (void) const +EventId::getEventImpl (void) const { return m_eventImpl; } uint64_t -EventId::get_ns (void) const +EventId::getNs (void) const { return m_ns; } uint32_t -EventId::get_uid (void) const +EventId::getUid (void) const { return m_uid; } diff --git a/src/simulator/event-id.h b/src/simulator/event-id.h index 73f85b575..06af82af9 100644 --- a/src/simulator/event-id.h +++ b/src/simulator/event-id.h @@ -32,15 +32,15 @@ public: EventId (); EventId (EventImpl *impl, uint64_t ns, uint32_t uid); void cancel (void); - bool is_expired (void); + bool isExpired (void); public: /* The following methods are semi-private * they are supposed to be invoked only by * subclasses of the Scheduler base class. */ - EventImpl *get_event_impl (void) const; - uint64_t get_ns (void) const; - uint32_t get_uid (void) const; + EventImpl *getEventImpl (void) const; + uint64_t getNs (void) const; + uint32_t getUid (void) const; private: EventImpl *m_eventImpl; uint64_t m_ns; diff --git a/src/simulator/event-impl.cc b/src/simulator/event-impl.cc index d9122848c..16d13197b 100644 --- a/src/simulator/event-impl.cc +++ b/src/simulator/event-impl.cc @@ -40,12 +40,12 @@ EventImpl::invoke (void) } } void -EventImpl::set_internal_iterator (void *tag) +EventImpl::setInternalIterator (void *tag) { m_internalIterator = tag; } void * -EventImpl::get_internal_iterator (void) const +EventImpl::getInternalIterator (void) const { return m_internalIterator; } diff --git a/src/simulator/event-impl.h b/src/simulator/event-impl.h index 442dd776d..2b2a81176 100644 --- a/src/simulator/event-impl.h +++ b/src/simulator/event-impl.h @@ -31,8 +31,8 @@ public: virtual ~EventImpl () = 0; void invoke (void); void cancel (void); - void set_internal_iterator (void *iterator); - void *get_internal_iterator (void) const; + void setInternalIterator (void *iterator); + void *getInternalIterator (void) const; protected: virtual void notify (void) = 0; private: diff --git a/src/simulator/scheduler-factory.cc b/src/simulator/scheduler-factory.cc index c1254a55a..6e268fff6 100644 --- a/src/simulator/scheduler-factory.cc +++ b/src/simulator/scheduler-factory.cc @@ -28,7 +28,7 @@ SchedulerFactory::~SchedulerFactory () Scheduler * SchedulerFactory::create (void) const { - return real_create (); + return realCreate (); } }; // namespace ns3 diff --git a/src/simulator/scheduler-factory.h b/src/simulator/scheduler-factory.h index e9bbe16ac..b6088f0e0 100644 --- a/src/simulator/scheduler-factory.h +++ b/src/simulator/scheduler-factory.h @@ -31,7 +31,7 @@ class Scheduler; * If you want to make the core simulation engine use a new * event scheduler without editing the code of the simulator, * you need to create a subclass of this base class and implement - * the ns3::SchedulerFactory::real_create method. + * the ns3::SchedulerFactory::realCreate method. */ class SchedulerFactory { public: @@ -42,7 +42,7 @@ private: * \returns a newly-created scheduler. The caller takes * ownership of the returned pointer. */ - virtual Scheduler *real_create (void) const = 0; + virtual Scheduler *realCreate (void) const = 0; }; }; // namespace ns3 diff --git a/src/simulator/scheduler-heap.cc b/src/simulator/scheduler-heap.cc index 1644d209d..a2cd4bbb5 100644 --- a/src/simulator/scheduler-heap.cc +++ b/src/simulator/scheduler-heap.cc @@ -56,22 +56,22 @@ SchedulerHeap::SchedulerHeap () // we purposedly waste an item at the start of // the array to make sure the indexes in the // array start at one. - Scheduler::EventKey empty_key = {0,0}; - m_heap.push_back (std::make_pair (static_cast(0), empty_key)); + Scheduler::EventKey emptyKey = {0,0}; + m_heap.push_back (std::make_pair (static_cast(0), emptyKey)); } SchedulerHeap::~SchedulerHeap () {} void -SchedulerHeap::store_in_event (EventImpl *ev, uint32_t index) const +SchedulerHeap::storeInEvent (EventImpl *ev, uint32_t index) const { - ev->set_internal_iterator ((void *)index); + ev->setInternalIterator ((void *)index); } uint32_t -SchedulerHeap::get_from_event (EventImpl *ev) const +SchedulerHeap::getFrom_event (EventImpl *ev) const { - return (uint32_t)ev->get_internal_iterator (); + return (uint32_t)ev->getInternalIterator (); } uint32_t SchedulerHeap::parent (uint32_t id) const @@ -84,12 +84,12 @@ SchedulerHeap::sibling (uint32_t id) const return id + 1; } uint32_t -SchedulerHeap::left_child (uint32_t id) const +SchedulerHeap::leftChild (uint32_t id) const { return id * 2; } uint32_t -SchedulerHeap::right_child (uint32_t id) const +SchedulerHeap::rightChild (uint32_t id) const { return id * 2 + 1; } @@ -101,7 +101,7 @@ SchedulerHeap::root (void) const } bool -SchedulerHeap::is_root (uint32_t id) const +SchedulerHeap::isRoot (uint32_t id) const { return (id == root ())?true:false; } @@ -114,7 +114,7 @@ SchedulerHeap::last (void) const bool -SchedulerHeap::is_bottom (uint32_t id) const +SchedulerHeap::isBottom (uint32_t id) const { return (id >= m_heap.size ())?true:false; } @@ -127,12 +127,12 @@ SchedulerHeap::exch (uint32_t a, uint32_t b) std::pair tmp (m_heap[a]); m_heap[a] = m_heap[b]; m_heap[b] = tmp; - store_in_event (m_heap[a].first, a); - store_in_event (m_heap[b].first, b); + storeInEvent (m_heap[a].first, a); + storeInEvent (m_heap[b].first, b); } bool -SchedulerHeap::is_less (uint32_t a, uint32_t b) +SchedulerHeap::isLess (uint32_t a, uint32_t b) { Scheduler::EventKeyCompare compare; return compare (m_heap[a].second, m_heap[b].second); @@ -141,11 +141,11 @@ SchedulerHeap::is_less (uint32_t a, uint32_t b) uint32_t SchedulerHeap::smallest (uint32_t a, uint32_t b) { - return is_less (a,b)?a:b; + return isLess (a,b)?a:b; } bool -SchedulerHeap::real_is_empty (void) const +SchedulerHeap::realIsEmpty (void) const { return (m_heap.size () == 1)?true:false; } @@ -154,37 +154,37 @@ void SchedulerHeap::bottom_up (void) { uint32_t index = last (); - while (!is_root (index) && - is_less (index, parent (index))) { + while (!isRoot (index) && + isLess (index, parent (index))) { exch(index, parent (index)); index = parent (index); } } void -SchedulerHeap::top_down (void) +SchedulerHeap::topDown (void) { uint32_t index = root (); - uint32_t right = right_child (index); - while (!is_bottom (right)) { - uint32_t left = left_child (index); + uint32_t right = rightChild (index); + while (!isBottom (right)) { + uint32_t left = leftChild (index); uint32_t tmp = smallest (left, right); - if (is_less (index, tmp)) { + if (isLess (index, tmp)) { return; } exch (index, tmp); index = tmp; - right = right_child (index); + right = rightChild (index); } - if (is_bottom (index)) { + if (isBottom (index)) { return; } - assert (!is_bottom (index)); - uint32_t left = left_child (index); - if (is_bottom (left)) { + assert (!isBottom (index)); + uint32_t left = leftChild (index); + if (isBottom (left)) { return; } - if (is_less (index, left)) { + if (isLess (index, left)) { return; } exch (index, left); @@ -192,52 +192,52 @@ SchedulerHeap::top_down (void) EventId -SchedulerHeap::real_insert (EventImpl *event, Scheduler::EventKey key) +SchedulerHeap::realInsert (EventImpl *event, Scheduler::EventKey key) { m_heap.push_back (std::make_pair (event, key)); bottom_up (); - store_in_event (event, last ()); + storeInEvent (event, last ()); return EventId (event, key.m_ns, key.m_uid); } EventImpl * -SchedulerHeap::real_peek_next (void) const +SchedulerHeap::realPeekNext (void) const { return m_heap[root ()].first; } Scheduler::EventKey -SchedulerHeap::real_peek_next_key (void) const +SchedulerHeap::realPeekNextKey (void) const { return m_heap[root ()].second; } void -SchedulerHeap::real_remove_next (void) +SchedulerHeap::realRemoveNext (void) { exch (root (), last ()); m_heap.pop_back (); - top_down (); + topDown (); } EventImpl * -SchedulerHeap::real_remove (EventId id, Scheduler::EventKey *key) +SchedulerHeap::realRemove (EventId id, Scheduler::EventKey *key) { - EventImpl *ev = id.get_event_impl (); - uint32_t i = get_from_event (ev); + EventImpl *ev = id.getEventImpl (); + uint32_t i = getFrom_event (ev); *key = m_heap[i].second; exch (i, last ()); m_heap.pop_back (); - top_down (); + topDown (); return ev; } bool -SchedulerHeap::real_is_valid (EventId id) +SchedulerHeap::realIsValid (EventId id) { - EventImpl *ev = id.get_event_impl (); - uint32_t i = get_from_event (ev); + EventImpl *ev = id.getEventImpl (); + uint32_t i = getFrom_event (ev); Scheduler::EventKey key = m_heap[i].second; - return (key.m_ns == id.get_ns () && - key.m_uid == id.get_uid ()); + return (key.m_ns == id.getNs () && + key.m_uid == id.getUid ()); } }; // namespace ns3 diff --git a/src/simulator/scheduler-heap.h b/src/simulator/scheduler-heap.h index cae81c87e..1b5d4fa17 100644 --- a/src/simulator/scheduler-heap.h +++ b/src/simulator/scheduler-heap.h @@ -36,32 +36,32 @@ public: virtual ~SchedulerHeap (); private: - virtual EventId real_insert (EventImpl *event, Scheduler::EventKey key); - virtual bool real_is_empty (void) const; - virtual EventImpl *real_peek_next (void) const; - virtual Scheduler::EventKey real_peek_next_key (void) const; - virtual void real_remove_next (void); - virtual EventImpl *real_remove (EventId ev, Scheduler::EventKey *key); - virtual bool real_is_valid (EventId id); + virtual EventId realInsert (EventImpl *event, Scheduler::EventKey key); + virtual bool realIsEmpty (void) const; + virtual EventImpl *realPeekNext (void) const; + virtual Scheduler::EventKey realPeekNextKey (void) const; + virtual void realRemoveNext (void); + virtual EventImpl *realRemove (EventId ev, Scheduler::EventKey *key); + virtual bool realIsValid (EventId id); typedef std::vector > BinaryHeap; - inline void store_in_event (EventImpl *ev, uint32_t index) const; - uint32_t get_from_event (EventImpl *ev) const; + inline void storeInEvent (EventImpl *ev, uint32_t index) const; + uint32_t getFrom_event (EventImpl *ev) const; inline uint32_t parent (uint32_t id) const; uint32_t sibling (uint32_t id) const; - inline uint32_t left_child (uint32_t id) const; - inline uint32_t right_child (uint32_t id) const; + inline uint32_t leftChild (uint32_t id) const; + inline uint32_t rightChild (uint32_t id) const; inline uint32_t root (void) const; uint32_t last (void) const; - inline bool is_root (uint32_t id) const; - inline bool is_bottom (uint32_t id) const; - inline bool is_less (uint32_t a, uint32_t b); + inline bool isRoot (uint32_t id) const; + inline bool isBottom (uint32_t id) const; + inline bool isLess (uint32_t a, uint32_t b); inline uint32_t smallest (uint32_t a, uint32_t b); inline void exch (uint32_t a, uint32_t b); void bottom_up (void); - void top_down (void); + void topDown (void); BinaryHeap m_heap; }; diff --git a/src/simulator/scheduler-list.cc b/src/simulator/scheduler-list.cc index b0d9c7a71..8546a75f2 100644 --- a/src/simulator/scheduler-list.cc +++ b/src/simulator/scheduler-list.cc @@ -38,81 +38,81 @@ SchedulerList::~SchedulerList () * member variable, a pointer. */ EventId -SchedulerList::get_event_id (Scheduler::EventKey key, EventsI i) +SchedulerList::getEventId (Scheduler::EventKey key, EventsI i) { assert (sizeof (i) <= sizeof (void *)); - void *internal_iterator; - memcpy ((char *)&(internal_iterator), (char *)&i, sizeof (void *)); + void *internalIterator; + memcpy ((char *)&(internalIterator), (char *)&i, sizeof (void *)); EventImpl *ev = i->first; - ev->set_internal_iterator (internal_iterator); + ev->setInternalIterator (internalIterator); return EventId (ev, key.m_ns, key.m_uid); } SchedulerList::EventsI -SchedulerList::get_iterator (EventId id) +SchedulerList::getIterator (EventId id) { SchedulerList::EventsI i; assert (sizeof (i) <= sizeof (void *)); - EventImpl *ev = id.get_event_impl (); - void *internal_iterator = ev->get_internal_iterator (); - memcpy ((char *)&i, (char *)&(internal_iterator), sizeof (void *)); + EventImpl *ev = id.getEventImpl (); + void *internalIterator = ev->getInternalIterator (); + memcpy ((char *)&i, (char *)&(internalIterator), sizeof (void *)); return i; } EventId -SchedulerList::real_insert (EventImpl *event, Scheduler::EventKey key) +SchedulerList::realInsert (EventImpl *event, Scheduler::EventKey key) { Scheduler::EventKeyCompare compare; for (EventsI i = m_events.begin (); i != m_events.end (); i++) { if (compare (key, i->second)) { m_events.insert (i, std::make_pair (event, key)); - return get_event_id (key, i); + return getEventId (key, i); } } m_events.push_back (std::make_pair (event, key)); - return get_event_id (key, --(m_events.end ())); + return getEventId (key, --(m_events.end ())); } bool -SchedulerList::real_is_empty (void) const +SchedulerList::realIsEmpty (void) const { return m_events.empty (); } EventImpl * -SchedulerList::real_peek_next (void) const +SchedulerList::realPeekNext (void) const { return m_events.front ().first; } Scheduler::EventKey -SchedulerList::real_peek_next_key (void) const +SchedulerList::realPeekNextKey (void) const { return m_events.front ().second; } void -SchedulerList::real_remove_next (void) +SchedulerList::realRemoveNext (void) { m_events.pop_front (); } EventImpl * -SchedulerList::real_remove (EventId id, Scheduler::EventKey *key) +SchedulerList::realRemove (EventId id, Scheduler::EventKey *key) { - EventsI i = get_iterator (id); + EventsI i = getIterator (id); *key = i->second; - assert (key->m_ns == id.get_ns () && - key->m_uid == id.get_uid ()); + assert (key->m_ns == id.getNs () && + key->m_uid == id.getUid ()); EventImpl *ev = i->first; m_events.erase (i); return ev; } bool -SchedulerList::real_is_valid (EventId id) +SchedulerList::realIsValid (EventId id) { - EventsI i = get_iterator (id); + EventsI i = getIterator (id); Scheduler::EventKey key = i->second; - return (key.m_ns == id.get_ns () && - key.m_uid == id.get_uid ()); + return (key.m_ns == id.getNs () && + key.m_uid == id.getUid ()); } diff --git a/src/simulator/scheduler-list.h b/src/simulator/scheduler-list.h index b840bcd26..e6de24f32 100644 --- a/src/simulator/scheduler-list.h +++ b/src/simulator/scheduler-list.h @@ -38,18 +38,18 @@ class SchedulerList : public Scheduler { virtual ~SchedulerList (); private: - virtual EventId real_insert (EventImpl *event, EventKey key); - virtual bool real_is_empty (void) const; - virtual EventImpl *real_peek_next (void) const; - virtual Scheduler::EventKey real_peek_next_key (void) const; - virtual void real_remove_next (void); - virtual EventImpl *real_remove (EventId ev, Scheduler::EventKey *key); - virtual bool real_is_valid (EventId id); + virtual EventId realInsert (EventImpl *event, EventKey key); + virtual bool realIsEmpty (void) const; + virtual EventImpl *realPeekNext (void) const; + virtual Scheduler::EventKey realPeekNextKey (void) const; + virtual void realRemoveNext (void); + virtual EventImpl *realRemove (EventId ev, Scheduler::EventKey *key); + virtual bool realIsValid (EventId id); typedef std::list > Events; typedef std::list >::iterator EventsI; - EventId get_event_id (Scheduler::EventKey key, EventsI i); - EventsI get_iterator (EventId id); + EventId getEventId (Scheduler::EventKey key, EventsI i); + EventsI getIterator (EventId id); Events m_events; }; diff --git a/src/simulator/scheduler-map.cc b/src/simulator/scheduler-map.cc index 0a0f64175..9d2016cd9 100644 --- a/src/simulator/scheduler-map.cc +++ b/src/simulator/scheduler-map.cc @@ -45,72 +45,72 @@ SchedulerMap::~SchedulerMap () void -SchedulerMap::store_in_event (EventImpl *ev, EventMapI i) const +SchedulerMap::storeInEvent (EventImpl *ev, EventMapI i) const { void *tag; memcpy (&(tag), &i, sizeof (tag)); - ev->set_internal_iterator (tag); + ev->setInternalIterator (tag); } SchedulerMap::EventMapI -SchedulerMap::get_from_event (EventImpl *ev) const +SchedulerMap::getFrom_event (EventImpl *ev) const { EventMapI i; - void *tag = ev->get_internal_iterator (); + void *tag = ev->getInternalIterator (); memcpy (&i, &(tag), sizeof (i)); return i; } EventId -SchedulerMap::real_insert (EventImpl *event, Scheduler::EventKey key) +SchedulerMap::realInsert (EventImpl *event, Scheduler::EventKey key) { std::pair result = m_list.insert (std::make_pair (key, event)); assert (result.second); - store_in_event (event, result.first); + storeInEvent (event, result.first); return EventId (event, key.m_ns, key.m_uid); } bool -SchedulerMap::real_is_empty (void) const +SchedulerMap::realIsEmpty (void) const { return m_list.empty (); } EventImpl * -SchedulerMap::real_peek_next (void) const +SchedulerMap::realPeekNext (void) const { EventMapCI i = m_list.begin (); assert (i != m_list.end ()); return (*i).second; } Scheduler::EventKey -SchedulerMap::real_peek_next_key (void) const +SchedulerMap::realPeekNextKey (void) const { EventMapCI i = m_list.begin (); assert (i != m_list.end ()); return (*i).first; } void -SchedulerMap::real_remove_next (void) +SchedulerMap::realRemoveNext (void) { m_list.erase (m_list.begin ()); } EventImpl * -SchedulerMap::real_remove (EventId id, Scheduler::EventKey *key) +SchedulerMap::realRemove (EventId id, Scheduler::EventKey *key) { - EventMapI i = get_from_event (id.get_event_impl ()); + EventMapI i = getFrom_event (id.getEventImpl ()); *key = i->first; m_list.erase (i); return i->second; } bool -SchedulerMap::real_is_valid (EventId id) +SchedulerMap::realIsValid (EventId id) { - EventMapI i = get_from_event (id.get_event_impl ()); + EventMapI i = getFrom_event (id.getEventImpl ()); Scheduler::EventKey key = i->first; - return (key.m_ns == id.get_ns () && - key.m_uid == id.get_uid ()); + return (key.m_ns == id.getNs () && + key.m_uid == id.getUid ()); } diff --git a/src/simulator/scheduler-map.h b/src/simulator/scheduler-map.h index 0e95ddf20..90afdbd0a 100644 --- a/src/simulator/scheduler-map.h +++ b/src/simulator/scheduler-map.h @@ -37,20 +37,20 @@ public: virtual ~SchedulerMap (); private: - virtual EventId real_insert (EventImpl *event, Scheduler::EventKey key); - virtual bool real_is_empty (void) const; - virtual EventImpl *real_peek_next (void) const; - virtual Scheduler::EventKey real_peek_next_key (void) const; - virtual void real_remove_next (void); - virtual EventImpl *real_remove (EventId ev, Scheduler::EventKey *key); - virtual bool real_is_valid (EventId id); + virtual EventId realInsert (EventImpl *event, Scheduler::EventKey key); + virtual bool realIsEmpty (void) const; + virtual EventImpl *realPeekNext (void) const; + virtual Scheduler::EventKey realPeekNextKey (void) const; + virtual void realRemoveNext (void); + virtual EventImpl *realRemove (EventId ev, Scheduler::EventKey *key); + virtual bool realIsValid (EventId id); typedef std::map EventMap; typedef std::map::iterator EventMapI; typedef std::map::const_iterator EventMapCI; - void store_in_event (EventImpl *ev, EventMapI i) const; - SchedulerMap::EventMapI get_from_event (EventImpl *ev) const; + void storeInEvent (EventImpl *ev, EventMapI i) const; + SchedulerMap::EventMapI getFrom_event (EventImpl *ev) const; EventMap m_list; uint32_t m_uid; diff --git a/src/simulator/scheduler.cc b/src/simulator/scheduler.cc index 9aa5355d1..b6e065069 100644 --- a/src/simulator/scheduler.cc +++ b/src/simulator/scheduler.cc @@ -49,41 +49,41 @@ Scheduler::EventKeyCompare::operator () (struct EventKey a, struct EventKey b) EventId Scheduler::insert (EventImpl *event, struct EventKey key) { - return real_insert (event, key); + return realInsert (event, key); } bool -Scheduler::is_empty (void) const +Scheduler::isEmpty (void) const { - return real_is_empty (); + return realIsEmpty (); } EventImpl * -Scheduler::peek_next (void) const +Scheduler::peekNext (void) const { - assert (!real_is_empty ()); - return real_peek_next (); + assert (!realIsEmpty ()); + return realPeekNext (); } Scheduler::EventKey -Scheduler::peek_next_key (void) const +Scheduler::peekNextKey (void) const { - assert (!real_is_empty ()); - return real_peek_next_key (); + assert (!realIsEmpty ()); + return realPeekNextKey (); } void -Scheduler::remove_next (void) +Scheduler::removeNext (void) { - assert (!real_is_empty ()); - return real_remove_next (); + assert (!realIsEmpty ()); + return realRemoveNext (); } EventImpl * Scheduler::remove (EventId id, EventKey *key) { - assert (!real_is_empty ()); - return real_remove (id, key); + assert (!realIsEmpty ()); + return realRemove (id, key); } bool -Scheduler::is_valid (EventId id) +Scheduler::isValid (EventId id) { - return real_is_valid (id); + return realIsValid (id); } }; // namespace ns3 diff --git a/src/simulator/scheduler.h b/src/simulator/scheduler.h index 408bbbcbe..2d53abd99 100644 --- a/src/simulator/scheduler.h +++ b/src/simulator/scheduler.h @@ -36,18 +36,18 @@ class EventImpl; * event list. If you want to provide a new event list scheduler, * you need to create a subclass of this base class and implement * all the private pure virtual methods defined here. Namely: - * - ns3::Scheduler::real_insert - * - ns3::Scheduler::real_is_empty - * - ns3::Scheduler::real_peek_next - * - ns3::Scheduler::real_peek_next_key - * - ns3::Scheduler::real_remove_next - * - ns3::Scheduler::real_remove - * - ns3::Scheduler::real_is_valid + * - ns3::Scheduler::realInsert + * - ns3::Scheduler::realIsEmpty + * - ns3::Scheduler::realPeekNext + * - ns3::Scheduler::realPeekNextKey + * - ns3::Scheduler::realRemoveNext + * - ns3::Scheduler::realRemove + * - ns3::Scheduler::realIsValid * * If you need to provide a new event list scheduler without * editing the main simulator class, you need to also implement * a subclass of the ns3::SchedulerFactory base class and - * feed it to ns3::Simulator::set_external. + * feed it to ns3::Simulator::setExternal. */ class Scheduler { public: @@ -63,12 +63,12 @@ class Scheduler { virtual ~Scheduler () = 0; EventId insert (EventImpl *event, EventKey key); - bool is_empty (void) const; - EventImpl *peek_next (void) const; - Scheduler::EventKey peek_next_key (void) const ; - void remove_next (void); + bool isEmpty (void) const; + EventImpl *peekNext (void) const; + Scheduler::EventKey peekNextKey (void) const ; + void removeNext (void); EventImpl *remove (EventId id, EventKey *key); - bool is_valid (EventId id); + bool isValid (EventId id); private: /** @@ -78,29 +78,29 @@ private: * * This method takes ownership of the event pointer. */ - virtual EventId real_insert (EventImpl *event, EventKey key) = 0; + virtual EventId realInsert (EventImpl *event, EventKey key) = 0; /** * \returns true if the event list is empty and false otherwise. */ - virtual bool real_is_empty (void) const = 0; + virtual bool realIsEmpty (void) const = 0; /** * \returns a pointer to the next earliest event. The caller * takes ownership of the returned pointer. * * This method cannot be invoked if the list is empty. */ - virtual EventImpl *real_peek_next (void) const = 0; + virtual EventImpl *realPeekNext (void) const = 0; /** * \returns the timecode associated with the next earliest event. * * This method cannot be invoked if the list is empty. */ - virtual Scheduler::EventKey real_peek_next_key (void) const = 0; + virtual Scheduler::EventKey realPeekNextKey (void) const = 0; /** * This method cannot be invoked if the list is empty. * Remove the next earliest event from the event list. */ - virtual void real_remove_next (void) = 0; + virtual void realRemoveNext (void) = 0; /** * \param id the id of the event to remove * \param key the timecode of the event removed @@ -109,13 +109,13 @@ private: * * This methods cannot be invoked if the list is empty. */ - virtual EventImpl *real_remove (EventId id, EventKey *key) = 0; + virtual EventImpl *realRemove (EventId id, EventKey *key) = 0; /** * \param id event id to validate * \returns true if the event id identifies an existing valid * event stored in the event list and false otherwise. */ - virtual bool real_is_valid (EventId id) = 0; + virtual bool realIsValid (EventId id) = 0; }; }; // namespace ns3 diff --git a/src/simulator/simulator.cc b/src/simulator/simulator.cc index c34d716ad..f1b4b1a2d 100644 --- a/src/simulator/simulator.cc +++ b/src/simulator/simulator.cc @@ -35,7 +35,7 @@ #ifdef TRACE_SIMU #include # define TRACE(x) \ -std::cout << "SIMU TRACE " << Simulator::now_s () << " " << x << std::endl; +std::cout << "SIMU TRACE " << Simulator::nowS () << " " << x << std::endl; # define TRACE_S(x) \ std::cout << "SIMU TRACE " << x << std::endl; #else /* TRACE_SIMU */ @@ -52,21 +52,21 @@ public: SimulatorPrivate (Scheduler *events); ~SimulatorPrivate (); - void enable_log_to (char const *filename); + void enableLogTo (char const *filename); - bool is_finished (void) const; + bool isFinished (void) const; Time next (void) const; void stop (void); - void stop_at (Time time); + void stopAt (Time time); EventId schedule (Time time, EventImpl *event); void remove (EventId ev); void cancel (EventId ev); - bool is_expired (EventId ev); + bool isExpired (EventId ev); void run (void); Time now (void) const; private: - void process_one_event (void); + void processOneEvent (void); typedef std::list > Events; Events m_destroy; @@ -109,48 +109,48 @@ SimulatorPrivate::~SimulatorPrivate () void -SimulatorPrivate::enable_log_to (char const *filename) +SimulatorPrivate::enableLogTo (char const *filename) { m_log.open (filename); m_logEnable = true; } void -SimulatorPrivate::process_one_event (void) +SimulatorPrivate::processOneEvent (void) { - EventImpl *next_ev = m_events->peek_next (); - Scheduler::EventKey next_key = m_events->peek_next_key (); - m_events->remove_next (); - TRACE ("handle " << next_ev); - m_currentNs = next_key.m_ns; - m_currentUid = next_key.m_uid; + EventImpl *nextEv = m_events->peekNext (); + Scheduler::EventKey nextKey = m_events->peekNextKey (); + m_events->removeNext (); + TRACE ("handle " << nextEv); + m_currentNs = nextKey.m_ns; + m_currentUid = nextKey.m_uid; if (m_logEnable) { - m_log << "e "<invoke (); - delete next_ev; + nextEv->invoke (); + delete nextEv; } bool -SimulatorPrivate::is_finished (void) const +SimulatorPrivate::isFinished (void) const { - return m_events->is_empty (); + return m_events->isEmpty (); } Time SimulatorPrivate::next (void) const { - assert (!m_events->is_empty ()); - Scheduler::EventKey next_key = m_events->peek_next_key (); - return Time::abs_ns (next_key.m_ns); + assert (!m_events->isEmpty ()); + Scheduler::EventKey nextKey = m_events->peekNextKey (); + return Time::absNs (nextKey.m_ns); } void SimulatorPrivate::run (void) { - while (!m_events->is_empty () && !m_stop && + while (!m_events->isEmpty () && !m_stop && (m_stopAt == 0 || m_stopAt > next ().ns ())) { - process_one_event (); + processOneEvent (); } m_log.close (); } @@ -162,14 +162,14 @@ SimulatorPrivate::stop (void) m_stop = true; } void -SimulatorPrivate::stop_at (Time at) +SimulatorPrivate::stopAt (Time at) { m_stopAt = at.ns (); } EventId SimulatorPrivate::schedule (Time time, EventImpl *event) { - if (time.is_destroy ()) { + if (time.isDestroy ()) { m_destroy.push_back (std::make_pair (event, m_uid)); if (m_logEnable) { m_log << "id " << m_currentUid << " " << now ().ns () << " " @@ -191,7 +191,7 @@ SimulatorPrivate::schedule (Time time, EventImpl *event) Time SimulatorPrivate::now (void) const { - return Time::abs_ns (m_currentNs); + return Time::absNs (m_currentNs); } void @@ -209,17 +209,17 @@ SimulatorPrivate::remove (EventId ev) void SimulatorPrivate::cancel (EventId id) { - assert (m_events->is_valid (id)); - EventImpl *ev = id.get_event_impl (); + assert (m_events->isValid (id)); + EventImpl *ev = id.getEventImpl (); ev->cancel (); } bool -SimulatorPrivate::is_expired (EventId ev) +SimulatorPrivate::isExpired (EventId ev) { - if (ev.get_event_impl () != 0 && - ev.get_ns () <= now ().ns () && - ev.get_uid () < m_currentUid) { + if (ev.getEventImpl () != 0 && + ev.getNs () <= now ().ns () && + ev.getUid () < m_currentUid) { return false; } return true; @@ -241,33 +241,33 @@ SimulatorPrivate *Simulator::m_priv = 0; Simulator::ListType Simulator::m_listType = LINKED_LIST; SchedulerFactory const*Simulator::m_schedFactory = 0; -void Simulator::set_linked_list (void) +void Simulator::setLinkedList (void) { m_listType = LINKED_LIST; } -void Simulator::set_binary_heap (void) +void Simulator::setBinaryHeap (void) { m_listType = BINARY_HEAP; } -void Simulator::set_std_map (void) +void Simulator::setStdMap (void) { m_listType = STD_MAP; } void -Simulator::set_external (SchedulerFactory const*factory) +Simulator::setExternal (SchedulerFactory const*factory) { assert (factory != 0); m_schedFactory = factory; m_listType = EXTERNAL; } -void Simulator::enable_log_to (char const *filename) +void Simulator::enableLogTo (char const *filename) { - get_priv ()->enable_log_to (filename); + getPriv ()->enableLogTo (filename); } SimulatorPrivate * -Simulator::get_priv (void) +Simulator::getPriv (void) { if (m_priv == 0) { Scheduler *events; @@ -303,60 +303,60 @@ Simulator::destroy (void) bool -Simulator::is_finished (void) +Simulator::isFinished (void) { - return get_priv ()->is_finished (); + return getPriv ()->isFinished (); } Time Simulator::next (void) { - return get_priv ()->next (); + return getPriv ()->next (); } void Simulator::run (void) { - get_priv ()->run (); + getPriv ()->run (); } void Simulator::stop (void) { TRACE ("stop"); - get_priv ()->stop (); + getPriv ()->stop (); } void -Simulator::stop_at (Time at) +Simulator::stopAt (Time at) { - get_priv ()->stop_at (at); + getPriv ()->stopAt (at); } Time Simulator::now (void) { - return get_priv ()->now (); + return getPriv ()->now (); } EventId Simulator::schedule (Time time, EventImpl *ev) { - return get_priv ()->schedule (time, ev); + return getPriv ()->schedule (time, ev); } void Simulator::remove (EventId ev) { - return get_priv ()->remove (ev); + return getPriv ()->remove (ev); } void Simulator::cancel (EventId ev) { - return get_priv ()->cancel (ev); + return getPriv ()->cancel (ev); } bool -Simulator::is_expired (EventId id) +Simulator::isExpired (EventId id) { - return get_priv ()->is_expired (id); + return getPriv ()->isExpired (id); } }; // namespace ns3 @@ -372,7 +372,7 @@ class SimulatorTests : public Test { public: SimulatorTests (); virtual ~SimulatorTests (); - virtual bool run_tests (void); + virtual bool runTests (void); private: void a (int a); void b (int b); @@ -404,7 +404,7 @@ SimulatorTests::b (int b) m_b = true; } Simulator::remove (m_idC); - Simulator::schedule (Time::rel_us (10), &SimulatorTests::d, this, 4); + Simulator::schedule (Time::relUs (10), &SimulatorTests::d, this, 4); } void SimulatorTests::c (int c) @@ -421,16 +421,16 @@ SimulatorTests::d (int d) } } bool -SimulatorTests::run_tests (void) +SimulatorTests::runTests (void) { bool ok = true; m_a = true; m_b = false; m_c = true; m_d = false; - EventId a = Simulator::schedule (Time::abs_us (10), &SimulatorTests::a, this, 1); - EventId b = Simulator::schedule (Time::abs_us (11), &SimulatorTests::b, this, 2); - m_idC = Simulator::schedule (Time::abs_us (12), &SimulatorTests::c, this, 3); + EventId a = Simulator::schedule (Time::absUs (10), &SimulatorTests::a, this, 1); + EventId b = Simulator::schedule (Time::absUs (11), &SimulatorTests::b, this, 2); + m_idC = Simulator::schedule (Time::absUs (12), &SimulatorTests::c, this, 3); Simulator::cancel (a); Simulator::run (); @@ -442,7 +442,7 @@ SimulatorTests::run_tests (void) return ok; } -SimulatorTests g_simulator_tests; +SimulatorTests gSimulatorTests; }; // namespace ns3 diff --git a/src/simulator/simulator.h b/src/simulator/simulator.h index 3e6009a83..4ffdbc40d 100644 --- a/src/simulator/simulator.h +++ b/src/simulator/simulator.h @@ -52,7 +52,7 @@ public: * - insert: O(n) * - remove: O(1) */ - static void set_linked_list (void); + static void setLinkedList (void); /** * Force the use of an event scheduler based on a binary heap. * This method must be invoked before any other method exported @@ -60,7 +60,7 @@ public: * - insert: O(log(n)) * - remove: O(log(n)) */ - static void set_binary_heap (void); + static void setBinaryHeap (void); /** * Force the use of an event scheduler based on a std::map. * This method must be invoked before any other method exported @@ -68,14 +68,14 @@ public: * - insert: O(log(n)) * - remove: O(log(n)) */ - static void set_std_map (void); + static void setStdMap (void); /** * Force the use of a user-provided event scheduler. * This method must be invoked before any other method exported * by the Simulator class. */ - static void set_external (SchedulerFactory const*factory); + static void setExternal (SchedulerFactory const*factory); /** * Enable logging to the file identified by filename. If the file @@ -90,10 +90,10 @@ public: * This method must be invoked before any call to Simulator::run * @param filename the name of the file to log to */ - static void enable_log_to (char const *filename); + static void enableLogTo (char const *filename); /** - * Every event scheduled by the Simulator::insert_at_destroy method is + * Every event scheduled by the Simulator::insertAtDestroy method is * invoked. Then, we ensure that any memory allocated by the * Simulator is freed. * This method is typically invoked at the end of a simulation @@ -109,9 +109,9 @@ public: * If there any any events lefts to be scheduled, return * true. Return false otherwise. */ - static bool is_finished (void); + static bool isFinished (void); /** - * If Simulator::is_finished returns true, the behavior of this + * If Simulator::isFinished returns true, the behavior of this * method is undefined. Otherwise, it returns the microsecond-based * time of the next event expected to be scheduled. */ @@ -121,7 +121,7 @@ public: * Run the simulation until one of: * - no events are present anymore * - the user called Simulator::stop - * - the user called Simulator::stop_at_us and the + * - the user called Simulator::stopAtUs and the * expiration time of the next event to be processed * is greater than or equal to the stop time. */ @@ -138,7 +138,7 @@ public: * is greater than or equal to the stop time. * @param at the stop time. */ - static void stop_at (Time time); + static void stopAt (Time time); /** * Schedule an event to expire at time. @@ -469,7 +469,7 @@ public: /* XXX */ - static bool is_expired (EventId id); + static bool isExpired (EventId id); /** * Return the "current time". */ @@ -477,7 +477,7 @@ public: private: Simulator (); ~Simulator (); - static SimulatorPrivate *get_priv (void); + static SimulatorPrivate *getPriv (void); static EventId schedule (Time time, EventImpl *event); static SimulatorPrivate *m_priv; static SchedulerFactory const*m_schedFactory; diff --git a/src/simulator/time.cc b/src/simulator/time.cc index aea902b86..5ef9e175e 100644 --- a/src/simulator/time.cc +++ b/src/simulator/time.cc @@ -64,41 +64,41 @@ Time::ns (void) const } bool -Time::is_destroy (void) const +Time::isDestroy (void) const { return m_isDestroy; } Time -Time::abs_s (double s) +Time::absS (double s) { int64_t ns = (int64_t)(s * 1000000000.0); return Time (ns); } Time -Time::abs_us (uint64_t us) +Time::absUs (uint64_t us) { int64_t ns = us * 1000; return Time (ns); } Time -Time::abs_ns (uint64_t ns) +Time::absNs (uint64_t ns) { return Time (ns); } Time -Time::rel_s (double s) +Time::relS (double s) { int64_t ns = (int64_t)(s * 1000000000.0); return Time (Simulator::now ().ns () + ns); } Time -Time::rel_us (uint64_t us) +Time::relUs (uint64_t us) { return Time (Simulator::now ().ns () + us * 1000); } Time -Time::rel_ns (uint64_t ns) +Time::relNs (uint64_t ns) { return Time (Simulator::now ().ns () + ns); } diff --git a/src/simulator/time.h b/src/simulator/time.h index ab320fb77..7a4ddac0b 100644 --- a/src/simulator/time.h +++ b/src/simulator/time.h @@ -32,13 +32,13 @@ public: double s (void) const; uint64_t us (void) const; uint64_t ns (void) const; - bool is_destroy (void) const; - static Time abs_s (double s); - static Time abs_us (uint64_t us); - static Time abs_ns (uint64_t ns); - static Time rel_s (double s); - static Time rel_us (uint64_t us); - static Time rel_ns (uint64_t ns); + bool isDestroy (void) const; + static Time absS (double s); + static Time absUs (uint64_t us); + static Time absNs (uint64_t ns); + static Time relS (double s); + static Time relUs (uint64_t us); + static Time relNs (uint64_t ns); static Time now (void); static Time destroy (void); protected: diff --git a/utils/bench-packets.cc b/utils/bench-packets.cc index b5d2cea79..f2162dca2 100644 --- a/utils/bench-packets.cc +++ b/utils/bench-packets.cc @@ -28,7 +28,7 @@ using namespace ns3; static void -bench_ptr_a (uint32_t n) +benchPtrA (uint32_t n) { ChunkConstantData data = ChunkConstantData (2000, 1); ChunkUdp udp; @@ -50,7 +50,7 @@ bench_ptr_a (uint32_t n) } static void -bench_ptr_b (uint32_t n) +benchPtrB (uint32_t n) { ChunkConstantData data = ChunkConstantData (2000, 1); ChunkUdp udp; @@ -65,7 +65,7 @@ bench_ptr_b (uint32_t n) } static void -ptr_c2 (Packet p) +ptrC2 (Packet p) { ChunkConstantData data = ChunkConstantData (2000, 1); ChunkUdp udp; @@ -77,16 +77,16 @@ ptr_c2 (Packet p) } static void -ptr_c1 (Packet p) +ptrC1 (Packet p) { ChunkIpv4 ipv4; p.peek (&ipv4); p.remove (&ipv4); - ptr_c2 (p); + ptrC2 (p); } static void -bench_ptr_c (uint32_t n) +benchPtrC (uint32_t n) { ChunkConstantData data = ChunkConstantData (2000, 1); ChunkUdp udp; @@ -97,21 +97,21 @@ bench_ptr_c (uint32_t n) p.add (&data); p.add (&udp); p.add (&ipv4); - ptr_c1 (p); + ptrC1 (p); } } static void -run_bench (void (*bench) (uint32_t), uint32_t n, char const *name) +runBench (void (*bench) (uint32_t), uint32_t n, char const *name) { WallClockMs time; time.start (); (*bench) (n); - unsigned long long delta_ms = time.end (); + unsigned long long deltaMs = time.end (); double ps = n; ps *= 1000; - ps /= delta_ms; + ps /= deltaMs; std::cout << name<<"=" << ps << " packets/s" << std::endl; } @@ -120,16 +120,16 @@ int main (int argc, char *argv[]) uint32_t n = 0; while (argc > 0) { if (strncmp ("--n=", argv[0],strlen ("--n=")) == 0) { - char const *n_ascii = argv[0] + strlen ("--n="); - n = atoi (n_ascii); + char const *nAscii = argv[0] + strlen ("--n="); + n = atoi (nAscii); } argc--; argv++; } - run_bench (&bench_ptr_a, n, "a"); - run_bench (&bench_ptr_b, n, "b"); - run_bench (&bench_ptr_c, n, "c"); + runBench (&benchPtrA, n, "a"); + runBench (&benchPtrB, n, "b"); + runBench (&benchPtrC, n, "c"); return 0; } diff --git a/utils/bench-simulator.cc b/utils/bench-simulator.cc index aa7085fdc..991bb1f10 100644 --- a/utils/bench-simulator.cc +++ b/utils/bench-simulator.cc @@ -28,12 +28,12 @@ using namespace ns3; -bool g_debug = false; +bool gDebug = false; class Bench { public: - void read_distribution (std::istream &istream); - void set_total (uint32_t total); + void readDistribution (std::istream &istream); + void setTotal (uint32_t total); void bench (void); private: void cb (void); @@ -44,13 +44,13 @@ private: }; void -Bench::set_total (uint32_t total) +Bench::setTotal (uint32_t total) { m_total = total; } void -Bench::read_distribution (std::istream &input) +Bench::readDistribution (std::istream &input) { double data; while (!input.eof ()) { @@ -73,7 +73,7 @@ Bench::bench (void) time.start (); for (std::vector::const_iterator i = m_distribution.begin (); i != m_distribution.end (); i++) { - Simulator::schedule (Time::abs_ns (*i), &Bench::cb, this); + Simulator::schedule (Time::absNs (*i), &Bench::cb, this); } init = time.end (); @@ -102,10 +102,10 @@ Bench::cb (void) if (m_current == m_distribution.end ()) { m_current = m_distribution.begin (); } - if (g_debug) { + if (gDebug) { std::cerr << "event at " << Simulator::now ().s () << "s" << std::endl; } - Simulator::schedule (Time::abs_ns (*m_current), &Bench::cb, this); + Simulator::schedule (Time::absNs (*m_current), &Bench::cb, this); m_current++; m_n++; } @@ -123,23 +123,23 @@ int main (int argc, char *argv[]) } while (argc > 0) { if (strcmp ("--list", argv[0]) == 0) { - Simulator::set_linked_list (); + Simulator::setLinkedList (); } else if (strcmp ("--heap", argv[0]) == 0) { - Simulator::set_binary_heap (); + Simulator::setBinaryHeap (); } else if (strcmp ("--map", argv[0]) == 0) { - Simulator::set_std_map (); + Simulator::setStdMap (); } else if (strcmp ("--debug", argv[0]) == 0) { - g_debug = true; + gDebug = true; } else if (strncmp ("--log=", argv[0],strlen ("--log=")) == 0) { char const *filename = argv[0] + strlen ("--log="); - Simulator::enable_log_to (filename); + Simulator::enableLogTo (filename); } argc--; argv++; } Bench *bench = new Bench (); - bench->read_distribution (*input); - bench->set_total (20000); + bench->readDistribution (*input); + bench->setTotal (20000); bench->bench (); return 0; diff --git a/utils/replay-simulation.cc b/utils/replay-simulation.cc index a79ff88f9..f990071fe 100644 --- a/utils/replay-simulation.cc +++ b/utils/replay-simulation.cc @@ -32,9 +32,9 @@ using namespace ns3; class LogReader { public: - void read_from_filename (char const *filename); + void readFrom_filename (char const *filename); void run (void); - void print_stats (void); + void printStats (void); private: struct Command { enum { @@ -57,10 +57,10 @@ private: uint32_t m_evLoc; // time at which the event is supposed to expire uint64_t m_evUs; - } insert_remove; + } insertRemove; }; }; - void execute_log_commands (uint32_t uid); + void executeLogCommands (uint32_t uid); typedef std::deque Commands; typedef std::deque::iterator CommandsI; @@ -77,7 +77,7 @@ typedef std::vector > Removes; typedef std::vector >::iterator RemovesI; void -LogReader::read_from_filename (char const *filename) +LogReader::readFrom_filename (char const *filename) { std::ifstream log; std::cout << "read log..." << std::endl; @@ -87,30 +87,30 @@ LogReader::read_from_filename (char const *filename) std::string type; log >> type; if (type == "i") { - uint32_t now_uid, ev_uid; - uint64_t now_us, ev_us; - log >> now_uid >> now_us >> ev_uid >> ev_us; + uint32_t nowUid, evUid; + uint64_t nowUs, evUs; + log >> nowUid >> nowUs >> evUid >> evUs; struct Command cmd; cmd.m_type = Command::INSERT; - cmd.m_uid = now_uid; - cmd.insert.m_evUs = ev_us; + cmd.m_uid = nowUid; + cmd.insert.m_evUs = evUs; m_commands.push_back (cmd); } else if (type == "r") { - uint32_t now_uid, ev_uid; - uint64_t now_us, ev_us; - log >> now_uid >> now_us >> ev_uid >> ev_us; + uint32_t nowUid, evUid; + uint64_t nowUs, evUs; + log >> nowUid >> nowUs >> evUid >> evUs; struct Command cmd; cmd.m_type = Command::REMOVE; - cmd.m_uid = now_uid; + cmd.m_uid = nowUid; m_commands.push_back (cmd); - removes.push_back (std::make_pair (now_uid, ev_uid)); + removes.push_back (std::make_pair (nowUid, evUid)); } else if (type == "il") { - uint32_t now_uid, ev_uid; - uint64_t now_us, ev_us; - log >> now_uid >> now_us >> ev_uid >> ev_us; + uint32_t nowUid, evUid; + uint64_t nowUs, evUs; + log >> nowUid >> nowUs >> evUid >> evUs; struct Command cmd; cmd.m_type = Command::INSERT_LATER; - cmd.m_uid = now_uid; + cmd.m_uid = nowUid; m_commands.push_back (cmd); } } @@ -126,8 +126,8 @@ LogReader::read_from_filename (char const *filename) uint32_t uid = i->m_uid; i->m_type = Command::INSERT_REMOVE; i->m_uid = uid; - i->insert_remove.m_evUs = us; - i->insert_remove.m_evLoc = j->first; + i->insertRemove.m_evUs = us; + i->insertRemove.m_evLoc = j->first; break; } } @@ -140,8 +140,8 @@ LogReader::read_from_filename (char const *filename) uint32_t loc = 0; for (CommandsI tmp = i; tmp != m_commands.end (); tmp++) { if (tmp->m_type == Command::REMOVE && - tmp->m_uid == i->insert_remove.m_evLoc) { - i->insert_remove.m_evLoc = loc; + tmp->m_uid == i->insertRemove.m_evLoc) { + i->insertRemove.m_evLoc = loc; break; } loc++; @@ -150,7 +150,7 @@ LogReader::read_from_filename (char const *filename) } } void -LogReader::execute_log_commands (uint32_t uid) +LogReader::executeLogCommands (uint32_t uid) { if (m_command == m_commands.end ()) { return; @@ -162,15 +162,15 @@ LogReader::execute_log_commands (uint32_t uid) m_command++; switch (cmd.m_type) { case Command::INSERT: - //std::cout << "exec insert now=" << Simulator::now_us () + //std::cout << "exec insert now=" << Simulator::nowUs () //<< ", time=" << cmd.insert.m_evUs << std::endl; - Simulator::schedule_abs_us (cmd.insert.m_evUs, - make_event (&LogReader::execute_log_commands, this, m_uid)); + Simulator::scheduleAbsUs (cmd.insert.m_evUs, + makeEvent (&LogReader::executeLogCommands, this, m_uid)); m_uid++; break; case Command::INSERT_LATER: //std::cout << "exec insert later" << std::endl; - Simulator::schedule_now (make_event (&LogReader::execute_log_commands, this, m_uid)); + Simulator::scheduleNow (makeEvent (&LogReader::executeLogCommands, this, m_uid)); m_uid++; break; case Command::REMOVE: { @@ -181,9 +181,9 @@ LogReader::execute_log_commands (uint32_t uid) } break; case Command::INSERT_REMOVE: { //std::cout << "exec insert remove" << std::endl; - Event ev = make_event (&LogReader::execute_log_commands, this, m_uid); - Simulator::schedule_abs_us (cmd.insert_remove.m_evUs, ev); - m_removeEvents[cmd.insert_remove.m_evLoc] = ev; + Event ev = makeEvent (&LogReader::executeLogCommands, this, m_uid); + Simulator::scheduleAbsUs (cmd.insertRemove.m_evUs, ev); + m_removeEvents[cmd.insertRemove.m_evLoc] = ev; m_uid++; } break; } @@ -192,27 +192,27 @@ LogReader::execute_log_commands (uint32_t uid) } void -LogReader::print_stats (void) +LogReader::printStats (void) { - uint32_t n_inserts = 0; - uint32_t n_removes = 0; + uint32_t nInserts = 0; + uint32_t nRemoves = 0; for (CommandsI i = m_commands.begin (); i != m_commands.end (); i++) { switch (i->m_type) { case Command::INSERT: - n_inserts++; + nInserts++; break; case Command::INSERT_LATER: - n_inserts++; + nInserts++; break; case Command::INSERT_REMOVE: - n_inserts++; + nInserts++; break; case Command::REMOVE: - n_removes++; + nRemoves++; break; } } - std::cout << "inserts="< 0) { if (strcmp ("--list", argv[0]) == 0) { - Simulator::set_linked_list (); + Simulator::setLinkedList (); } else if (strcmp ("--heap", argv[0]) == 0) { - Simulator::set_binary_heap (); + Simulator::setBinaryHeap (); } else if (strcmp ("--map", argv[0]) == 0) { - Simulator::set_std_map (); + Simulator::setStdMap (); } else if (strncmp ("--n=", argv[0], strlen("--n=")) == 0) { n = atoi (argv[0]+strlen ("--n=")); } else if (strncmp ("--input=", argv[0],strlen ("--input=")) == 0) { input = argv[0] + strlen ("--input="); } else if (strncmp ("--log=", argv[0],strlen ("--log=")) == 0) { char const *filename = argv[0] + strlen ("--log="); - Simulator::enable_log_to (filename); + Simulator::enableLogTo (filename); } argc--; argv++; @@ -258,7 +258,7 @@ int main (int argc, char *argv[]) return 1; } LogReader log; - log.read_from_filename (input); + log.readFrom_filename (input); for (uint32_t i = 0; i < n; i++) { log.run (); } diff --git a/utils/run-tests.cc b/utils/run-tests.cc index a70544d72..b2fdd1317 100644 --- a/utils/run-tests.cc +++ b/utils/run-tests.cc @@ -24,8 +24,8 @@ int main (int argc, char *argv[]) { #ifdef RUN_SELF_TESTS - ns3::TestManager::enable_verbose (); - ns3::TestManager::run_tests (); + ns3::TestManager::enableVerbose (); + ns3::TestManager::runTests (); #endif /* RUN_SELF_TESTS */ return 0;