/* Copyright (c) 2020, 2023, The Unified Company. This code is part of Unify. This program is free software; you can redistribute it and/or modify it under the terms of the ESA Software Community License - Strong Copyleft LICENSE, as published by the ESA. See the ESA Software Community License - Strong Copyleft LICENSE, for more details. https://unifyjs.org */ export default class cacheManager{ objects = new Array(); getObjectByClassName( object, id, classname ) { var arrayWithObjects = this.objects[ classname ]; if( arrayWithObjects ) { var output = arrayWithObjects[ id ]; if( output ) { object.serialize( output ); return object; } else { object.id = id; var row = object.getRow(); arrayWithObjects[ id ] = row; object.serialize( row ); return object; } } else { this.objects[ classname ] = new Array(); return this.getObjectByClassName( object, id, classname ); } } getObject( object, id ) { var className = object.getClassName(); return this.getObjectByClassName( object, id, className ); } getLocalObject( object, id, classname ) { var arrayWithObjects = this.objects[ classname ]; if( arrayWithObjects ) { var output = arrayWithObjects[ id ]; if( output ) { return output; } else { return false; } } else { this.objects[ classname ] = new Array(); return this.getLocalObject( object, id, classname ); } } addObject( object, id, classname ) { this.objects[ classname ][ id ] = object; } }