/* automatically generated by JSCoverage - do not edit */
if (typeof _$jscoverage === 'undefined') _$jscoverage = {};
if (! _$jscoverage['plugins/Broadcaster.js']) {
  _$jscoverage['plugins/Broadcaster.js'] = [];
  _$jscoverage['plugins/Broadcaster.js'][1] = 0;
  _$jscoverage['plugins/Broadcaster.js'][5] = 0;
  _$jscoverage['plugins/Broadcaster.js'][44] = 0;
  _$jscoverage['plugins/Broadcaster.js'][54] = 0;
  _$jscoverage['plugins/Broadcaster.js'][55] = 0;
  _$jscoverage['plugins/Broadcaster.js'][56] = 0;
  _$jscoverage['plugins/Broadcaster.js'][57] = 0;
  _$jscoverage['plugins/Broadcaster.js'][58] = 0;
  _$jscoverage['plugins/Broadcaster.js'][73] = 0;
  _$jscoverage['plugins/Broadcaster.js'][74] = 0;
  _$jscoverage['plugins/Broadcaster.js'][78] = 0;
  _$jscoverage['plugins/Broadcaster.js'][79] = 0;
  _$jscoverage['plugins/Broadcaster.js'][80] = 0;
  _$jscoverage['plugins/Broadcaster.js'][81] = 0;
  _$jscoverage['plugins/Broadcaster.js'][83] = 0;
  _$jscoverage['plugins/Broadcaster.js'][85] = 0;
  _$jscoverage['plugins/Broadcaster.js'][95] = 0;
  _$jscoverage['plugins/Broadcaster.js'][96] = 0;
  _$jscoverage['plugins/Broadcaster.js'][97] = 0;
  _$jscoverage['plugins/Broadcaster.js'][98] = 0;
  _$jscoverage['plugins/Broadcaster.js'][99] = 0;
  _$jscoverage['plugins/Broadcaster.js'][100] = 0;
  _$jscoverage['plugins/Broadcaster.js'][101] = 0;
  _$jscoverage['plugins/Broadcaster.js'][102] = 0;
  _$jscoverage['plugins/Broadcaster.js'][103] = 0;
  _$jscoverage['plugins/Broadcaster.js'][113] = 0;
}
_$jscoverage['plugins/Broadcaster.js'][1]++;
var func = require("../base/functions"), define = require("../define").define;
_$jscoverage['plugins/Broadcaster.js'][5]++;
var Broadcaster = define(null, {instance: {constructor: (function () {
  _$jscoverage['plugins/Broadcaster.js'][44]++;
  this.__listeners = {};
}), broadcast: (function (topic, args) {
  _$jscoverage['plugins/Broadcaster.js'][54]++;
  var args = Array.prototype.slice.call(arguments, 0), topic = args.shift();
  _$jscoverage['plugins/Broadcaster.js'][55]++;
  if (topic && topic in this.__listeners) {
    _$jscoverage['plugins/Broadcaster.js'][56]++;
    var list = this.__listeners[topic], i = list.length - 1;
    _$jscoverage['plugins/Broadcaster.js'][57]++;
    while (i >= 0) {
      _$jscoverage['plugins/Broadcaster.js'][58]++;
      list[i--].cb.apply(this, args);
}
  }
}), listen: (function (topic, callback) {
  _$jscoverage['plugins/Broadcaster.js'][73]++;
  if (! func.isFunction(callback)) {
    _$jscoverage['plugins/Broadcaster.js'][73]++;
    throw new Error("callback must be a function");
  }
  _$jscoverage['plugins/Broadcaster.js'][74]++;
  var handle = {topic: topic, cb: callback};
  _$jscoverage['plugins/Broadcaster.js'][78]++;
  var list = this.__listeners[topic];
  _$jscoverage['plugins/Broadcaster.js'][79]++;
  if (! list) {
    _$jscoverage['plugins/Broadcaster.js'][80]++;
    list = (this.__listeners[topic] = [handle]);
    _$jscoverage['plugins/Broadcaster.js'][81]++;
    handle.pos = 0;
  }
  else {
    _$jscoverage['plugins/Broadcaster.js'][83]++;
    handle.pos = list.push(handle);
  }
  _$jscoverage['plugins/Broadcaster.js'][85]++;
  return handle;
}), unListen: (function (handle) {
  _$jscoverage['plugins/Broadcaster.js'][95]++;
  if (handle) {
    _$jscoverage['plugins/Broadcaster.js'][96]++;
    var topic = handle.topic;
    _$jscoverage['plugins/Broadcaster.js'][97]++;
    if (topic in this.__listeners) {
      _$jscoverage['plugins/Broadcaster.js'][98]++;
      var listeners = this.__listeners, list = listeners[topic];
      _$jscoverage['plugins/Broadcaster.js'][99]++;
      if (list) {
        _$jscoverage['plugins/Broadcaster.js'][100]++;
        for (var i = list.length - 1; i >= 0; i--) {
          _$jscoverage['plugins/Broadcaster.js'][101]++;
          if (list[i] == handle) {
            _$jscoverage['plugins/Broadcaster.js'][102]++;
            list.splice(i, 1);
            _$jscoverage['plugins/Broadcaster.js'][103]++;
            break;
          }
}
      }
    }
  }
})}});
_$jscoverage['plugins/Broadcaster.js'][113]++;
exports = module.exports = Broadcaster;
_$jscoverage['plugins/Broadcaster.js'].source = ["var func = require(\"../base/functions\"),","\t\tdefine = require(\"../define\").define;","","","var Broadcaster = define(null, {","\t\t\tinstance : {","\t\t\t\t/** @lends comb.plugins.Broadcaster.prototype */","\t\t\t\t/**","\t\t\t\t * Plugin to allow a class to easily broadcast events","\t\t\t\t *","\t\t\t\t * @example","\t\t\t\t *","\t\t\t\t * var Mammal = define(comb.plugins.Broadcaster, {","\t\t\t\t *   instance : {","\t\t\t\t *","\t\t\t\t *      constructor: function(options) {","\t\t\t\t *          options = options || {};","\t\t\t\t *          this.super(arguments);","\t\t\t\t *          this._type = options.type || \"mammal\";","\t\t\t\t *      },","\t\t\t\t *","\t\t\t\t *      speak : function() {","\t\t\t\t *          var str = \"A mammal of type \" + this._type + \" sounds like\";","\t\t\t\t *          this.broadcast(\"speak\", str);","\t\t\t\t *          this.onSpeak(str);","\t\t\t\t *          return str;","\t\t\t\t *      },","\t\t\t\t *","\t\t\t\t *      onSpeak : function(){}","\t\t\t\t *    }","\t\t\t\t * });","\t\t\t\t *","\t\t\t\t *","\t\t\t\t * var m = new Mammal({color : \"gold\"});","\t\t\t\t * m.listen(\"speak\", function(str){","\t\t\t\t *      //called back from the broadcast event","\t\t\t\t *       console.log(str);","\t\t\t\t * });","\t\t\t\t * m.speak();","\t\t\t\t *","\t\t\t\t * @constructs","\t\t\t\t */","\t\t\t\tconstructor : function() {","\t\t\t\t\tthis.__listeners = {};","\t\t\t\t},","","\t\t\t\t/**","\t\t\t\t * Broadcasts an event from an object","\t\t\t\t *","\t\t\t\t * @param name the name of the event to broadcast","\t\t\t\t * @param {Object|String|Function|Date|Number} [args]  variable number of arguments to pass to listeners, can be anything","\t\t\t\t */","\t\t\t\tbroadcast : function(topic, args) {","\t\t\t\t\tvar args = Array.prototype.slice.call(arguments, 0), topic = args.shift();","\t\t\t\t\tif (topic &amp;&amp; topic in this.__listeners) {","\t\t\t\t\t\tvar list = this.__listeners[topic], i = list.length - 1;","\t\t\t\t\t\twhile (i &gt;= 0) {","\t\t\t\t\t\t\tlist[i--].cb.apply(this, args);","\t\t\t\t\t\t}","\t\t\t\t\t}","\t\t\t\t},","","\t\t\t\t/**","\t\t\t\t * Listens to a broadcasted event","\t\t\t\t * Simimlar to {@link comb.listen}","\t\t\t\t *","\t\t\t\t * @param {String} topic the topic to listen to","\t\t\t\t * @param {Function} callback the function to callback on event publish","\t\t\t\t *","\t\t\t\t * @returns {Array} handle to disconnect a topic","\t\t\t\t */","\t\t\t\tlisten : function(topic, callback) {","\t\t\t\t\tif (!func.isFunction(callback)) throw new Error(\"callback must be a function\");","\t\t\t\t\tvar handle = {","\t\t\t\t\t\ttopic : topic,","\t\t\t\t\t\tcb : callback","\t\t\t\t\t};","\t\t\t\t\tvar list = this.__listeners[topic];","\t\t\t\t\tif (!list) {","\t\t\t\t\t\tlist = (this.__listeners[topic] = [handle]);","\t\t\t\t\t\thandle.pos = 0;","\t\t\t\t\t} else {","\t\t\t\t\t\thandle.pos = list.push(handle);","\t\t\t\t\t}","\t\t\t\t\treturn handle;","\t\t\t\t},","","\t\t\t\t/**","\t\t\t\t * Disconnects a listener","\t\t\t\t * Similar to {@link comb.unListen}","\t\t\t\t *","\t\t\t\t * @param  handle disconnect a handle returned from Broadcaster.listen","\t\t\t\t */","\t\t\t\tunListen : function(handle) {","\t\t\t\t\tif (handle) {","\t\t\t\t\t\tvar topic = handle.topic;","\t\t\t\t\t\tif (topic in this.__listeners) {","\t\t\t\t\t\t\tvar listeners = this.__listeners, list = listeners[topic];","\t\t\t\t\t\t\tif (list) {","\t\t\t\t\t\t\t\tfor (var i = list.length - 1; i &gt;= 0; i--) {","\t\t\t\t\t\t\t\t\tif (list[i] == handle) {","\t\t\t\t\t\t\t\t\t\tlist.splice(i, 1);","\t\t\t\t\t\t\t\t\t\tbreak;","\t\t\t\t\t\t\t\t\t}","\t\t\t\t\t\t\t\t}","\t\t\t\t\t\t\t}","\t\t\t\t\t\t}","\t\t\t\t\t}","\t\t\t\t}","\t\t\t}","\t\t});","","exports = module.exports = Broadcaster;"];
