ruby: record fully busy cycle with in the controller
[gem5.git] / src / mem / ruby / system / MachineID.hh
index 5bfa1584ca14d52f5fbce7a7935898eeebcdd5ce..0bcd10efc39f5cb2c52d7fd332c132d282116297 100644 (file)
@@ -1,4 +1,3 @@
-
 /*
  * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
  * All rights reserved.
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-/*
- * NodeID.hh
- *
- * Description:
- *
- * $Id$
- *
- */
+#ifndef __MEM_RUBY_SYSTEM_MACHINEID_HH__
+#define __MEM_RUBY_SYSTEM_MACHINEID_HH__
 
-#ifndef MACHINEID_H
-#define MACHINEID_H
+#include <iostream>
+#include <string>
 
-#include "mem/ruby/common/Global.hh"
-#include "mem/gems_common/util.hh"
+#include "base/cprintf.hh"
 #include "mem/protocol/MachineType.hh"
 
-struct MachineID {
-  MachineType type;
-  int num;  // range: 0 ... number of this machine's components in the system - 1
+struct MachineID
+{
+    MachineType type;
+    //! range: 0 ... number of this machine's components in system - 1
+    uint32_t num;
+
+    MachineType getType() const { return type; }
+    uint32_t getNum() const { return num; }
 };
 
-extern inline
-string MachineIDToString (MachineID machine) {
-  return MachineType_to_string(machine.type)+"_"+int_to_string(machine.num);
+inline std::string
+MachineIDToString(MachineID machine)
+{
+    return csprintf("%s_%d", MachineType_to_string(machine.type), machine.num);
 }
 
-extern inline
-bool operator==(const MachineID & obj1, const MachineID & obj2)
+inline bool
+operator==(const MachineID & obj1, const MachineID & obj2)
 {
-  return (obj1.type == obj2.type && obj1.num == obj2.num);
+    return (obj1.type == obj2.type && obj1.num == obj2.num);
 }
 
-extern inline
-bool operator!=(const MachineID & obj1, const MachineID & obj2)
+inline bool
+operator!=(const MachineID & obj1, const MachineID & obj2)
 {
-  return (obj1.type != obj2.type || obj1.num != obj2.num);
+    return (obj1.type != obj2.type || obj1.num != obj2.num);
 }
 
 // Output operator declaration
-ostream& operator<<(ostream& out, const MachineID& obj);
+std::ostream& operator<<(std::ostream& out, const MachineID& obj);
 
-// ******************* Definitions *******************
-
-// Output operator definition
-extern inline
-ostream& operator<<(ostream& out, const MachineID& obj)
+inline std::ostream&
+operator<<(std::ostream& out, const MachineID& obj)
 {
-  if ((obj.type < MachineType_NUM) && (obj.type >= MachineType_FIRST)) {
-    out << MachineType_to_string(obj.type);
-  } else {
-    out << "NULL";
-  }
-  out << "-";
-  out << obj.num;
-  out << flush;
-  return out;
+    if ((obj.type < MachineType_NUM) && (obj.type >= MachineType_FIRST)) {
+        out << MachineType_to_string(obj.type);
+    } else {
+        out << "NULL";
+    }
+    out << "-";
+    out << obj.num;
+    out << std::flush;
+    return out;
 }
 
-
-#endif //MACHINEID_H
+#endif // __MEM_RUBY_SYSTEM_MACHINEID_HH__