File: agent-list.cc

package info (click to toggle)
ns2 2.35%2Bdfsg-2.1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 78,780 kB
  • ctags: 27,490
  • sloc: cpp: 172,923; tcl: 107,130; perl: 6,391; sh: 6,143; ansic: 5,846; makefile: 816; awk: 525; csh: 355
file content (58 lines) | stat: -rw-r--r-- 936 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Author: Satish Kumar, kkumar@isi.edu

extern "C" {
#include <stdarg.h>
#include <float.h>
};

#include "agent-list.h"

AgentList* AgentList::instance_;

static class AgentListClass:public TclClass
{
  public:
  AgentListClass ():TclClass ("AgentList")
  {
  }
  TclObject *create (int, const char *const *)
  {
    return (new AgentList ());
  }
} class_agent_list;




int 
AgentList::command (int argc, const char *const *argv)
{
  if(argc == 3) {
    if (strcasecmp(argv[1], "num_agents") == 0) {
      assert(num_agents_ == 0);

      num_agents_ = atoi(argv[2]);
      
      agents_ = new void*[num_agents_];
      bzero((char*) agents_, sizeof(void*) * num_agents_);
      
      instance_ = this;
      
      return TCL_OK;
    }
  }
  return (TclObject::command(argc, argv));
}





void
AgentList::AddAgent(nsaddr_t node_addr, void *a) {
  assert(agents_);
  assert(node_addr < num_agents_);
  agents_[node_addr] = a;
}