Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / ACE / apps / drwho / Protocol_Manager.cpp
blobb5cfb466f8fad271ed408465d5a536fc8b1fff72
1 #include "ace/config-all.h"
2 #include "ace/Log_Msg.h"
3 #include "ace/OS_Memory.h"
4 #include "ace/OS_NS_string.h"
6 #include "Options.h"
7 #include "Protocol_Manager.h"
9 // Returns a pointer to the Drwho_Node associated with HOST_NAME (if
10 // it exists, otherwise a new node is created. Note that if a
11 // Drwho_Node is found it is moved to the front of the list so that
12 // subsequent finds are faster (i.e., self-organizing!)
14 Drwho_Node *
15 Protocol_Manager::get_drwho_node (char *key_name, Drwho_Node *&head)
17 Drwho_Node **temp = &head;
18 for (; *temp != 0; temp = &(*temp)->next_)
19 if (ACE_OS::strcmp (key_name,
20 (*temp)->get_login_name ()) == 0)
21 break;
23 if (*temp == 0)
24 ACE_NEW_RETURN (head,
25 Drwho_Node (key_name, head),
26 0);
27 else
29 Drwho_Node *t = *temp;
31 *temp = (*temp)->next_;
32 t->next_ = head;
34 head = t;
37 return head;
40 Protocol_Manager::Protocol_Manager ()
41 : total_users (0)
45 Protocol_Manager::~Protocol_Manager ()
47 if (Options::get_opt (Options::DEBUGGING))
48 ACE_DEBUG ((LM_DEBUG,
49 "disposing Protocol_Manager\n"));
52 // Returns the next friend in the sequence of sorted friends.
54 Protocol_Record *
55 Protocol_Manager::get_next_friend ()
57 return this->ss->get_next_entry ();
60 Protocol_Record *
61 Protocol_Manager::get_each_friend ()
63 return this->ss->get_each_entry ();
66 // Returns the number of friends.
68 int
69 Protocol_Manager::friend_count ()
71 return this->ss->n_elems ();
74 // Returns total number of users logged in throughout the system.
76 int
77 Protocol_Manager::get_total_users ()
79 return Protocol_Manager::total_users;
82 void
83 Protocol_Manager::increment_total_users (int remote_users)
85 Protocol_Manager::total_users += remote_users;