[shill] the beginnings of the data model

Flesh out Manager a little, to add vectors of Device* and Service* and ways to look through them.

BUG=chromium-os:15347
TEST=unit tests

Change-Id: Iae5280f56bf58cf1580f0b87c465f4905459f07a
Reviewed-on: http://gerrit.chromium.org/gerrit/966
Reviewed-by: Chris Masone <cmasone@chromium.org>
Tested-by: Chris Masone <cmasone@chromium.org>
diff --git a/manager.cc b/manager.cc
index 19ff5f3..9b77f8e 100644
--- a/manager.cc
+++ b/manager.cc
@@ -8,11 +8,17 @@
 #include <string>
 
 #include <base/logging.h>
+#include <base/memory/ref_counted.h>
 
 #include "shill/control_interface.h"
+#include "shill/device.h"
+#include "shill/device_info.h"
 #include "shill/manager.h"
+#include "shill/shill_event.h"
+#include "shill/service.h"
 
 using std::string;
+using std::vector;
 
 namespace shill {
 Manager::Manager(ControlInterface *control_interface,
@@ -38,4 +44,60 @@
   adaptor_->UpdateRunning();
 }
 
+void Manager::RegisterDevice(Device *to_manage) {
+  vector<scoped_refptr<Device> >::iterator it;
+  for (it = devices_.begin(); it != devices_.end(); ++it) {
+    if (to_manage == it->get())
+      return;
+  }
+  devices_.push_back(scoped_refptr<Device>(to_manage));
+}
+
+void Manager::DeregisterDevice(const Device *to_forget) {
+  vector<scoped_refptr<Device> >::iterator it;
+  for (it = devices_.begin(); it != devices_.end(); ++it) {
+    if (to_forget == it->get()) {
+      devices_.erase(it);
+      return;
+    }
+  }
+}
+
+void Manager::RegisterService(Service *to_manage) {
+  vector<scoped_refptr<Service> >::iterator it;
+  for (it = services_.begin(); it != services_.end(); ++it) {
+    if (to_manage == it->get())
+      return;
+  }
+  services_.push_back(scoped_refptr<Service>(to_manage));
+}
+
+void Manager::DeregisterService(const Service *to_forget) {
+  vector<scoped_refptr<Service> >::iterator it;
+  for (it = services_.begin(); it != services_.end(); ++it) {
+    if (to_forget == it->get()) {
+      services_.erase(it);
+      return;
+    }
+  }
+}
+
+void Manager::FilterByTechnology(Device::Technology tech,
+                                 vector<scoped_refptr<Device> > *found) {
+  CHECK(found);
+  vector<scoped_refptr<Device> >::iterator it;
+  for (it = devices_.begin(); it != devices_.end(); ++it) {
+    if ((*it)->TechnologyIs(tech))
+      found->push_back(*it);
+  }
+}
+
+Service* Manager::FindService(const string& name) {
+  vector<scoped_refptr<Service> >::iterator it;
+  for (it = services_.begin(); it != services_.end(); ++it) {
+    if (name == (*it)->name())
+      return it->get();
+  }
+}
+
 }  // namespace shill