Gather topology element info to TopologyImpl

- Moved all the self-contained topology elements (*Event) to
  TopologyImpl. (ONOS-1651)
  Now {Switch, Port, Link, Host}Impl is just a handler attached to
  TopologyImpl.
- BugFix: TopologyManager.addHost(HostEvent)
  HostEvent could be pushed to reorder queue multiple times,
  if multiple attachment point was given.
- BugFix: TopologyManager.{addLink, removePort}
  Properly handle if Host attachment point was removed as side-effect.
- BugFix: Copy HostEvent#lastSeenTime
- BugFix: Event instance notified to listeners (api*Events) should be
  the event which was/will be in the replica. (TopologyManager)
- Added/Modified debug log in TopologyManager so that log will be in
  same format for each event type.
  "{Added, Update, Removed} <Self-contained>"
- Removed backdoor method and use TestUtils instead.

Change-Id: If053d6f11f39574a188e7a52cb6194114f8afe5d
diff --git a/src/main/java/net/onrc/onos/core/topology/TopologyObject.java b/src/main/java/net/onrc/onos/core/topology/TopologyObject.java
index f929926..445c2d8 100644
--- a/src/main/java/net/onrc/onos/core/topology/TopologyObject.java
+++ b/src/main/java/net/onrc/onos/core/topology/TopologyObject.java
@@ -3,28 +3,40 @@
 import org.apache.commons.lang.Validate;
 
 
-
 /**
  * Base class for Topology Objects.
  */
 public abstract class TopologyObject implements ITopologyElement {
 
-    // XXX This will be a snapshot, thus should be replaceable
     /**
-     * Topology instance this object belongs to.
+     * Topology snapshot this object belongs to.
      */
-    protected final Topology topology;
+    protected volatile TopologyInternal topology;
+
+    // XXX Updater to be used once we implement snapshot update.
+    // Should it be static or not.
+    //     static: Low memory consumption, but higher contention on atomic update
+    // non-static: Updater per instance, but less chance of contention
+//    private static final AtomicReferenceFieldUpdater<TopologyObject, TopologyImpl>
+//        TOPOLOGY_UPDATER =
+//            AtomicReferenceFieldUpdater.newUpdater(
+//                        TopologyObject.class, TopologyImpl.class, "topology");
 
     /**
      * Constructor.
      *
      * @param topology Topology instance this object belongs to
      */
-    protected TopologyObject(Topology topology) {
+    protected TopologyObject(TopologyInternal topology) {
         Validate.notNull(topology);
         this.topology = topology;
     }
 
+    // TODO Add method to replace topology snapshot
+    //  - Request TopologyManager for latest TopologyImpl and swap?
+    //  - Make caller specify TopologyImpl instance?
+    //  -
+
 
     /**
      * Returns the type of topology object.