params.py (8656:44203702a57a) | params.py (8664:42052d5bb793) |
---|---|
1# Copyright (c) 2004-2006 The Regents of The University of Michigan 2# Copyright (c) 2010-2011 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; --- 214 unchanged lines hidden (view full) --- 223 # we can nicely handle iterating over all a SimObject's children 224 # without having to provide lots of special functions on 225 # SimObjectVector directly. 226 def descendants(self): 227 for v in self: 228 for obj in v.descendants(): 229 yield obj 230 | 1# Copyright (c) 2004-2006 The Regents of The University of Michigan 2# Copyright (c) 2010-2011 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; --- 214 unchanged lines hidden (view full) --- 223 # we can nicely handle iterating over all a SimObject's children 224 # without having to provide lots of special functions on 225 # SimObjectVector directly. 226 def descendants(self): 227 for v in self: 228 for obj in v.descendants(): 229 yield obj 230 |
231 def get_config_as_dict(self): 232 a = [] 233 for v in self: 234 a.append(v.get_config_as_dict()) 235 return a 236 |
|
231class VectorParamDesc(ParamDesc): 232 # Convert assigned value to appropriate type. If the RHS is not a 233 # list or tuple, it generates a single-element list. 234 def convert(self, value): 235 if isinstance(value, (list, tuple)): 236 # list: coerce each element into new list 237 tmp_list = [ ParamDesc.convert(self, v) for v in value ] 238 else: --- 720 unchanged lines hidden (view full) --- 959 return c_time 960 961 def __str__(self): 962 return time.asctime(self.value) 963 964 def ini_str(self): 965 return str(self) 966 | 237class VectorParamDesc(ParamDesc): 238 # Convert assigned value to appropriate type. If the RHS is not a 239 # list or tuple, it generates a single-element list. 240 def convert(self, value): 241 if isinstance(value, (list, tuple)): 242 # list: coerce each element into new list 243 tmp_list = [ ParamDesc.convert(self, v) for v in value ] 244 else: --- 720 unchanged lines hidden (view full) --- 965 return c_time 966 967 def __str__(self): 968 return time.asctime(self.value) 969 970 def ini_str(self): 971 return str(self) 972 |
973 def get_config_as_dict(self): 974 return str(self) 975 |
|
967# Enumerated types are a little more complex. The user specifies the 968# type as Enum(foo) where foo is either a list or dictionary of 969# alternatives (typically strings, but not necessarily so). (In the 970# long run, the integer value of the parameter will be the list index 971# or the corresponding dictionary value. For now, since we only check 972# that the alternative is valid and then spit it into a .ini file, 973# there's not much point in using the dictionary.) 974 --- 574 unchanged lines hidden --- | 976# Enumerated types are a little more complex. The user specifies the 977# type as Enum(foo) where foo is either a list or dictionary of 978# alternatives (typically strings, but not necessarily so). (In the 979# long run, the integer value of the parameter will be the list index 980# or the corresponding dictionary value. For now, since we only check 981# that the alternative is valid and then spit it into a .ini file, 982# there's not much point in using the dictionary.) 983 --- 574 unchanged lines hidden --- |