1 /*!
  2  * This file is part of Aloha Editor
  3  * Author & Copyright (c) 2010 Gentics Software GmbH, aloha@gentics.com
  4  * Licensed unter the terms of http://www.aloha-editor.com/license.html
  5  */
  6 
  7 /**
  8  * Registry base class.
  9  * TODO: document that it also contains Observable.
 10  *
 11  */
 12 define(
 13 ['aloha/jquery', 'aloha/observable', 'util/class'],
 14 function(jQuery, Observable, Class) {
 15 	"use strict";
 16 
 17 	return Class.extend(Observable, {
 18 
 19 		_entries: null,
 20 
 21 		_constructor: function() {
 22 			this._entries = {};
 23 		},
 24 
 25 		/**
 26 		 * @event register
 27 		 * @param entry
 28 		 * @param id
 29 		 */
 30 		register: function(id, entry) {
 31 			this._entries[id] = entry;
 32 			this.trigger('register', entry, id);
 33 		},
 34 
 35 		/**
 36 		 * @event unregister
 37 		 * @param id
 38 		 */
 39 		unregister: function(id) {
 40 			var oldEntry = this._entries[id];
 41 			delete this._entries[id];
 42 			this.trigger('unregister', oldEntry, id);
 43 		},
 44 		
 45 		get: function(id) {
 46 			return this._entries[id];
 47 		},
 48 		
 49 		has: function(id) {
 50 			return (this._entries[id] ? true : false);
 51 		},
 52 		
 53 		getEntries: function() {
 54 			// clone the entries so the user does not accidentally modify our _entries object.
 55 			return jQuery.extend({}, this._entries);
 56 		}
 57 	});
 58 });