Files
secondo/apis/python2/SecondoAPI/.ipynb_checkpoints/Rel_Attrib-checkpoint.ipynb

95 lines
2.6 KiB
Plaintext
Raw Normal View History

2026-01-23 17:03:45 +08:00
{
"cells": [
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"import import_ipynb\n",
"from PInt import *\n",
"from PReal import *\n",
"from PBool import *\n",
"from PString import *\n",
"from PText import *\n",
"\n",
"class Rel_Attrib():\n",
" \n",
" #identifier: The attribute's identifier\n",
" #typeName: The attribute's type as String\n",
" #att_type: The attribute's type as Class\n",
" #projected: If set to false, the attribute is not visible\n",
" \n",
" def __init__(self, identifier, typeName):\n",
" self.cls_name = {'bool':globals()[\"PBool\"],'int':globals()[\"PInt\"],'float':globals()[\"PReal\"],'String':globals()[\"PString\"],'Text':globals()[\"PText\"]}\n",
" self.identifier = identifier\n",
" self.typeName = typeName\n",
" self.att_type = self.cls_name[typeName].__name__\n",
" self.projected = True\n",
"\n",
" def get_Identifier(self):\n",
" return self.identifier\n",
" \n",
" \n",
" def getTypeName(self):\n",
" return self.typeName\n",
" \n",
" def getTypeClass(self):\n",
" return self.att_type\n",
"\n",
" def get_Projected(self):\n",
" return self.projected\n",
" \n",
"\n",
" def set_Projected(self, prj):\n",
" self.projected = prj\n",
"\n",
"\n",
" def __eq__(self, obj):\n",
" if obj is None:\n",
" return False\n",
" if not(self.get_Projected() or obj.get_Projected()):\n",
" return True\n",
" if not (self.identifier == obj.identifier):\n",
" return False\n",
" return True\n",
" \n",
" \n",
" def __hash__(self):\n",
" prm = 31\n",
" result = 1\n",
" result = prm * result + (0 if self.identifier is None else hash(self.identifier)) \n",
" return result\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.4"
}
},
"nbformat": 4,
"nbformat_minor": 2
}