Packagecom.soma.core.model
Classpublic class SomaModels
InheritanceSomaModels Inheritance Object

Author: Romuald Quantin - www.soundstep.com

Resources: http://www.soundstep.com/downloads/somacore

Actionscript version: 3.0

Copyright: Mozilla Public License 1.1 (MPL 1.1) http://www.opensource.org/licenses/mozilla1.1.php

The SomaModels class handles the models of the application. See the Model class documentation for implementation.

See also

com.soma.core.model.Model


Protected Properties
 PropertyDefined By
  models : Dictionary
List of the models registered to the framework.
SomaModels
Public Methods
 MethodDefined By
  
SomaModels(instance:ISoma)
Create an instance of the SomaModels class.
SomaModels
  
addModel(modelName:String, model:IModel):IModel
Registers a model to the framework.
SomaModels
  
dispose():void
Destroys all the models and properties.
SomaModels
  
getModel(modelName:String):IModel
Retrieves the model instance that has been registered using its name.
SomaModels
  
getModels():Dictionary
Retrieves all the model instances that have been registered to the framework.
SomaModels
  
hasModel(modelName:String):Boolean
Indicates wether a model has been registered to the framework.
SomaModels
  
removeModel(modelName:String):void
Removes a model from the framework and call the dispose method of this model.
SomaModels
Property Detail
modelsproperty
protected var models:Dictionary

List of the models registered to the framework.

Constructor Detail
SomaModels()Constructor
public function SomaModels(instance:ISoma)

Create an instance of the SomaModels class. Should not be directly instantiated, the framework will instantiate the class.

Parameters
instance:ISoma — Framework instance.
Method Detail
addModel()method
public function addModel(modelName:String, model:IModel):IModel

Registers a model to the framework.

Parameters

modelName:String — Name of the model.
 
model:IModel — Instance of the model.

Returns
IModel — The model instance.

Example
addModel(MyModel.NAME, new MyModel());
dispose()method 
public function dispose():void

Destroys all the models and properties. The class will call the dispose method of each model instance.

getModel()method 
public function getModel(modelName:String):IModel

Retrieves the model instance that has been registered using its name.

Parameters

modelName:String — Name of the model.

Returns
IModel — A IModel instance.

Example
var myModel:MyModel = getModel(MyModel.NAME) as MyModel;
getModels()method 
public function getModels():Dictionary

Retrieves all the model instances that have been registered to the framework.

Returns
Dictionary — A Dictionary (the key of the Dictionary is the name used for the registration).

Example
var models:Dictionary = getModels();
hasModel()method 
public function hasModel(modelName:String):Boolean

Indicates wether a model has been registered to the framework.

Parameters

modelName:String — Name of the model.

Returns
Boolean — A Boolean.

Example
hasModel(MyModel.NAME);
removeModel()method 
public function removeModel(modelName:String):void

Removes a model from the framework and call the dispose method of this model.

Parameters

modelName:String — Name of the model.


Example
removeModel(MyModel.NAME);