| <?php
/*
    DataSource.lib, DomCore, the WebAbility(r) Core System
    Contains the basic data access object
    (c) 2008-2012 Philippe Thomassigny
    This file is part of DomCore
    DomCore is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
    DomCore is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
    You should have received a copy of the GNU General Public License
    along with DomCore.  If not, see <http://www.gnu.org/licenses/>.
*/
/* @UML_Box -- Do not edit
|------------------------------------------------------------------|
| DataSource : Basic data access object                            |
|------------------------------------------------------------------|
| # data : mixed                                                   |
| # timestamp : integer                                            |
|------------------------------------------------------------------|
| + new DataSource($data: mixed)                                   |
| + isValid() : boolean                                            |
| + getTimestamp() : integer                                       |
| + read() : mixed                                                 |
| + write($data: mixed) : void                                     |
| + unlink() : void                                                |
|------------------------------------------------------------------|
|------------------------------------------------------------------|
@End_UML_Box */
class DataSource extends WAObject
{
  protected $data = null;
  protected $timestamp = null;
  public function __construct($data)
  {
    parent::__construct();
    if (self::$debug || $this->localdebug)
      $this->doDebug("include/datasources/DataSource->__construct($data)", WADebug::SYSTEM);
    if ($data)
    {
      $this->data = $data;
      $this->timestamp = microtime(true);
    }
  }
  public function isValid()
  {
    if (self::$debug || $this->localdebug)
      $this->doDebug('include/datasources/DataSource->isValid()', WADebug::SYSTEM);
    return !!$this->timestamp;
  }
  public function getTimeStamp()
  {
    if (self::$debug || $this->localdebug)
      $this->doDebug('include/datasources/DataSource->getTimeStamp()', WADebug::SYSTEM);
    return $this->timestamp;
  }
  public function read()
  {
    if (self::$debug || $this->localdebug)
      $this->doDebug('include/datasources/DataSource->read()', WADebug::SYSTEM);
    return $this->data;
  }
  public function write($data)
  {
    if (self::$debug || $this->localdebug)
      $this->doDebug("include/datasources/DataSource->write($data)", WADebug::SYSTEM);
    $this->data = $data;
    $this->timestamp = microtime(true);
  }
  public function unlink()
  {
    if (self::$debug || $this->localdebug)
      $this->doDebug('include/datasources/DataSource->unlink()', WADebug::SYSTEM);
    $this->data = null;
    $this->timestamp = null;
  }
}
?>
 |