From f25f9dc7302ced98341148d70f0754c194520d02 Mon Sep 17 00:00:00 2001 From: Robert Ammon Date: Fri, 24 Feb 2017 09:23:49 -0800 Subject: [PATCH] utils: Doxygen updates for utils directory --- utils/bench-packets.cc | 16 +- utils/bench-simulator.cc | 28 +- utils/check-style.py | 140 +++++- utils/grid.py | 644 +++++++++++++++++++++++++++- utils/print-introspected-doxygen.cc | 25 +- utils/python-unit-tests.py | 87 ++++ utils/tests/TestBase.py | 39 +- 7 files changed, 953 insertions(+), 26 deletions(-) diff --git a/utils/bench-packets.cc b/utils/bench-packets.cc index 6a317b64b..e57c8ba44 100644 --- a/utils/bench-packets.cc +++ b/utils/bench-packets.cc @@ -30,11 +30,16 @@ using namespace ns3; +/// BenchHeader class template class BenchHeader : public Header { public: BenchHeader (); + /** + * Is OK function + * \returns true if OK + */ bool IsOk (void) const; /** @@ -48,8 +53,12 @@ public: virtual void Serialize (Buffer::Iterator start) const; virtual uint32_t Deserialize (Buffer::Iterator start); private: + /** + * Get type name function + * \returns the type name string + */ static std::string GetTypeName (void); - bool m_ok; + bool m_ok; ///< is OK }; template @@ -125,10 +134,15 @@ BenchHeader::Deserialize (Buffer::Iterator start) return N; } +/// BenchTag class template class BenchTag : public Tag { public: + /** + * Get the bench tag name. + * \return the name. + */ static std::string GetName (void) { std::ostringstream oss; oss << "anon::BenchTag<" << N << ">"; diff --git a/utils/bench-simulator.cc b/utils/bench-simulator.cc index 64f4b0787..07ca73c45 100644 --- a/utils/bench-simulator.cc +++ b/utils/bench-simulator.cc @@ -39,9 +39,15 @@ std::string g_me; // Output field width int g_fwidth = 6; +/// Bench class class Bench { public: + /** + * constructor + * \param population the population + * \param total the total + */ Bench (const uint32_t population, const uint32_t total) : m_population (population), m_total (total), @@ -49,29 +55,43 @@ public: { } + /** + * Set random stream + * \param stream the random variable stream + */ void SetRandomStream (Ptr stream) { m_rand = stream; } + /** + * Set population function + * \param population the population + */ void SetPopulation (const uint32_t population) { m_population = population; } + /** + * Set total function + * \param total + */ void SetTotal (const uint32_t total) { m_total = total; } + /// Run function void RunBench (void); private: + /// callback function void Cb (void); - Ptr m_rand; - uint32_t m_population; - uint32_t m_total; - uint32_t m_count; + Ptr m_rand; ///< random variable + uint32_t m_population; ///< population + uint32_t m_total; ///< total + uint32_t m_count; ///< count }; void diff --git a/utils/check-style.py b/utils/check-style.py index d0a22eece..15d0f2e30 100755 --- a/utils/check-style.py +++ b/utils/check-style.py @@ -130,31 +130,83 @@ cmt_indent_multi=False # really, do not touch them dst.close() return pathname +## PatchChunkLine class class PatchChunkLine: + ## @var __type + # type + ## @var __line + # line + ## @var SRC + # Source SRC = 1 + ## @var DST + # Destination DST = 2 + ## @var BOTH + # Both BOTH = 3 def __init__(self): + """! Initializer + @param self The current class + @return none + """ self.__type = 0 self.__line = '' def set_src(self,line): + """! Set source + @param self The current class + @param line source line + @return none + """ self.__type = self.SRC self.__line = line def set_dst(self,line): + """! Set destination + @param self The current class + @param line destination line + @return none + """ self.__type = self.DST self.__line = line def set_both(self,line): + """! Set both + @param self The current class + @param line + @return none + """ self.__type = self.BOTH self.__line = line def append_to_line(self, s): + """! Append to line + @param self The current class + @param s line to append + @return none + """ self.__line = self.__line + s def line(self): + """! Get line + @param self The current class + @return line + """ return self.__line def is_src(self): + """! Is source + @param self The current class + @return true if type is source + """ return self.__type == self.SRC or self.__type == self.BOTH def is_dst(self): + """! Is destination + @param self The current class + @return true if type is destination + """ return self.__type == self.DST or self.__type == self.BOTH def write(self, f): + """! Write to file + @param self The current class + @param f file + @return exception if invalid type + """ if self.__type == self.SRC: f.write('-%s\n' % self.__line) elif self.__type == self.DST: @@ -164,55 +216,141 @@ class PatchChunkLine: else: raise Exception('invalid patch') - +## PatchChunk class class PatchChunk: + ## @var __lines + # list of lines + ## @var __src_pos + # source position + ## @var __dst_pos + # destination position + ## @var src + # source + ## @var dst + # destination def __init__(self, src_pos, dst_pos): + """! Initializer + @param self: this object + @param src_pos: source position + @param dst_pos: destination position + @return none + """ self.__lines = [] self.__src_pos = int(src_pos) self.__dst_pos = int(dst_pos) def src_start(self): + """! Source start function + @param self this object + @return source position + """ return self.__src_pos def add_line(self,line): + """! Add line function + @param self The current class + @param line line to add + @return none + """ self.__lines.append(line) def src(self): + """! Get source lines + @param self The current class + @return the source lines + """ src = [] for line in self.__lines: if line.is_src(): src.append(line) return src def dst(self): + """! Get destination lines + @param self The current class + @return the destination lines + """ dst = [] for line in self.__lines: if line.is_dst(): dst.append(line) return dst def src_len(self): + """! Get number of source lines + @param self The current class + @return number of source lines + """ return len(self.src()) def dst_len(self): + """! Get number of destinaton lines + @param self The current class + @return number of destination lines + """ return len(self.dst()) def write(self,f): + """! Write lines to file + @param self The current class + @param f: file to write to + @return none + """ f.write('@@ -%d,%d +%d,%d @@\n' % (self.__src_pos, self.src_len(), self.__dst_pos, self.dst_len())) for line in self.__lines: line.write(f) +## Patch class class Patch: + ## @var __src + # source + ## @var __dst + # destination + ## @var __chunks + # chunks def __init__(self): + """! Initializer + @param self The current class + @return none + """ self.__src = '' self.__dst = '' self.__chunks = [] def add_chunk(self, chunk): + """! Add chunk + @param self this object + @param chunk chunk + @return none + """ self.__chunks.append(chunk) def chunks(self): + """! Get the chunks + @param self The current class + @return the chunks + """ return self.__chunks def set_src(self,src): + """! Set source + @param self this object + @param src source + @return none + """ self.__src = src def set_dst(self,dst): + """! Set destination + @param self this object + @param dst destintion + @return none + """ self.__dst = dst def apply(self,filename): + """! Apply function + @param self The current class + @param filename file name + @return none + """ # XXX: not implemented return def write(self,f): + """! Write to file + @param self The current class + @param f the file + @return none + """ f.write('--- %s\n' % self.__src ) f.write('+++ %s\n' % self.__dst ) for chunk in self.__chunks: diff --git a/utils/grid.py b/utils/grid.py index 67cace8e8..58d7f7b66 100644 --- a/utils/grid.py +++ b/utils/grid.py @@ -7,22 +7,68 @@ import re import gtk - +## DataRange class class DataRange: + ## @var start + # start + ## @var end + # end + ## @var value + # value def __init__(self, start = 0, end = 0, value = ''): + """! Initializer + @param self this object + @param start start + @param end end + @param value value + @return none + """ self.start = start self.end = end self.value = value +## EventString class class EventString: + ## @var at + # at + ## @var value + # value def __init__(self, at = 0, value = ''): + """! Initializer + @param self this object + @param at you + @param value value + @return none + """ self.at = at self.value = value +## EventFloat class class EventFloat: + ## @var at + # at + ## @var value + # value def __init__(self, at = 0, value = 0.0): + """! Initializer + @param self this object + @param at you + @param value value + @return none + """ self.at = at self.value = value +## EventInt class class EventInt: + ## @var at + # at + ## @var value + # value def __init__(self, at = 0, value = 0.0): + """! Initializer + @param self this object + @param at you + @param value value + @return none + """ self.at = at self.value = value def ranges_cmp(a, b): @@ -41,12 +87,27 @@ def events_cmp(a, b): return +1 else: return 0 +## TimelineDataRange class TimelineDataRange: + ## @var name + # name + ## @var ranges + # ranges def __init__(self, name = ''): + """! Initializer + @param self this object + @param name name + @return none + """ self.name = name self.ranges = [] return def __search(self, key): + """! Search + @param self this object + @param key key + @return index if found or -1 if not found + """ l = 0 u = len(self.ranges)-1 while l <= u: @@ -60,10 +121,25 @@ class TimelineDataRange: l = i + 1 return - 1 def add_range(self, range): + """! Add range + @param self this object + @param range range + @return none + """ self.ranges.append(range) def get_all(self): + """! Get all ranges + @param self this object + @return the ranges + """ return self.ranges def get_ranges(self, start, end): + """! Get selected ranges + @param self this object + @param start range start + @param end range end + @return the range or and empty list + """ s = self.__search(start) e = self.__search(end) if s == -1 and e == -1: @@ -75,6 +151,12 @@ class TimelineDataRange: else: return self.ranges[s:e + 1] def get_ranges_bounds(self, start, end): + """! Get ranges bounds + @param self this object + @param start range start + @param end range end + @return range + """ s = self.__search(start) e = self.__search(end) if s == -1 and e == -1: @@ -86,19 +168,42 @@ class TimelineDataRange: else: return(s, e + 1) def sort(self): + """! Sort ranges + @param self this object + @return none + """ self.ranges.sort(ranges_cmp) def get_bounds(self): + """! Get bounds + @param self this object + @return the bounds + """ if len(self.ranges) > 0: lo = self.ranges[0].start hi = self.ranges[len(self.ranges)-1].end return(lo, hi) else: return(0, 0) +## TimelineEvent class class TimelineEvent: + ## @var name + # name + ## @var events + # events def __init__(self, name = ''): + """! Get ranges bounds + @param self this object + @param name name + @return none + """ self.name = name self.events = [] def __search(self, key): + """! Search function + @param self this object + @param key the key + @return event index + """ l = 0 u = len(self.events)-1 while l <= u: @@ -112,18 +217,43 @@ class TimelineEvent: l = i + 1 return l def add_event(self, event): + """! Add Event + @param self this object + @param event event to add + @return none + """ self.events.append(event) def get_events(self, start, end): + """! Get Events + @param self this object + @param start starting event + @param end ending event + @return the events + """ s = self.__search(start) e = self.__search(end) return self.events[s:e + 1] def get_events_bounds(self, start, end): + """! Get Events Bounds + @param self this object + @param start starting event + @param end ending event + @return event bounds + """ s = self.__search(start) e = self.__search(end) return(s, e + 1) def sort(self): + """! Sort function + @param self this object + @return none + """ self.events.sort(events_cmp) def get_bounds(self): + """! Get Bounds + @param self this object + @return the bounds + """ if len(self.events) > 0: lo = self.events[0].at hi = self.events[-1].at @@ -131,13 +261,32 @@ class TimelineEvent: else: return(0, 0) +## Timeline class class Timeline: + ## @var name + # name + ## @var ranges + # ranges + ## @var event_str + # event string + ## @var event_int + # event int def __init__(self, name = ''): + """! Initializer + @param self this object + @param name name + @return none + """ self.ranges = [] self.event_str = [] self.event_int = [] self.name = name def get_range(self, name): + """! Get range + @param self this object + @param name name + @return the range + """ for range in self.ranges: if range.name == name: return range @@ -145,6 +294,11 @@ class Timeline: self.ranges.append(timeline) return timeline def get_event_str(self, name): + """! Get Event String + @param self this object + @param name name + @return the event string + """ for event_str in self.event_str: if event_str.name == name: return event_str @@ -152,6 +306,11 @@ class Timeline: self.event_str.append(timeline) return timeline def get_event_int(self, name): + """! Get Event Int + @param self this object + @param name name + @return eevent int + """ for event_int in self.event_int: if event_int.name == name: return event_int @@ -159,12 +318,28 @@ class Timeline: self.event_int.append(timeline) return timeline def get_ranges(self): + """! Get Ranges + @param self this object + @return the ranges + """ return self.ranges def get_events_str(self): + """! Get Events string + @param self this object + @return event string + """ return self.event_str def get_events_int(self): + """! Get Events int + @param self this object + @return evrnt int + """ return self.event_int def sort(self): + """! Sort the ranges and events + @param self this object + @return none + """ for range in self.ranges: range.sort() for event in self.event_int: @@ -172,6 +347,10 @@ class Timeline: for event in self.event_str: event.sort() def get_bounds(self): + """! Get Bounds + @param self this object + @return the bounds + """ lo = 0 hi = 0 for range in self.ranges: @@ -193,10 +372,22 @@ class Timeline: if ev_hi > hi: hi = ev_hi return(lo, hi) + +## Timelines class class Timelines: + ## @var timelines + # timelines def __init__(self): + """ Initializer + @param self: this object + """ self.timelines = [] def get(self, name): + """! Get Timeline + @param self this object + @param name name + @return the timeline for the name + """ for timeline in self.timelines: if timeline.name == name: return timeline @@ -204,11 +395,23 @@ class Timelines: self.timelines.append(timeline) return timeline def get_all(self): + """! Get All Timeline + @param self this object + @return all timelines + """ return self.timelines def sort(self): + """! Sort the timelines + @param self this object + @return none + """ for timeline in self.timelines: timeline.sort() def get_bounds(self): + """! Get Bounds + @param self this object + @return the bounds for all timelines + """ lo = 0 hi = 0 for timeline in self.timelines: @@ -219,43 +422,120 @@ class Timelines: hi = t_hi return(lo, hi) def get_all_range_values(self): + """! Get All Ranges + @param self this object + @return the keys for all ranges + """ range_values = {} for timeline in self.timelines: for ranges in timeline.get_ranges(): for ran in ranges.get_all(): range_values[ran.value] = 1 return range_values.keys() + +## Color class class Color: + ## @var r + # red + ## @var g + # green + ## @var b + # blue def __init__(self, r = 0.0, g = 0.0, b = 0.0): + """! Initializer + @param self: this object + @param r: red + @param g: green + @param b: blue + @return none + """ self.r = r self.g = g self.b = b def set(self, r, g, b): + """! Set color + @param self: this object + @param r: red + @param g: green + @param b: blue + @return none + """ self.r = r self.g = g self.b = b + +## Colors class class Colors: - # XXX add more + ## @var __colors + # colors + ## @var default_colors + # default colors + ## XXX add more default_colors = [Color(1, 0, 0), Color(0, 1, 0), Color(0, 0, 1), Color(1, 1, 0), Color(1, 0, 1), Color(0, 1, 1)] def __init__(self): + """! Initializer + @param self this object + @return none + """ self.__colors = {} def add(self, name, color): + """! Add + @param self this object + @param name name of the color + @param color color value + @return none + """ self.__colors[name] = color def lookup(self, name): + """! Lookup name + @param self this object + @param name name + @return named color + """ if not self.__colors.has_key(name): self.add(name, self.default_colors.pop()) return self.__colors.get(name) - +## TopLegendRenderer class class TopLegendRenderer: + ## @var __padding + # padding + ## @var __legends + # legends + ## @var __colors + # colors + ## @var __width + # width + ## @var __height + # height def __init__(self): + """! Initializer + @param self this object + @return none + """ self.__padding = 10 def set_padding(self, padding): + """! Set padding + @param self this object + @param padding padding + @return none + """ self.__padding = padding def set_legends(self, legends, colors): + """! Set padding + @param self this object + @param legends legends + @param colors colors + @return none + """ self.__legends = legends self.__colors = colors def layout(self, width): + """! Set padding + @param self this object + @param width width + @return none + """ self.__width = width surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 1, 1) ctx = cairo.Context(surface) @@ -278,8 +558,17 @@ class TopLegendRenderer: self.__height = total_height def get_height(self): + """! Set padding + @param self this object + @return height + """ return self.__height def draw(self, ctx): + """! Set padding + @param self this object + @param ctx ctx + @return none + """ i = 0 line_height = 0 total_height = self.__padding @@ -311,21 +600,73 @@ class TopLegendRenderer: return +## TimelinesRenderer class class TimelinesRenderer: + ## @var padding + # padding + ## @var timelines + # timelines + ## @var colors + # colors + ## @var start + # start + ## @var end + # end + ## @var left_width + # left width + ## @var right_width + # right width + ## @var max_text_height + # maximum text height + ## @var width + # width + ## @var height + # height + ## @var grey_background + # grey background def __init__(self): + """! Initializer + @param self this object + @return none + """ self.padding = 10 return def get_height(self): + """! Get Height + @param self this object + @return height + """ return self.height def set_timelines(self, timelines, colors): + """! Set Timelines + @param self this object + @param timelines timelines + @param colors colors + @return none + """ self.timelines = timelines self.colors = colors def set_render_range(self, start, end): + """! Set Render Range + @param self this object + @param start start + @param end end + @return none + """ self.start = start self.end = end def get_data_x_start(self): + """! Get Data X Start + @param self: this object + @return X start + """ return self.padding / 2 + self.left_width + self.padding + self.right_width + self.padding / 2 def layout(self, width): + """! Get Data X Start + @param self this object + @param width width + @return none + """ surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 1, 1) ctx = cairo.Context(surface) max_text_height = ctx.text_extents("ABCDEFGHIJKLMNOPQRSTUVWXYZabcedefghijklmnopqrstuvwxyz0123456789")[3] @@ -368,6 +709,15 @@ class TimelinesRenderer: self.width = width self.height = height + self.padding def draw_line(self, ctx, x, y, width, height): + """! Draw Line + @param self this object + @param ctx ctx + @param x x + @param y y + @param width width + @param height height + @return none + """ ctx.move_to(x, y) ctx.rel_line_to(width, height) ctx.close_path() @@ -376,6 +726,16 @@ class TimelinesRenderer: ctx.set_source_rgb(0, 0, 0) ctx.stroke() def draw_events(self, ctx, events, x, y, width, height): + """! Draw Event + @param self this object + @param ctx ctx + @param events events + @param x x + @param y y + @param width width + @param height height + @return none + """ if (self.grey_background % 2) == 0: ctx.rectangle(x, y - self.padding / 2, width, height + self.padding) @@ -395,6 +755,16 @@ class TimelinesRenderer: last_x_drawn = real_x self.grey_background += 1 def draw_ranges(self, ctx, ranges, x, y, width, height): + """! Draw Ranges + @param self this object + @param ctx ctx + @param ranges ranges + @param x x + @param y y + @param width width + @param height height + @return none + """ if (self.grey_background % 2) == 0: ctx.rectangle(x, y - self.padding / 2, width, height + self.padding) @@ -419,6 +789,11 @@ class TimelinesRenderer: self.grey_background += 1 def draw(self, ctx): + """! Draw + @param self this object + @param ctx ctx + @return none + """ timeline_top = 0 top_y = self.padding / 2 left_x_start = self.padding / 2 @@ -469,21 +844,64 @@ class TimelinesRenderer: 0, bot_y) return +## ScaleRenderer class class ScaleRenderer: + ## @var __top + # top + ## @var __lo + # lo + ## @var __hi + # hi + ## @var __delta + # delta + ## @var __width + # width + ## @var __height + # height + ## @var max_text_height + # maximum text height def __init__(self): + """! Initializer + @param self this object + @return none + """ self.__top = 0 return def set_bounds(self, lo, hi): + """! Set Bounds + @param self this object + @param lo lo + @param hi hi + @return none + """ self.__lo = lo self.__hi = hi def get_position(self, x): + """! Get Position + @param self this object + @param x x + @return real x + """ real_x = (x - self.__lo ) * self.__width / (self.__hi - self.__lo) return real_x def set_top(self): + """! Set Top + @param self this object + @return none + """ self.__top = 1 def set_bot(self): + """! Set Bottom + @param self this object + @return none + """ self.__top = 0 def layout(self, width): + """! Layout + @param self this object + @param width width + @return none + """ surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 1, 1) ctx = cairo.Context(surface) @@ -511,8 +929,17 @@ class ScaleRenderer: self.__height = height def get_height(self): + """! Get Height + @param self: this object + @return height + """ return self.__height def draw(self, ctx): + """! Draw + @param self this object + @param ctx ctx + @return none + """ delta = self.__delta start = self.__lo - (self.__lo % delta) + delta end = self.__hi - (self.__hi % delta) @@ -551,9 +978,37 @@ class ScaleRenderer: ctx.stroke() - +## GraphicRenderer class class GraphicRenderer: + ## @var __start + # start + ## @var __end + # end + ## @var __mid_scale + # mid scale + ## @var __bot_scale + # bottom scale + ## @var __width + # width + ## @var __height + # height + ## @var __r_start + # start + ## @var __r_end + # end + ## @var __data + # data + ## @var __mid_scale + # mid scale + ## @var __top_legend + # top legend def __init__(self, start, end): + """! Initializer + @param self this object + @param start start + @param end end + @return none + """ self.__start = float(start) self.__end = float(end) self.__mid_scale = ScaleRenderer() @@ -564,29 +1019,61 @@ class GraphicRenderer: self.__width = 1 self.__height = 1 def get_width(self): + """! Get Width + @param self: this object + @return width + """ return self.__width def get_height(self): + """! Get Height + @param self this object + @return height + """ return self.__height # return x, y, width, height def get_data_rectangle(self): + """! Get Data Rectangle + @param self this object + @return rectangle + """ y_start = self.__top_legend.get_height() x_start = self.__data.get_data_x_start() return(x_start, y_start, self.__width - x_start, self.__data.get_height()) def scale_data(self, x): + """! Get Data Rectangle + @param self this object + @param x x + @return scaled x + """ x_start = self.__data.get_data_x_start() x_scaled = x / (self.__width - x_start) * (self.__r_end - self.__r_start) return x_scaled # return x, y, width, height def get_selection_rectangle(self): + """! Get Selection Rectangle + @param self this object + @return rectangle + """ y_start = self.__top_legend.get_height() + self.__data.get_height() + self.__mid_scale.get_height() + 20 y_height = self.__bot_scale.get_height() + 20 x_start = self.__bot_scale.get_position(self.__r_start) x_end = self.__bot_scale.get_position(self.__r_end) return(x_start, y_start, x_end - x_start, y_height) def scale_selection(self, x): + """! Scale Selection + @param self this object + @param x the X + @return scaled X + """ x_scaled = x / self.__width * (self.__end - self.__start) return x_scaled def set_range(self, start, end): + """! Set Range + @param self this object + @param start start + @param end end + @return none + """ s = min(start, end) e = max(start, end) start = max(self.__start, s) @@ -597,12 +1084,32 @@ class GraphicRenderer: self.__mid_scale.set_bounds(start, end) self.layout(self.__width, self.__height) def get_range(self): + """! Get Range + @param self this object + @return range + """ return(self.__r_start, self.__r_end) def set_data(self, data): + """! Set Date + @param self this object + @param data data + @return none + """ self.__data = data def set_top_legend(self, top_legend): + """! Set Top Legend + @param self this object + @param top_legend The legend + @return none + """ self.__top_legend = top_legend def layout(self, width, height): + """! Set Layout + @param self this object + @param width width + @param height height + @return none + """ self.__width = width self.__height = height self.__top_legend.layout(width) @@ -612,10 +1119,21 @@ class GraphicRenderer: self.__bot_scale.layout(width) return def __x_pixel(self, x, width): + """! X Pixel + @param self this object + @param x x + @param width width + @return x pixel + """ new_x = (x - self.__start) * width / (self.__end - self.__start) return new_x def draw(self, ctx): + """! Draw + @param self this object + @param ctx ctx + @return none + """ # default background is white ctx.save() ctx.set_source_rgb(1, 1, 1) @@ -747,8 +1265,44 @@ class GraphicRenderer: self.__bot_scale.draw(ctx) ctx.restore() +## GtkGraphicRenderer class class GtkGraphicRenderer(gtk.DrawingArea): + ## @var __data + # data + ## @var __moving_left + # moving left + ## @var __moving_right + # moving right + ## @var __moving_both + # moving both + ## @var __moving_top + # moving top + ## @var __force_full_redraw + # full redraw + ## @var __moving_left_cur + # moving left cur + ## @var __moving_right_cur + # moving right cur + ## @var __moving_both_start + # moving both start + ## @var __moving_both_cur + # moving both cur + ## @var __moving_top_cur + # moving top cur + ## @var __moving_top_start + # moving top start + ## @var __width + # width + ## @var __height + # height + ## @var __buffer_surface + # buffer surface def __init__(self, data): + """! Initializer + @param self this object + @param data data + @return none + """ super(GtkGraphicRenderer, self).__init__() self.__data = data self.__moving_left = False @@ -765,16 +1319,29 @@ class GtkGraphicRenderer(gtk.DrawingArea): self.connect('button-press-event', self.button_press) self.connect('button-release-event', self.button_release) def set_smaller_zoom(self): + """! Set Smaller Zoom + @param self this object + @return none + """ (start, end) = self.__data.get_range() self.__data.set_range(start, start + (end - start)*2) self.__force_full_redraw = True self.queue_draw() def set_bigger_zoom(self): + """! Set Bigger Zoom + @param self this object + @return none + """ (start, end) = self.__data.get_range() self.__data.set_range(start, start + (end - start) / 2) self.__force_full_redraw = True self.queue_draw() def output_png(self, filename): + """! Output PNG + @param self this object + @param filename file name + @return none + """ surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, self.__data.get_width(), self.__data.get_height()) @@ -782,6 +1349,12 @@ class GtkGraphicRenderer(gtk.DrawingArea): self.__data.draw(ctx) surface.write_to_png(filename) def button_press(self, widget, event): + """! Button Press + @param self this object + @param widget widget + @param event event + @return true if button has been pressed otherwise false + """ (x, y, width, height) = self.__data.get_selection_rectangle() (d_x, d_y, d_width, d_height) = self.__data.get_data_rectangle() if event.y > y and event.y < y + height: @@ -804,6 +1377,12 @@ class GtkGraphicRenderer(gtk.DrawingArea): return True return False def button_release(self, widget, event): + """! Button Release + @param self this object + @param widget widget + @param event event + @return true if button was released otherwise false + """ if self.__moving_left: self.__moving_left = False left = self.__data.scale_selection(self.__moving_left_cur) @@ -832,6 +1411,12 @@ class GtkGraphicRenderer(gtk.DrawingArea): self.__moving_top = False return False def motion_notify(self, widget, event): + """! Motion Notify + @param self this object + @param widget widget + @param event event + @return true if moving otherwise false + """ (x, y, width, height) = self.__data.get_selection_rectangle() if self.__moving_left: if event.x <= 0: @@ -886,12 +1471,24 @@ class GtkGraphicRenderer(gtk.DrawingArea): widget.window.set_cursor(None) return False def size_allocate(self, widget, allocation): + """! Size Allocate + @param self this object + @param widget widget + @param allocation allocation + @return none + """ self.__width = allocation.width self.__height = allocation.height self.__data.layout(allocation.width, allocation.height) self.__force_full_redraw = True self.queue_draw() def expose(self, widget, event): + """! Expose + @param self this object + @param widget widget + @param event event + @return false + """ if self.__force_full_redraw: self.__buffer_surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, self.__data.get_width(), @@ -934,10 +1531,26 @@ class GtkGraphicRenderer(gtk.DrawingArea): ctx.stroke() return False +## MainWindow class class MainWindow: + ## @var __window + # window + ## @var __render + # render + ## @var __dialog + # dialog def __init__(self): + """! Initializer + @param self this object + @return none + """ return def run(self, graphic): + """! Run function + @param self this object + @param graphic graphic + @return none + """ window = gtk.Window() self.__window = window window.set_default_size(200, 200) @@ -962,10 +1575,25 @@ class MainWindow: #gtk.bindings_activate(gtk.main_quit, 'q', 0) gtk.main() def __set_smaller_cb(self, widget): + """! Set Smaller Callback + @param self this object + @param widget widget + @return none + """ self.__render.set_smaller_zoom() def __set_bigger_cb(self, widget): + """! Set Bigger Callback + @param self this object + @param widget widget + @return none + """ self.__render.set_bigger_zoom() def __output_png_cb(self, widget): + """! Output PNG Callback + @param self this object + @param widget widget + @return none + """ dialog = gtk.FileChooserDialog("Output Png", self.__window, gtk.FILE_CHOOSER_ACTION_SAVE, ("Save", 1)) self.__dialog = dialog @@ -974,6 +1602,12 @@ class MainWindow: dialog.show() return def __dialog_response_cb(self, widget, response): + """! Dialog Response Callback + @param self this object + @param widget widget + @param response response + @return none + """ if response == 1: filename = self.__dialog.get_filename() self.__render.output_png(filename) @@ -981,7 +1615,7 @@ class MainWindow: return - +## read_data function def read_data(filename): timelines = Timelines() colors = Colors() diff --git a/utils/print-introspected-doxygen.cc b/utils/print-introspected-doxygen.cc index 31346d8f0..4bb63d3f9 100644 --- a/utils/print-introspected-doxygen.cc +++ b/utils/print-introspected-doxygen.cc @@ -674,7 +674,7 @@ PrintAttributeValueSection (std::ostream & os, /** * Print the AttributeValue documentation for a class. * - * This will print documentation for the \p Value class and methods. + * This will print documentation for the \p AttributeValue class and methods. * * \param [in,out] os The output stream. * \param [in] name The token to use in defining the accessor name. @@ -1248,8 +1248,8 @@ StaticInformation::DoGather (TypeId tid) } // StaticInformation::DoGather () -StaticInformation -GetTypicalAggregations () +/// GetTypicalAggregations function +StaticInformation GetTypicalAggregations () { NS_LOG_FUNCTION_NOARGS (); // The below statements register typical aggregation relationships @@ -1297,13 +1297,18 @@ GetTypicalAggregations () } // GetTypicalAggregations () -// Map from TypeId name to tid +/// Map from TypeId name to tid typedef std::map< std::string, int32_t> NameMap; -typedef NameMap::const_iterator NameMapIterator; +typedef NameMap::const_iterator NameMapIterator; ///< NameMap iterator -// Create a map from the class names to their index in the vector of -// TypeId's so that the names will end up in alphabetical order. +/** + * Create a map from the class names to their index in the vector of + * TypeId's so that the names will end up in alphabetical order. + * + * \param info type names withut type ids + * \returns NameMap + */ NameMap GetNameMap (const StaticInformation & info) { @@ -1344,6 +1349,12 @@ GetNameMap (const StaticInformation & info) } // GetNameMap () +/** + * Print config paths + * \param os the output stream + * \param info the information + * \param tid the type ID + */ void PrintConfigPaths (std::ostream & os, const StaticInformation & info, const TypeId tid) diff --git a/utils/python-unit-tests.py b/utils/python-unit-tests.py index dc7d8636a..c4f30fd43 100644 --- a/utils/python-unit-tests.py +++ b/utils/python-unit-tests.py @@ -8,10 +8,27 @@ import ns.csma import ns.applications +## TestSimulator class class TestSimulator(unittest.TestCase): + ## @var _received_packet + # received packet + ## @var _args_received + # args + ## @var _cb_time + # current time + ## @var _context_received + # context def testScheduleNow(self): + """! Test schedule now + @param self this object + @return none + """ def callback(args): + """! Callback function + @param args arguments + return none + """ self._args_received = args self._cb_time = Simulator.Now() Simulator.Destroy() @@ -23,7 +40,15 @@ class TestSimulator(unittest.TestCase): self.assertEqual(self._cb_time.GetSeconds(), 0.0) def testSchedule(self): + """! Test schedule + @param self this object + @return none + """ def callback(args): + """! Callback function + @param args arguments + @return none + """ self._args_received = args self._cb_time = Simulator.Now() Simulator.Destroy() @@ -35,7 +60,15 @@ class TestSimulator(unittest.TestCase): self.assertEqual(self._cb_time.GetSeconds(), 123.0) def testScheduleDestroy(self): + """! Test schedule destroy + @param self this object + @return none + """ def callback(args): + """! Callback function + @param args + @return none + """ self._args_received = args self._cb_time = Simulator.Now() Simulator.Destroy() @@ -50,7 +83,16 @@ class TestSimulator(unittest.TestCase): self.assertEqual(self._cb_time.GetSeconds(), 123.0) def testScheduleWithContext(self): + """! Test schedule with context + @param self this object + @return none + """ def callback(context, args): + """! Callback + @param context the cntet + @param args the arguments + @return none + """ self._context_received = context self._args_received = args self._cb_time = Simulator.Now() @@ -65,6 +107,10 @@ class TestSimulator(unittest.TestCase): self.assertEqual(self._cb_time.GetSeconds(), 123.0) def testTimeComparison(self): + """! Test time comparison + @param self this object + @return none + """ self.assert_(Seconds(123) == Seconds(123)) self.assert_(Seconds(123) >= Seconds(123)) self.assert_(Seconds(123) <= Seconds(123)) @@ -72,6 +118,10 @@ class TestSimulator(unittest.TestCase): self.assert_(Seconds(123) < Seconds(124)) def testTimeNumericOperations(self): + """! Test numeric operations + @param self ths object + @return none + """ self.assertEqual(Seconds(10) + Seconds(5), Seconds(15)) self.assertEqual(Seconds(10) - Seconds(5), Seconds(5)) @@ -79,16 +129,28 @@ class TestSimulator(unittest.TestCase): self.assertEqual(v1, int64x64_t(50)) def testConfig(self): + """! Test configuration + @param self this object + @return none + """ Config.SetDefault("ns3::OnOffApplication::PacketSize", ns.core.UintegerValue(123)) # hm.. no Config.Get? def testSocket(self): + """! Test socket + @param self + @return none + """ node = ns.network.Node() internet = ns.internet.InternetStackHelper() internet.Install(node) self._received_packet = None def rx_callback(socket): + """! Receive Callback + @param socket the socket to receive + @return none + """ assert self._received_packet is None self._received_packet = socket.Recv() @@ -105,6 +167,10 @@ class TestSimulator(unittest.TestCase): def testAttributes(self): + """! Test attributes function + @param self this object + @return none + """ ## ## Yes, I know, the GetAttribute interface for Python is ## horrible, we should fix this soon, I hope. @@ -131,6 +197,10 @@ class TestSimulator(unittest.TestCase): self.assert_(ptr.GetObject() is not None) def testIdentity(self): + """! Test identify + @param self thsi object + @return none + """ csma = ns.csma.CsmaNetDevice() channel = ns.csma.CsmaChannel() csma.Attach(channel) @@ -141,12 +211,20 @@ class TestSimulator(unittest.TestCase): self.assert_(c1 is c2) def testTypeId(self): + """! Test type ID + @param self this object + @return none + """ typeId1 = ns.core.TypeId.LookupByNameFailSafe("ns3::UdpSocketFactory") self.assertEqual(typeId1.GetName (), "ns3::UdpSocketFactory") self.assertRaises(KeyError, ns.core.TypeId.LookupByNameFailSafe, "__InvalidTypeName__") def testCommandLine(self): + """! Test command line + @param self this object + @return none + """ cmd = ns.core.CommandLine() cmd.AddValue("Test1", "this is a test option") cmd.AddValue("Test2", "this is a test option") @@ -168,8 +246,17 @@ class TestSimulator(unittest.TestCase): self.assertEqual(foo.test_foo, "xpto") def testSubclass(self): + """! Test subclass + @param self this object + @return none + """ + ## MyNode class class MyNode(ns.network.Node): def __init__(self): + """! Initializer + @param self this object + @return none + """ super(MyNode, self).__init__() node = MyNode() diff --git a/utils/tests/TestBase.py b/utils/tests/TestBase.py index 9c829c564..1cacbc5b0 100644 --- a/utils/tests/TestBase.py +++ b/utils/tests/TestBase.py @@ -49,14 +49,28 @@ def set_workdir(): print('Error: Invalid working directory') sys.exit(1) +## TestBaseClass class class TestBaseClass: """ Generic class for testing tools based on provided commands and test cases. """ + ## @var my_env + # os environment + ## @var mode + # mode + ## @var outfile + # output file + ## @var options + # options def __init__(self, argv, desc, mode): - """ - Provide input argument list, description and mode of the suite being executed. + """! + Provide input argument list, description and mode of the suite being executed. + @param self this object + @param argv argument list + @param desc description + @param mode test mode + @return none """ self.my_env = os.environ set_workdir() @@ -66,8 +80,12 @@ class TestBaseClass: self.options = self.parseargs(argv , desc) def parseargs(self, argv, desc): - """ - Parses the commandline arguments + """! + Parses the commandline arguments + @param self this object + @param argv argument list + @param desc description + @return command line arguments """ parser = argparse.ArgumentParser(description = desc) parser.add_argument('-f', '--file', action='store', dest='out_file', default = self.outfile, @@ -82,14 +100,19 @@ class TestBaseClass: return parser.parse_args(argv) def override_cmds(self): - """ - Can be used by importing suite to handle custom commands + """! + Can be used by importing suite to handle custom commands + @param self this object + @return custom commands """ return self.options.custcmd def runtests(self, cmds): - """ - Execute the tests. + """! + Execute the tests. + @param self this object + @param cmds test commands + @return error code """ if self.options.cmds: print_cmds(cmds)