params.py (7811:a8fc35183c10) | params.py (8321:9f34cf472451) |
---|---|
1# Copyright (c) 2004-2006 The Regents of The University of Michigan 2# Copyright (c) 2010 Advanced Micro Devices, Inc. 3# All rights reserved. 4# 5# Redistribution and use in source and binary forms, with or without 6# modification, are permitted provided that the following conditions are 7# met: redistributions of source code must retain the above copyright 8# notice, this list of conditions and the following disclaimer; --- 189 unchanged lines hidden (view full) --- 198 def set_parent(self, parent, name): 199 if len(self) == 1: 200 self[0].set_parent(parent, name) 201 else: 202 width = int(math.ceil(math.log(len(self))/math.log(10))) 203 for i,v in enumerate(self): 204 v.set_parent(parent, "%s%0*d" % (name, width, i)) 205 | 1# Copyright (c) 2004-2006 The Regents of The University of Michigan 2# Copyright (c) 2010 Advanced Micro Devices, Inc. 3# All rights reserved. 4# 5# Redistribution and use in source and binary forms, with or without 6# modification, are permitted provided that the following conditions are 7# met: redistributions of source code must retain the above copyright 8# notice, this list of conditions and the following disclaimer; --- 189 unchanged lines hidden (view full) --- 198 def set_parent(self, parent, name): 199 if len(self) == 1: 200 self[0].set_parent(parent, name) 201 else: 202 width = int(math.ceil(math.log(len(self))/math.log(10))) 203 for i,v in enumerate(self): 204 v.set_parent(parent, "%s%0*d" % (name, width, i)) 205 |
206 def get_parent(self): 207 parent_set = set(v._parent for v in self) 208 if len(parent_set) != 1: 209 raise RuntimeError, \ 210 "SimObjectVector elements have inconsistent parent value." 211 return parent_set.pop() | 206 def has_parent(self): 207 return reduce(lambda x,y: x and y, [v.has_parent() for v in self]) |
212 213 # return 'cpu0 cpu1' etc. for print_ini() 214 def get_name(self): 215 return ' '.join([v._name for v in self]) 216 217 # By iterating through the constituent members of the vector here 218 # we can nicely handle iterating over all a SimObject's children 219 # without having to provide lots of special functions on --- 1269 unchanged lines hidden --- | 208 209 # return 'cpu0 cpu1' etc. for print_ini() 210 def get_name(self): 211 return ' '.join([v._name for v in self]) 212 213 # By iterating through the constituent members of the vector here 214 # we can nicely handle iterating over all a SimObject's children 215 # without having to provide lots of special functions on --- 1269 unchanged lines hidden --- |