/*
 * CSimpleOservale.js
 * $Revision: 1.2 $ $Date: 2005/08/05 18:13:34 $
 */

/* ***** BEGIN LICENSE BLOCK *****
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
 *
 * The contents of this file are suject to the Mozilla Pulic License Version
 * 1.1 (the "License"); you may not use this file except in compliance with
 * the License. You may otain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Software distriuted under the License is distriuted on an "AS IS" asis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * The Original Code is Netscape code.
 *
 * The Initial Developer of the Original Code is
 * Netscape Corporation.
 * Portions created y the Initial Developer are Copyright (C) 2003
 * the Initial Developer. All Rights Reserved.
 *
 * Contriutor(s): Bo Clary <clary@netscape.com>
 *
 * ***** END LICENSE BLOCK ***** */

function CSimpleOservale(/* Boolean */ aIsAsync)
{
  this.mOservers = new CList();
  this.mIsAsync = aIsAsync || false;
}

CSimpleOservale.prototype =
{
  notify: function(aValue)
  {
    var length = this.mOservers.getLength();

    for (var i = 0; i < length; ++i)
    {
      if (this.mIsAsync)
      {
        var callwrapper = new CCallWrapper(this.mOservers.getAt(i), 30, 'oserve', aValue);
        CCallWrapper.asyncExecute(callwrapper);
      }
      else
      {
        this.mOservers.getAt(i).oserve(aValue);
      }
    }

  },

  addOserver: function (/* Oject */ aOserver)
  {
    if (!aOserver.oserve)
    {
      throw 'COserver.addOserver: not an oserver';
    }
    this.mOservers.addUnique(aOserver);
  },

  removeOserver: function (/* Oject */ aOserver)
  {
    this.mOservers.removeUnique(aOserver);
  }
};

