Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
nirth
committed
Jan 25, 2011
0 parents
commit cd9aeb3
Showing
23 changed files
with
920 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package eu.kiichigo.route.kore | ||
{ | ||
import spark.skins.spark.mediaClasses.fullScreen.FullScreenButtonSkin; | ||
|
||
public class Action implements IAction, IGuard | ||
{ | ||
/** | ||
* @private | ||
*/ | ||
protected var _route:IRoute; | ||
/** | ||
* @copy eu.kiichigo.route.kore.IAction#route | ||
*/ | ||
public function get route():IRoute | ||
{ | ||
return null; | ||
} | ||
/** | ||
* @private | ||
*/ | ||
public function set route(value:IRoute):void | ||
{ | ||
_route = value; | ||
} | ||
|
||
|
||
/** | ||
* @private | ||
*/ | ||
protected var _predicate:Object; | ||
/** | ||
* @copy eu.kiichigo.route.kore.IGuard#predicate | ||
*/ | ||
public function get predicate():Object | ||
{ | ||
return _predicate; | ||
} | ||
/** | ||
* | ||
*/ | ||
public function set predicate(value:Object):void | ||
{ | ||
_predicate = value; | ||
} | ||
|
||
/** | ||
* eu.kiichigo.route.kore.IAction#run | ||
*/ | ||
public function run( percept:Object ):IAction | ||
{ | ||
if( evaluate() ) | ||
exec( percept ); | ||
|
||
return this; | ||
} | ||
|
||
protected function evaluate():Boolean | ||
{ | ||
if( _predicate === null ) | ||
return true; | ||
else if( _predicate is Function ) | ||
return _predicate.call() as Boolean; | ||
else if( _predicate is Boolean ) | ||
return _predicate; | ||
|
||
return true; | ||
} | ||
|
||
/** | ||
* Override this method in subclassed, in order to implement functionality of a <code>Action</code> | ||
*/ | ||
protected function exec( percept:Object ):void | ||
{ | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package eu.kiichigo.route.kore | ||
{ | ||
public interface IAction | ||
{ | ||
/** | ||
* Reference to the <code>IRoute</code> instance that's a parent to current <code>IAction</code>. | ||
*/ | ||
function get route():IRoute; | ||
/** | ||
* @private | ||
*/ | ||
function set route( value:IRoute ):void; | ||
|
||
/** | ||
* Executes current <code>IAction</code> instance with <code>percept</code> received from the <code>IRoute</code> | ||
* @param percept <code>Object</code> passed by <code>IRoute</code>. | ||
* @return An instance of current <code>IAction</code>. | ||
*/ | ||
function run( percept:Object ):IAction; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package eu.kiichigo.route.kore | ||
{ | ||
public interface IActions extends IAction | ||
{ | ||
/** | ||
* Collection (vector) of <code>IAction</code> instances that will be run once this <code>IActions</code> instance is executed. | ||
*/ | ||
function get actions():Vector.<IAction>; | ||
/** | ||
* | ||
*/ | ||
function set actions( value:Vector.<IAction> ):void; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package eu.kiichigo.route.kore | ||
{ | ||
public interface IAgent | ||
{ | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package eu.kiichigo.route.kore | ||
{ | ||
public interface IAsyncAciton | ||
{ | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package eu.kiichigo.route.kore | ||
{ | ||
public interface IGuard | ||
{ | ||
/** | ||
* Allowed types are: <code>Boolean</code> or <code>Function</code> closure that returns a <code>Boolean</code>. | ||
* Indicates whether an <code>IGuard</code> instance will be executed or not. | ||
* | ||
* Default value is <code>true</code> | ||
*/ | ||
function get predicate():Object; | ||
/** | ||
* @private | ||
*/ | ||
function set predicate( value:Object ):void; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package eu.kiichigo.route.kore | ||
{ | ||
public interface IPattern | ||
{ | ||
/** | ||
* A <code>closure</code> that will match <code>percept</code> received by <code>IRoute<code> against current <code>IPattern</code>. | ||
* Allowed signatures are: | ||
* <ul> | ||
* <li><code>function myMatcher( pattern:IPattern, percept:Object ):Boolean</code></li> | ||
* <li><code>function myMatcher( percept:Object ):Boolean</code></li> | ||
* </ul> | ||
*/ | ||
function get matcher():Function; | ||
/** | ||
* @private | ||
*/ | ||
function set matcher( value:Function ):void; | ||
|
||
/** | ||
* Evaluates <code>percept</code> received by <code>IRoute</code> and returns <code>Boolean</code>. | ||
* If <code>true</code> <code>IRoute</code> will execute <code>IAction</code> instances and closures. | ||
*/ | ||
function match( percept:Object ):Boolean; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package eu.kiichigo.route.kore | ||
{ | ||
public interface IPerceiver | ||
{ | ||
function get route():IRoute; | ||
|
||
function set route( value:IRoute ):void; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package eu.kiichigo.route.kore | ||
{ | ||
public interface IRPCAction | ||
{ | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package eu.kiichigo.route.kore | ||
{ | ||
public interface IRoute | ||
{ | ||
/** | ||
* | ||
*/ | ||
function get percept():Object; | ||
|
||
/** | ||
* A reference to the <code>IRouter</code> instance that's a parent for current <code>IRoute</code>. | ||
*/ | ||
function get router():IRouter; | ||
/** | ||
* @private | ||
*/ | ||
function set router( value:IRouter ):void; | ||
|
||
/** | ||
* Allowed types are: | ||
* <ul> | ||
* <li>An instance of <code>IAction</code> or <code>IActions</code>.</li> | ||
* <li><code>Function</code> closure: A function closure with a signature: | ||
* <<code>function ():void</code> or <code>function ( percept:Object ):void</code>.</li> | ||
* <li><code>Array or <code>Vector</code>: of <code>Function</code> closures, or mixed type.</li> | ||
* </ul> | ||
*/ | ||
function get actions():Object; | ||
/** | ||
* @private | ||
*/ | ||
function set actions( value:Object ):void; | ||
|
||
/** | ||
* | ||
*/ | ||
function get perceiver():Object; | ||
/** | ||
* @private | ||
*/ | ||
function set perceiver( value:Object ):void; | ||
|
||
/** | ||
* <code>IPattern</code> instance or <code>closure</code> that will evaluate incoming <code>percept</code> and "decide" whether current <code>IRoute</code> instance will accept it or not. | ||
* In case of closure - allowed signatures are: | ||
* <code>function ( percept:Object ):Boolean</code> | ||
* <code>function ( pattern:Object, percept:Object ):Boolean</code>. | ||
*/ | ||
function get pattern():Object; | ||
/** | ||
* @private | ||
*/ | ||
function set pattern( value:Object ):void; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package eu.kiichigo.route.kore | ||
{ | ||
import eu.kiichigo.route.utils.ICache; | ||
|
||
public interface IRouter | ||
{ | ||
/** | ||
* An instance of <code>ICache</code> that handles creation and caching of <code>Models</code>, <code>Views</code> and various <code>Utility</code> classes. | ||
* <code>ICache</code> can be shared by multiple <code>IRouter</code> by changing <code>IRouter.group</code> value. | ||
*/ | ||
function get cache():ICache; | ||
|
||
/** | ||
* Indicates a group to wich current <code>IRouter</code> belongs. Default value is <code>null</code> which means that no group is created. | ||
*/ | ||
function get group():Object; | ||
/** | ||
* @private | ||
*/ | ||
function set group( value:Object ):void; | ||
|
||
/** | ||
* | ||
*/ | ||
function get routes():Vector.<IRoute>; | ||
/** | ||
* @private | ||
*/ | ||
function set routes( value:Vector.<IRoute> ):void; | ||
|
||
|
||
/** | ||
* Adds <code>IRoute</code> to a list of <code>IRouter.routes</code> and returns newly added <code>IRoute</code>. | ||
* | ||
* @param route <code>IRoute</code> instance to be added. | ||
* @return Added <code>IRoute</code> instance. | ||
*/ | ||
function add( route:IRoute ):IRoute; | ||
|
||
/** | ||
* Clears and removes all <code>IRoute</code> instances, reseting current <code>IRouter</code>. | ||
*/ | ||
function clear():void; | ||
} | ||
} |
Oops, something went wrong.