MachineID.hh revision 6154
11156SN/A
21762SN/A/*
31156SN/A * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
41156SN/A * All rights reserved.
51156SN/A *
61156SN/A * Redistribution and use in source and binary forms, with or without
71156SN/A * modification, are permitted provided that the following conditions are
81156SN/A * met: redistributions of source code must retain the above copyright
91156SN/A * notice, this list of conditions and the following disclaimer;
101156SN/A * redistributions in binary form must reproduce the above copyright
111156SN/A * notice, this list of conditions and the following disclaimer in the
121156SN/A * documentation and/or other materials provided with the distribution;
131156SN/A * neither the name of the copyright holders nor the names of its
141156SN/A * contributors may be used to endorse or promote products derived from
151156SN/A * this software without specific prior written permission.
161156SN/A *
171156SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
181156SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
191156SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
201156SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
211156SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
221156SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
231156SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
241156SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
251156SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
261156SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
272665SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
282665SN/A */
291156SN/A
301156SN/A/*
3111263Sandreas.sandberg@arm.com * NodeID.h
3211263Sandreas.sandberg@arm.com *
331156SN/A * Description:
348902SN/A *
358902SN/A * $Id$
361156SN/A *
371156SN/A */
381156SN/A
391156SN/A#ifndef MACHINEID_H
401156SN/A#define MACHINEID_H
411156SN/A
421156SN/A#include "mem/ruby/common/Global.hh"
431156SN/A#include "mem/gems_common/util.hh"
441156SN/A#include "mem/protocol/MachineType.hh"
451156SN/A
461156SN/Astruct MachineID {
471156SN/A  MachineType type;
481156SN/A  int num;  // range: 0 ... number of this machine's components in the system - 1
491156SN/A};
501156SN/A
515543SN/Aextern inline
521156SN/Astring MachineIDToString (MachineID machine) {
531156SN/A  return MachineType_to_string(machine.type)+"_"+int_to_string(machine.num);
541156SN/A}
551156SN/A
561156SN/Aextern inline
571156SN/Abool operator==(const MachineID & obj1, const MachineID & obj2)
581156SN/A{
591156SN/A  return (obj1.type == obj2.type && obj1.num == obj2.num);
602282SN/A}
612008SN/A
622008SN/Aextern inline
631156SN/Abool operator!=(const MachineID & obj1, const MachineID & obj2)
648902SN/A{
658902SN/A  return (obj1.type != obj2.type || obj1.num != obj2.num);
668902SN/A}
678902SN/A
688902SN/A// Output operator declaration
698902SN/Aostream& operator<<(ostream& out, const MachineID& obj);
708902SN/A
718902SN/A// ******************* Definitions *******************
728902SN/A
738902SN/A// Output operator definition
748902SN/Aextern inline
758902SN/Aostream& operator<<(ostream& out, const MachineID& obj)
768902SN/A{
778902SN/A  if ((obj.type < MachineType_NUM) && (obj.type >= MachineType_FIRST)) {
788902SN/A    out << MachineType_to_string(obj.type);
798902SN/A  } else {
808902SN/A    out << "NULL";
818902SN/A  }
828902SN/A  out << "-";
838902SN/A  out << obj.num;
848902SN/A  out << flush;
858902SN/A  return out;
868902SN/A}
878902SN/A
888902SN/A
891156SN/A#endif //MACHINEID_H
901156SN/A