You've already forked HeurAMS-legacy
重新实现对象系统
This commit is contained in:
@@ -1,13 +1,20 @@
|
||||
class Nucleon:
|
||||
"""核子: 材料元数据"""
|
||||
"""原子核: 材料元数据"""
|
||||
|
||||
def __init__(self, content: str, data: dict):
|
||||
self.metadata = data
|
||||
self.content = content
|
||||
def __init__(self, ident: str, metadata: dict):
|
||||
"""初始化原子核 (记忆内容)
|
||||
|
||||
Args:
|
||||
ident: 唯一标识符
|
||||
metadata: 记忆内容信息
|
||||
orbital: 记忆策略信息 (电子轨道)
|
||||
"""
|
||||
self.metadata = metadata
|
||||
self.ident = ident
|
||||
|
||||
def __getitem__(self, key):
|
||||
if key == "content":
|
||||
return self.content
|
||||
if key == "ident":
|
||||
return self.ident
|
||||
if key in self.metadata:
|
||||
return self.metadata[key]
|
||||
else:
|
||||
@@ -20,8 +27,9 @@ class Nucleon:
|
||||
return len(self.metadata)
|
||||
|
||||
def __hash__(self):
|
||||
return hash(self.content)
|
||||
return hash(self.ident)
|
||||
|
||||
@staticmethod
|
||||
def placeholder():
|
||||
"""生成一个占位原子核"""
|
||||
return Nucleon("核子对象样例内容", {})
|
||||
|
||||
Reference in New Issue
Block a user