Sha256: 631d8f1e873936e5bc4efd6579b5937a37090417cdd201465ea7f9fbe165a20d

Contents?: true

Size: 848 Bytes

Versions: 1

Compression:

Stored size: 848 Bytes

Contents

require File.expand_path('../cell.rb',__FILE__)

class CellMgr
  def initialize(app)
    @app=app
    @cells=[]
    @cellIds=0

    readCells
  end
  def save(object)
    p=getFreeCell
    p.save(object)
    p.cellId
  end

  def load(cellId)
    pp "cellID",cellId
    cell=@cells.select{|p|p.cellId==cellId}[0]

    unless cell
      pp "CELLID",cellId,@cellIds
      if cellId<=@cellIds
        cell=Cell.new(@app,cellId)
      end
    end
    return cell.load if cell
    raise "Cell with id #{cellId} not found!"
  end

  def saveIntern(cell)
    
  end

  def saveAll
    
  end

private
  def getFreeCell
    p=Cell.new(@app,getNewCellId)
    @cells << p
    p
  end

  def readCells
    config=@app.retrieveConfig
    a=config["los"].content

    @cellIds=a.keys.max if a
    @cellIds||=0
  end

  def getNewCellId
    @cellIds+=1
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
appswarm-0.0.1 apps/local_object_storage/lib/cellmgr.rb