systems generation ok for now

master
Theunis J. Botha 2021-07-12 12:02:59 +02:00
parent 3c955fe495
commit 3711c85887
22 changed files with 806 additions and 783 deletions

542
dist/r3.js vendored
View File

@ -1,6 +1,6 @@
class R3 {
static version = '2.0.25';
static compileDate = '2021 Jul 05 - 10:20:49 am';
static version = '2.0.82';
static compileDate = '2021 Jul 12 - 12:02:40 pm';
}
class System {
@ -9,13 +9,6 @@ class System {
Event.Emit(Event.OBJECT_CREATED, this);
if (typeof options === 'undefined') {
options = {};
}
if (Utils.UndefinedOrNull(options.started)) {
options.started = false;
}
Object.assign(this, options);
Event.Emit(Event.OBJECT_INITIALIZED, this);
@ -30,12 +23,7 @@ class System {
start(options) {
System.Start(options);
/**
* Now do something else
*/
console.log('something else');
this.started = true;
}
@ -47,6 +35,7 @@ class System {
stop(options) {
System.Stop(options);
this.started = false;
}
@ -57,7 +46,13 @@ class System {
*/
static Start(options) {
console.log('Starting system X');
if ('System' !== 'System') {
System.Start();
}
System.Started = true;
console.log('Started System');
}
@ -68,12 +63,20 @@ class System {
*/
static Stop(options) {
console.log('Stopping system X');
if ('System' !== 'System') {
System.Stop(options);
}
System.Started = false;
console.log('Stopped System');
}
}
System.Started = false;
class Event {
constructor(options) {
@ -241,7 +244,8 @@ class Event {
* Subscribe()
* - Subscribes to 'eventName', ex. Event.BEFORE_RENDER and executes 'callback()' when eventName is raised
* @param eventId
* @param callback \n * @returns {Object} - A handle to the subscription which can be removed by calling handle.remove()
* @param callback
* @returns {Object} - A handle to the subscription which can be removed by calling handle.remove()
*/
static Subscribe(
eventId,
@ -1589,7 +1593,7 @@ class Utils {
Properties:
- started (Default value false)
<no inherited properties>
Methods:
@ -1629,6 +1633,9 @@ class Utils {
- Stop(options)
Stops the system by removing these subscriptions to events
Event.OBJECT_CREATED
Event.INSTANCE_CREATED
**/
class SystemLinking extends System {
@ -1656,6 +1663,9 @@ class SystemLinking extends System {
*/
start(options) {
SystemLinking.Start(options);
this.started = true;
}
/**
@ -1665,6 +1675,96 @@ class SystemLinking extends System {
*/
stop(options) {
SystemLinking.Stop(options);
this.started = false;
}
/**
* Start()
* - Starts the system by registering subscriptions to events
* @param options
*/
static Start(options) {
if ('System' !== 'SystemLinking') {
System.Start();
}
SystemLinking.Subscriptions.push(
new Event.Subscribe(
Event.OBJECT_CREATED,
SystemLinking.OnObjectCreated
)
);
SystemLinking.Subscriptions.push(
new Event.Subscribe(
Event.INSTANCE_CREATED,
SystemLinking.OnInstanceCreated
)
);
SystemLinking.Started = true;
console.log('Started SystemLinking');
}
/**
* Stop()
* - Stops the system by removing these subscriptions to events
* @param options
*/
static Stop(options) {
if ('System' !== 'SystemLinking') {
System.Stop(options);
}
SystemLinking.Subscriptions = SystemLinking.Subscriptions.reduce(
(result, subscription) => {
if (subscription.remove() !== true) {
result.push(subscription);
}
return result;
},
[]
);
SystemLinking.Subscriptions = SystemLinking.Subscriptions.reduce(
(result, subscription) => {
if (subscription.remove() !== true) {
result.push(subscription);
}
return result;
},
[]
);
SystemLinking.Started = false;
console.log('Stopped SystemLinking');
}
/**
* OnObjectCreated()
* - Listens to events of type Event.OBJECT_CREATED and executes this function.
* @param data (The event data passed as argument - typically an R3Object)
* @return null
*/
static OnObjectCreated(data) {
}
/**
* OnInstanceCreated()
* - Listens to events of type Event.INSTANCE_CREATED and executes this function.
* @param data (The event data passed as argument - typically an R3Object)
* @return null
*/
static OnInstanceCreated(data) {
}
}
@ -1675,7 +1775,7 @@ class SystemLinking extends System {
Properties:
- started (Default value false)
<no inherited properties>
Methods:
@ -1742,6 +1842,9 @@ class SystemSocket extends System {
*/
start(options) {
SystemSocket.Start(options);
this.started = true;
}
/**
@ -1751,6 +1854,43 @@ class SystemSocket extends System {
*/
stop(options) {
SystemSocket.Stop(options);
this.started = false;
}
/**
* Start()
* - Starts the system by registering subscriptions to events
* @param options
*/
static Start(options) {
if ('System' !== 'SystemSocket') {
System.Start();
}
SystemSocket.Started = true;
console.log('Started SystemSocket');
}
/**
* Stop()
* - Stops the system by removing these subscriptions to events
* @param options
*/
static Stop(options) {
if ('System' !== 'SystemSocket') {
System.Stop(options);
}
SystemSocket.Started = false;
console.log('Stopped SystemSocket');
}
}
@ -1761,7 +1901,7 @@ class SystemSocket extends System {
Properties:
- started (Default value false)
<no inherited properties>
Methods:
@ -1828,6 +1968,9 @@ class SystemTest extends System {
*/
start(options) {
SystemTest.Start(options);
this.started = true;
}
/**
@ -1837,6 +1980,43 @@ class SystemTest extends System {
*/
stop(options) {
SystemTest.Stop(options);
this.started = false;
}
/**
* Start()
* - Starts the system by registering subscriptions to events
* @param options
*/
static Start(options) {
if ('System' !== 'SystemTest') {
System.Start();
}
SystemTest.Started = true;
console.log('Started SystemTest');
}
/**
* Stop()
* - Stops the system by removing these subscriptions to events
* @param options
*/
static Stop(options) {
if ('System' !== 'SystemTest') {
System.Stop(options);
}
SystemTest.Started = false;
console.log('Stopped SystemTest');
}
}
@ -1974,34 +2154,11 @@ class R3Object extends Event {
Properties:
- x (Default value 0)
- y (Default value 0)
- z (Default value 0)
<no static properties>
Methods:
- createInstance()
Creates an instance of this object based on the runtime.
- updateInstance(property)
Updates the instance property, ex. 'x', or specify 'all' to update all properties based on the current object
property(ies)
- updateFromInstance(property)
Updates the object property, ex. 'x', or specify 'all' to update all properties of this object based on the
value of the instance property(ies)
- dispose()
Sends out a notification that this object wants to be deleted. It will first send out a message to delete it's
instance, because an object instance should not exist without an object parent (except maybe for particles)
- disposeInstance()
This will signal all systems that an instance wants to be deleted. Once it has been deleted, another event
will be triggered to notify listeners of the deletion of this instance. This can give 'dispose()' a chance to
dispose the object parent this instance.
- toApiObject()
Transforms the current object into JSON ready to be stored to the back-end.
<no methods>
Static Methods:
@ -2025,158 +2182,12 @@ class Component extends R3Object {
this.emit(Event.OBJECT_CREATED, this);
if (typeof options === 'undefined') {
options = {};
}
if (Utils.UndefinedOrNull(options.x)) {
options.x = 0;
}
if (Utils.UndefinedOrNull(options.y)) {
options.y = 0;
}
if (Utils.UndefinedOrNull(options.z)) {
options.z = 0;
}
Object.assign(this, options);
this.emit(Event.OBJECT_INITIALIZED, this);
}
/**
* createInstance()
* - Creates an instance of this object based on the runtime.
*/
createInstance() {
this.emit(Event.CREATE_INSTANCE_BEFORE, this);
this[this.runtime].createInstance(
this,
{
'x': this.x,
'y': this.y,
'z': this.z
}
)
this.emit(Event.INSTANCE_CREATED, this);
}
/**
* updateInstance()
* - Updates the instance property, ex. 'x', or specify 'all' to update all properties based on the current object
* property(ies)
* @param property
*/
updateInstance(property) {
this.emit(Event.UPDATE_INSTANCE_BEFORE, this);
if (property === 'x') {
this.instance.x = this.x;
if (property !== 'all') {
this.emit(Event.UPDATE_INSTANCE_AFTER, this);
return;
}
}
if (property === 'y') {
this.instance.y = this.y;
if (property !== 'all') {
this.emit(Event.UPDATE_INSTANCE_AFTER, this);
return;
}
}
if (property === 'z') {
this.instance.z = this.z;
if (property !== 'all') {
this.emit(Event.UPDATE_INSTANCE_AFTER, this);
return;
}
}
this.emit(Event.UPDATE_INSTANCE_AFTER, this);
}
/**
* updateFromInstance()
* - Updates the object property, ex. 'x', or specify 'all' to update all properties of this object based on the
* value of the instance property(ies)
* @param property
*/
updateFromInstance(property) {
this.emit(Event.UPDATE_FROM_INSTANCE_BEFORE, this);
if (property === 'x' || property === 'all') {
this.x = this.instance.x;
if (property !== 'all') {
this.emit(Event.UPDATE_FROM_INSTANCE_AFTER, this);
return;
}
}
if (property === 'y' || property === 'all') {
this.y = this.instance.y;
if (property !== 'all') {
this.emit(Event.UPDATE_FROM_INSTANCE_AFTER, this);
return;
}
}
if (property === 'z' || property === 'all') {
this.z = this.instance.z;
if (property !== 'all') {
this.emit(Event.UPDATE_FROM_INSTANCE_AFTER, this);
return;
}
}
this.emit(Event.UPDATE_FROM_INSTANCE_AFTER, this);
}
/**
* dispose()
* - Sends out a notification that this object wants to be deleted. It will first send out a message to delete it's
* instance, because an object instance should not exist without an object parent (except maybe for particles)
*/
dispose() {
this.subscribe(
Event.INSTANCE_DISPOSED,
function(object) {
if (object === this) {
this.emit(Event.DISPOSE_OBJECT, this);
}
}
);
this.disposeInstance();
}
/**
* disposeInstance()
* - This will signal all systems that an instance wants to be deleted. Once it has been deleted, another event
* will be triggered to notify listeners of the deletion of this instance. This can give 'dispose()' a chance to
* dispose the object parent this instance.
*/
disposeInstance() {
console.log('Disposing instance of ' + this.name);
this.emit(Event.DISPOSE_INSTANCE, this);
}
/**
* toApiObject()
* - Transforms the current object into JSON ready to be stored to the back-end. \n * @returns JSON
*/
toApiObject() {
}
}
/**
@ -2267,16 +2278,6 @@ class Project extends R3Object {
}
Project.CAMERA_INDEX_EDIT = 0x0;
Project.CAMERA_INDEX_RUN = 0x1;
Project.APPLICATION_MODE_EDIT = Project.CAMERA_INDEX_EDIT;
Project.APPLICATION_MODE_RUN = Project.CAMERA_INDEX_RUN;
Project.RENDERER_INDEX_MAIN = 0x0;
Project.RENDER_TARGET_INDEX_NONE = -0x1;
/**
[Inherited from Event]
@ -2329,34 +2330,11 @@ Project.RENDER_TARGET_INDEX_NONE = -0x1;
Properties:
- x (Default value 0)
- y (Default value 0)
- z (Default value 0)
<no inherited properties>
Methods:
- createInstance()
Creates an instance of this object based on the runtime.
- updateInstance(property)
Updates the instance property, ex. 'x', or specify 'all' to update all properties based on the current object
property(ies)
- updateFromInstance(property)
Updates the object property, ex. 'x', or specify 'all' to update all properties of this object based on the
value of the instance property(ies)
- dispose()
Sends out a notification that this object wants to be deleted. It will first send out a message to delete it's
instance, because an object instance should not exist without an object parent (except maybe for particles)
- disposeInstance()
This will signal all systems that an instance wants to be deleted. Once it has been deleted, another event
will be triggered to notify listeners of the deletion of this instance. This can give 'dispose()' a chance to
dispose the object parent this instance.
- toApiObject()
Transforms the current object into JSON ready to be stored to the back-end.
<no inherited methods>
Static Methods:
@ -2370,28 +2348,7 @@ Project.RENDER_TARGET_INDEX_NONE = -0x1;
Methods:
- createInstance()
Creates an instance of this object based on the runtime.
- updateInstance(property)
Updates the instance property, ex. 'x', or specify 'all' to update all properties based on the current object
property(ies)
- updateFromInstance(property)
Updates the object property, ex. 'x', or specify 'all' to update all properties of this object based on the
value of the instance property(ies)
- dispose()
Sends out a notification that this object wants to be deleted. It will first send out a message to delete it's
instance, because an object instance should not exist without an object parent (except maybe for particles)
- disposeInstance()
This will signal all systems that an instance wants to be deleted. Once it has been deleted, another event
will be triggered to notify listeners of the deletion of this instance. This can give 'dispose()' a chance to
dispose the object parent this instance.
- toApiObject()
Transforms the current object into JSON ready to be stored to the back-end.
<no methods>
Static Methods:
@ -2421,92 +2378,6 @@ class Image extends Component {
}
/**
* createInstance()
* - Creates an instance of this object based on the runtime.
*/
createInstance() {
this.emit(Event.CREATE_INSTANCE_BEFORE, this);
this[this.runtime].createInstance(
this,
{
}
)
this.emit(Event.INSTANCE_CREATED, this);
}
/**
* updateInstance()
* - Updates the instance property, ex. 'x', or specify 'all' to update all properties based on the current object
* property(ies)
* @param property
*/
updateInstance(property) {
this.emit(Event.UPDATE_INSTANCE_BEFORE, this);
this.emit(Event.UPDATE_INSTANCE_AFTER, this);
}
/**
* updateFromInstance()
* - Updates the object property, ex. 'x', or specify 'all' to update all properties of this object based on the
* value of the instance property(ies)
* @param property
*/
updateFromInstance(property) {
this.emit(Event.UPDATE_FROM_INSTANCE_BEFORE, this);
this.emit(Event.UPDATE_FROM_INSTANCE_AFTER, this);
}
/**
* dispose()
* - Sends out a notification that this object wants to be deleted. It will first send out a message to delete it's
* instance, because an object instance should not exist without an object parent (except maybe for particles)
*/
dispose() {
this.subscribe(
Event.INSTANCE_DISPOSED,
function(object) {
if (object === this) {
this.emit(Event.DISPOSE_OBJECT, this);
}
}
);
this.disposeInstance();
}
/**
* disposeInstance()
* - This will signal all systems that an instance wants to be deleted. Once it has been deleted, another event
* will be triggered to notify listeners of the deletion of this instance. This can give 'dispose()' a chance to
* dispose the object parent this instance.
*/
disposeInstance() {
console.log('Disposing instance of ' + this.name);
this.emit(Event.DISPOSE_INSTANCE, this);
}
/**
* toApiObject()
* - Transforms the current object into JSON ready to be stored to the back-end. \n * @returns JSON
*/
toApiObject() {
}
}
R3.Object = R3Object;
@ -2521,7 +2392,6 @@ R3.Event.Object = R3Object;
R3.Event.Object.Component = Component;
R3.Event.Object.Project = Project;
R3.Event.Object.Component.Image = Image;
R3.Project = Project;
console.log('r3.js - version ' + R3.version + ' compiled ' + R3.compileDate);

View File

@ -1,6 +1,6 @@
{
"name": "r3",
"version" : "2.0.25",
"version" : "2.0.82",
"description": "",
"private": true,
"dependencies": {

View File

@ -4,6 +4,18 @@
include "utils.php";
include "graph.php";
function to_camel_case_from_uppper_underscore($string, $capitalizeFirstCharacter = true)
{
$str = str_replace(' ', '', ucwords(str_replace('_', ' ', strtolower($string))));
if (!$capitalizeFirstCharacter) {
$str[0] = strtolower($str[0]);
}
return $str;
}
function from_camel_case($input) {
preg_match_all('!([A-Z][A-Z0-9]*(?=$|[A-Z][a-z0-9])|[A-Za-z][a-z0-9]+)!', $input, $matches);
$ret = $matches[0];
@ -559,6 +571,69 @@ function generateUpdateFromInstanceOptions($file, $tokens)
}
}
function generateEventListenersStart($file, $tokens)
{
$token = 'CUSTOM_EVENT_LISTENERS';
$store = getTokenStore($token, $tokens);
if (sizeof($store) <= 0) {
return;
}
echo "Will be building events for $file\n";
$template = file_get_contents('src/templates/generate_event_listeners_start.template');
$updated = '';
foreach ($store as $item) {
$item = trim($item);
$eventName = preg_replace('/Event./', '', $item);
$methodName = 'ON_'.$eventName;
$methodName = to_camel_case_from_uppper_underscore($methodName);
$updates = str_replace('EVENT_NAME', $item, $template);
$updates = str_replace('CALL_BACK', $methodName, $updates);
$updated .= $updates;
}
updateSection($file, 'GENERATE_EVENT_LISTENERS_START' , $updated);
}
function generateEventListenersStop($file, $tokens)
{
$token = 'CUSTOM_EVENT_LISTENERS';
$store = getTokenStore($token, $tokens);
if (sizeof($store) <= 0) {
return;
}
echo "Will be events for $file\n";
$template = file_get_contents('src/templates/generate_event_listeners_stop.template');
$updated = '';
foreach ($store as $item) {
$item = trim($item);
$updates = str_replace('EVENT_NAME', $item, $template);
$updated .= $updates;
}
updateSection($file, 'GENERATE_EVENT_LISTENERS_STOP' , $updated);
}
/**
* @param $item
* @return array
@ -654,14 +729,19 @@ function doMethodUpdate($template, $tokens, $token)
}
if ($returns !== null) {
$returns = '\n * @returns ' . $returns;
$returns = "\n * @returns " . $returns;
}
$comment = wordwrap($comment, 110, "\n * ");
$updated = $template;
$potentialTemplate = strtolower('src/templates/' . $methodTokenName . '.template');
if ($token === 'CUSTOM_METHODS') {
$potentialTemplate = strtolower('src/templates/' . $methodTokenName . '.template');
} else {
$potentialTemplate = strtolower('src/templates/static_' . $methodTokenName . '.template');
}
if (file_exists($potentialTemplate)) {
$functionTemplate = file_get_contents($potentialTemplate);
$updated = preg_replace('/^\s*FUNCTION_TEMPLATE/m', $functionTemplate, $updated);
@ -697,6 +777,128 @@ function generateStaticMethods($file, $tokens)
}
function getEventListenerUpdates($template, $tokens, $token)
{
$store = getTokenStore($token, $tokens);
if (sizeof($store) <= 0) {
return null;
}
$updates = '';
foreach ($store as $item) {
// $detail = getMethodDetails($item);
// $argsArray = $detail['argsArray'];
// $args = $detail['args'];
// $methodTokenName = $detail['methodTokenName'];
// $methodName = $detail['methodName'];
// $comment = $detail['comment'];
// $returns = $detail['returns'];
//
// if (sizeof($argsArray) > 1) {
// $args = implode(",\n ", $argsArray);
// $args = "\n " . $args . "\n ";
// $params = implode("\n * @param ", $argsArray);
// $params = "\n * @param " . $params;
// } else if (sizeof($argsArray) === 1) {
// if ($args === '') {
// $params = $args;
// } else {
// $params = "\n * @param " . $args;
// }
// }
//
// if ($returns !== null) {
// $returns = "\n * @returns " . $returns;
// }
//
// $comment = wordwrap($comment, 110, "\n * ");
//
// $updated = $template;
//
// if ($token === 'CUSTOM_METHODS') {
// $potentialTemplate = strtolower('src/templates/' . $methodTokenName . '.template');
// } else {
// $potentialTemplate = strtolower('src/templates/static_' . $methodTokenName . '.template');
// }
//
// if (file_exists($potentialTemplate)) {
// $functionTemplate = file_get_contents($potentialTemplate);
// $updated = preg_replace('/^\s*FUNCTION_TEMPLATE/m', $functionTemplate, $updated);
// } else {
// $updated = preg_replace('/^.*?FUNCTION_TEMPLATE.*\n/m', '', $updated);
// }
//
// $updated = str_replace('METHOD_ARGS', $args, $updated);
// $updated = str_replace('METHOD_NAME_UPPERCASE', $methodTokenName, $updated);
// $updated = str_replace('METHOD_NAME', $methodName, $updated);
// $updated = str_replace('COMMENT', $comment, $updated);
// $updated = str_replace('PARAMS', $params, $updated);
// $updated = str_replace('RETURNS', $returns, $updated);
$item = trim($item);
$eventName = preg_replace('/Event./', '', $item);
$methodName = 'ON_'.$eventName;
$methodTokenName = $methodName;
$methodName = to_camel_case_from_uppper_underscore($methodName);
$updated = $template;
$methodArgs = 'data';
$params = "\n * @param " . $methodArgs . " (The event data passed as argument - typically an R3Object)";
$returns = "\n * @return null";
$potentialTemplate = strtolower('src/templates/static_' . $methodTokenName . '.template');
if (file_exists($potentialTemplate)) {
$functionTemplate = file_get_contents($potentialTemplate);
$updated = preg_replace('/^\s*FUNCTION_TEMPLATE/m', $functionTemplate, $updated);
} else {
$updated = preg_replace('/^.*?FUNCTION_TEMPLATE.*\n/m', '', $updated);
}
$updated = str_replace('METHOD_NAME_UPPERCASE', $methodTokenName, $updated);
$updated = str_replace('METHOD_NAME', $methodName, $updated);
$updated = str_replace('METHOD_ARGS', $methodArgs, $updated);
$comment = 'Listens to events of type ' . $item . ' and executes this function.';
$comment = wordwrap($comment, 110, "\n * ");
$updated = str_replace('COMMENT', $comment, $updated);
$updated = str_replace('PARAMS', $params, $updated);
$updated = str_replace('RETURNS', $returns, $updated);
$updates .= $updated;
}
return $updates;
}
function generateStaticEventListenerMethods($file, $tokens)
{
$token = 'CUSTOM_EVENT_LISTENERS';
$template = file_get_contents('src/templates/generate_static_methods.template');
$updates = getEventListenerUpdates($template, $tokens, $token);
if ($updates) {
echo "Updating static event listeners.. \n";
updateSection($file, 'GENERATE_STATIC_EVENT_LISTENER_METHODS', $updates);
} else {
echo "No static event listeners found to generate\n";
}
}
function generateMethods($file, $tokens)
{
$token = 'CUSTOM_METHODS';
@ -853,6 +1055,8 @@ foreach ($files as $file) {
generateStaticMethods($file, $tokens);
generateStaticEventListenerMethods($file, $tokens);
generateInitOptions($file, $tokens);
generateCreateInstanceOptions($file, $tokens);
@ -861,6 +1065,10 @@ foreach ($files as $file) {
generateUpdateFromInstanceOptions($file, $tokens);
generateEventListenersStart($file, $tokens);
generateEventListenersStop($file, $tokens);
/**
* Try to restore the rest of the old data because now methods were generated.
* If not all data restores now - a method name / token has changed and we need
@ -1104,6 +1312,32 @@ function generateR3Dist($nodes)
}
function updateParentSystems($nodes)
{
foreach ($nodes as $node) {
if (preg_match('/System/', $node->name)) {
$className = $node->name;
$parentName = $node->parent->name;
if ($node->parent->parent === null) {
/**
* We are working with the base system class
*/
$parentName = $node->name;
}
$contents = file_get_contents($node->file);
$contents = preg_replace('/PARENT_SYSTEM/', $parentName, $contents);
$contents = preg_replace('/CLASS_NAME/', $className, $contents);
$contents = preg_replace('/SYSTEM_NAME/', $className, $contents);
file_put_contents($node->file, $contents);
}
}
}
if ($argv[2] == 'build-dist') {
global $nodeList;
@ -1138,9 +1372,13 @@ if ($argv[2] == 'build-dist') {
$nodes = $graph->walk();
// Remove R3 (first node) from the list
array_shift($nodes);
updateParentSystems($nodes);
generateR3($nodes);
generateR3Dist($nodes);
foreach ($files as $file) {
$saveFile = $file . '.saved';

View File

@ -56,34 +56,11 @@ const R3Object = require('.././r3-r3-object.js');
Properties:
- x (Default value 0)
- y (Default value 0)
- z (Default value 0)
<no static properties>
Methods:
- createInstance()
Creates an instance of this object based on the runtime.
- updateInstance(property)
Updates the instance property, ex. 'x', or specify 'all' to update all properties based on the current object
property(ies)
- updateFromInstance(property)
Updates the object property, ex. 'x', or specify 'all' to update all properties of this object based on the
value of the instance property(ies)
- dispose()
Sends out a notification that this object wants to be deleted. It will first send out a message to delete it's
instance, because an object instance should not exist without an object parent (except maybe for particles)
- disposeInstance()
This will signal all systems that an instance wants to be deleted. Once it has been deleted, another event
will be triggered to notify listeners of the deletion of this instance. This can give 'dispose()' a chance to
dispose the object parent this instance.
- toApiObject()
Transforms the current object into JSON ready to be stored to the back-end.
<no methods>
Static Methods:
@ -93,9 +70,6 @@ const R3Object = require('.././r3-r3-object.js');
Of the form x=<value>
CUSTOM_OPTIONS_START
x=0
y=0
z=0
CUSTOM_OPTIONS_END
Of the form x=<instance.property>
@ -109,12 +83,6 @@ const R3Object = require('.././r3-r3-object.js');
CUSTOM_EXCLUDED_FROM_INSTANCE_OPTIONS_END
CUSTOM_METHODS_START
createInstance() - Creates an instance of this object based on the runtime.
updateInstance(property) - Updates the instance property, ex. 'x', or specify 'all' to update all properties based on the current object property(ies)
updateFromInstance(property) - Updates the object property, ex. 'x', or specify 'all' to update all properties of this object based on the value of the instance property(ies)
dispose() - Sends out a notification that this object wants to be deleted. It will first send out a message to delete it's instance, because an object instance should not exist without an object parent (except maybe for particles)
disposeInstance() - This will signal all systems that an instance wants to be deleted. Once it has been deleted, another event will be triggered to notify listeners of the deletion of this instance. This can give 'dispose()' a chance to dispose the object parent this instance.
toApiObject() - Transforms the current object into JSON ready to be stored to the back-end. @returns JSON
CUSTOM_METHODS_END
CUSTOM_STATIC_METHODS_START
@ -136,18 +104,6 @@ class Component extends R3Object {
this.emit(Event.OBJECT_CREATED, this);
//GENERATE_OPTIONS_INIT_START
if (typeof options === 'undefined') {
options = {};
}
if (Utils.UndefinedOrNull(options.x)) {
options.x = 0;
}
if (Utils.UndefinedOrNull(options.y)) {
options.y = 0;
}
if (Utils.UndefinedOrNull(options.z)) {
options.z = 0;
}
//GENERATE_OPTIONS_INIT_END
//CUSTOM_OPTIONS_INIT_START
@ -166,177 +122,6 @@ class Component extends R3Object {
//GENERATE_CONSTRUCTOR_EXTENDS_END
//GENERATE_METHODS_START
/**
* createInstance()
* - Creates an instance of this object based on the runtime.
*/
createInstance() {
//GENERATE_CREATE_INSTANCE_METHOD_START
this.emit(Event.CREATE_INSTANCE_BEFORE, this);
this[this.runtime].createInstance(
this,
{
//GENERATE_CREATE_INSTANCE_OPTIONS_START
'x': this.x,
'y': this.y,
'z': this.z
//GENERATE_CREATE_INSTANCE_OPTIONS_END
}
)
this.emit(Event.INSTANCE_CREATED, this);
//GENERATE_CREATE_INSTANCE_METHOD_END
//CUSTOM_CREATE_INSTANCE_METHOD_START
//CUSTOM_CREATE_INSTANCE_METHOD_END
}
/**
* updateInstance()
* - Updates the instance property, ex. 'x', or specify 'all' to update all properties based on the current object
* property(ies)
* @param property
*/
updateInstance(property) {
//GENERATE_UPDATE_INSTANCE_METHOD_START
this.emit(Event.UPDATE_INSTANCE_BEFORE, this);
//GENERATE_UPDATE_INSTANCE_OPTIONS_START
if (property === 'x') {
this.instance.x = this.x;
if (property !== 'all') {
this.emit(Event.UPDATE_INSTANCE_AFTER, this);
return;
}
}
if (property === 'y') {
this.instance.y = this.y;
if (property !== 'all') {
this.emit(Event.UPDATE_INSTANCE_AFTER, this);
return;
}
}
if (property === 'z') {
this.instance.z = this.z;
if (property !== 'all') {
this.emit(Event.UPDATE_INSTANCE_AFTER, this);
return;
}
}
//GENERATE_UPDATE_INSTANCE_OPTIONS_END
this.emit(Event.UPDATE_INSTANCE_AFTER, this);
//GENERATE_UPDATE_INSTANCE_METHOD_END
//CUSTOM_UPDATE_INSTANCE_METHOD_START
//CUSTOM_UPDATE_INSTANCE_METHOD_END
}
/**
* updateFromInstance()
* - Updates the object property, ex. 'x', or specify 'all' to update all properties of this object based on the
* value of the instance property(ies)
* @param property
*/
updateFromInstance(property) {
//GENERATE_UPDATE_FROM_INSTANCE_METHOD_START
this.emit(Event.UPDATE_FROM_INSTANCE_BEFORE, this);
//GENERATE_UPDATE_FROM_INSTANCE_OPTIONS_START
if (property === 'x' || property === 'all') {
this.x = this.instance.x;
if (property !== 'all') {
this.emit(Event.UPDATE_FROM_INSTANCE_AFTER, this);
return;
}
}
if (property === 'y' || property === 'all') {
this.y = this.instance.y;
if (property !== 'all') {
this.emit(Event.UPDATE_FROM_INSTANCE_AFTER, this);
return;
}
}
if (property === 'z' || property === 'all') {
this.z = this.instance.z;
if (property !== 'all') {
this.emit(Event.UPDATE_FROM_INSTANCE_AFTER, this);
return;
}
}
//GENERATE_UPDATE_FROM_INSTANCE_OPTIONS_END
this.emit(Event.UPDATE_FROM_INSTANCE_AFTER, this);
//GENERATE_UPDATE_FROM_INSTANCE_METHOD_END
//CUSTOM_UPDATE_FROM_INSTANCE_METHOD_START
//CUSTOM_UPDATE_FROM_INSTANCE_METHOD_END
}
/**
* dispose()
* - Sends out a notification that this object wants to be deleted. It will first send out a message to delete it's
* instance, because an object instance should not exist without an object parent (except maybe for particles)
*/
dispose() {
//GENERATE_DISPOSE_METHOD_START
this.subscribe(
Event.INSTANCE_DISPOSED,
function(object) {
if (object === this) {
this.emit(Event.DISPOSE_OBJECT, this);
}
}
);
this.disposeInstance();
//GENERATE_DISPOSE_METHOD_END
//CUSTOM_DISPOSE_METHOD_START
//CUSTOM_DISPOSE_METHOD_END
}
/**
* disposeInstance()
* - This will signal all systems that an instance wants to be deleted. Once it has been deleted, another event
* will be triggered to notify listeners of the deletion of this instance. This can give 'dispose()' a chance to
* dispose the object parent this instance.
*/
disposeInstance() {
//GENERATE_DISPOSE_INSTANCE_METHOD_START
console.log('Disposing instance of ' + this.name);
this.emit(Event.DISPOSE_INSTANCE, this);
//GENERATE_DISPOSE_INSTANCE_METHOD_END
//CUSTOM_DISPOSE_INSTANCE_METHOD_START
//CUSTOM_DISPOSE_INSTANCE_METHOD_END
}
/**
* toApiObject()
* - Transforms the current object into JSON ready to be stored to the back-end. \n * @returns JSON
*/
toApiObject() {
//GENERATE_TO_API_OBJECT_METHOD_START
//GENERATE_TO_API_OBJECT_METHOD_END
//CUSTOM_TO_API_OBJECT_METHOD_START
//CUSTOM_TO_API_OBJECT_METHOD_END
}
//GENERATE_METHODS_END
//GENERATE_STATIC_METHODS_START

View File

@ -56,34 +56,11 @@ const Component = require('.././r3-component.js');
Properties:
- x (Default value 0)
- y (Default value 0)
- z (Default value 0)
<no inherited properties>
Methods:
- createInstance()
Creates an instance of this object based on the runtime.
- updateInstance(property)
Updates the instance property, ex. 'x', or specify 'all' to update all properties based on the current object
property(ies)
- updateFromInstance(property)
Updates the object property, ex. 'x', or specify 'all' to update all properties of this object based on the
value of the instance property(ies)
- dispose()
Sends out a notification that this object wants to be deleted. It will first send out a message to delete it's
instance, because an object instance should not exist without an object parent (except maybe for particles)
- disposeInstance()
This will signal all systems that an instance wants to be deleted. Once it has been deleted, another event
will be triggered to notify listeners of the deletion of this instance. This can give 'dispose()' a chance to
dispose the object parent this instance.
- toApiObject()
Transforms the current object into JSON ready to be stored to the back-end.
<no inherited methods>
Static Methods:
@ -97,28 +74,7 @@ const Component = require('.././r3-component.js');
Methods:
- createInstance()
Creates an instance of this object based on the runtime.
- updateInstance(property)
Updates the instance property, ex. 'x', or specify 'all' to update all properties based on the current object
property(ies)
- updateFromInstance(property)
Updates the object property, ex. 'x', or specify 'all' to update all properties of this object based on the
value of the instance property(ies)
- dispose()
Sends out a notification that this object wants to be deleted. It will first send out a message to delete it's
instance, because an object instance should not exist without an object parent (except maybe for particles)
- disposeInstance()
This will signal all systems that an instance wants to be deleted. Once it has been deleted, another event
will be triggered to notify listeners of the deletion of this instance. This can give 'dispose()' a chance to
dispose the object parent this instance.
- toApiObject()
Transforms the current object into JSON ready to be stored to the back-end.
<no methods>
Static Methods:
@ -141,12 +97,6 @@ const Component = require('.././r3-component.js');
CUSTOM_EXCLUDED_FROM_INSTANCE_OPTIONS_END
CUSTOM_METHODS_START
createInstance() - Creates an instance of this object based on the runtime.
updateInstance(property) - Updates the instance property, ex. 'x', or specify 'all' to update all properties based on the current object property(ies)
updateFromInstance(property) - Updates the object property, ex. 'x', or specify 'all' to update all properties of this object based on the value of the instance property(ies)
dispose() - Sends out a notification that this object wants to be deleted. It will first send out a message to delete it's instance, because an object instance should not exist without an object parent (except maybe for particles)
disposeInstance() - This will signal all systems that an instance wants to be deleted. Once it has been deleted, another event will be triggered to notify listeners of the deletion of this instance. This can give 'dispose()' a chance to dispose the object parent this instance.
toApiObject() - Transforms the current object into JSON ready to be stored to the back-end. @returns JSON
CUSTOM_METHODS_END
CUSTOM_STATIC_METHODS_START
@ -186,132 +136,6 @@ class Image extends Component {
//GENERATE_CONSTRUCTOR_EXTENDS_END
//GENERATE_METHODS_START
/**
* createInstance()
* - Creates an instance of this object based on the runtime.
*/
createInstance() {
//GENERATE_CREATE_INSTANCE_METHOD_START
this.emit(Event.CREATE_INSTANCE_BEFORE, this);
this[this.runtime].createInstance(
this,
{
//GENERATE_CREATE_INSTANCE_OPTIONS_START
//GENERATE_CREATE_INSTANCE_OPTIONS_END
}
)
this.emit(Event.INSTANCE_CREATED, this);
//GENERATE_CREATE_INSTANCE_METHOD_END
//CUSTOM_CREATE_INSTANCE_METHOD_START
//CUSTOM_CREATE_INSTANCE_METHOD_END
}
/**
* updateInstance()
* - Updates the instance property, ex. 'x', or specify 'all' to update all properties based on the current object
* property(ies)
* @param property
*/
updateInstance(property) {
//GENERATE_UPDATE_INSTANCE_METHOD_START
this.emit(Event.UPDATE_INSTANCE_BEFORE, this);
//GENERATE_UPDATE_INSTANCE_OPTIONS_START
//GENERATE_UPDATE_INSTANCE_OPTIONS_END
this.emit(Event.UPDATE_INSTANCE_AFTER, this);
//GENERATE_UPDATE_INSTANCE_METHOD_END
//CUSTOM_UPDATE_INSTANCE_METHOD_START
//CUSTOM_UPDATE_INSTANCE_METHOD_END
}
/**
* updateFromInstance()
* - Updates the object property, ex. 'x', or specify 'all' to update all properties of this object based on the
* value of the instance property(ies)
* @param property
*/
updateFromInstance(property) {
//GENERATE_UPDATE_FROM_INSTANCE_METHOD_START
this.emit(Event.UPDATE_FROM_INSTANCE_BEFORE, this);
//GENERATE_UPDATE_FROM_INSTANCE_OPTIONS_START
//GENERATE_UPDATE_FROM_INSTANCE_OPTIONS_END
this.emit(Event.UPDATE_FROM_INSTANCE_AFTER, this);
//GENERATE_UPDATE_FROM_INSTANCE_METHOD_END
//CUSTOM_UPDATE_FROM_INSTANCE_METHOD_START
//CUSTOM_UPDATE_FROM_INSTANCE_METHOD_END
}
/**
* dispose()
* - Sends out a notification that this object wants to be deleted. It will first send out a message to delete it's
* instance, because an object instance should not exist without an object parent (except maybe for particles)
*/
dispose() {
//GENERATE_DISPOSE_METHOD_START
this.subscribe(
Event.INSTANCE_DISPOSED,
function(object) {
if (object === this) {
this.emit(Event.DISPOSE_OBJECT, this);
}
}
);
this.disposeInstance();
//GENERATE_DISPOSE_METHOD_END
//CUSTOM_DISPOSE_METHOD_START
//CUSTOM_DISPOSE_METHOD_END
}
/**
* disposeInstance()
* - This will signal all systems that an instance wants to be deleted. Once it has been deleted, another event
* will be triggered to notify listeners of the deletion of this instance. This can give 'dispose()' a chance to
* dispose the object parent this instance.
*/
disposeInstance() {
//GENERATE_DISPOSE_INSTANCE_METHOD_START
console.log('Disposing instance of ' + this.name);
this.emit(Event.DISPOSE_INSTANCE, this);
//GENERATE_DISPOSE_INSTANCE_METHOD_END
//CUSTOM_DISPOSE_INSTANCE_METHOD_START
//CUSTOM_DISPOSE_INSTANCE_METHOD_END
}
/**
* toApiObject()
* - Transforms the current object into JSON ready to be stored to the back-end. \n * @returns JSON
*/
toApiObject() {
//GENERATE_TO_API_OBJECT_METHOD_START
//GENERATE_TO_API_OBJECT_METHOD_END
//CUSTOM_TO_API_OBJECT_METHOD_START
//CUSTOM_TO_API_OBJECT_METHOD_END
}
//GENERATE_METHODS_END
//GENERATE_STATIC_METHODS_START

View File

@ -237,7 +237,8 @@ class Event {
* Subscribe()
* - Subscribes to 'eventName', ex. Event.BEFORE_RENDER and executes 'callback()' when eventName is raised
* @param eventId
* @param callback \n * @returns {Object} - A handle to the subscription which can be removed by calling handle.remove()
* @param callback
* @returns {Object} - A handle to the subscription which can be removed by calling handle.remove()
*/
static Subscribe(
eventId,

View File

@ -132,15 +132,6 @@ class Project extends R3Object {
}
//CUSTOM_OUT_OF_CLASS_IMPLEMENTATION_START
Project.CAMERA_INDEX_EDIT = 0x0;
Project.CAMERA_INDEX_RUN = 0x1;
Project.APPLICATION_MODE_EDIT = Project.CAMERA_INDEX_EDIT;
Project.APPLICATION_MODE_RUN = Project.CAMERA_INDEX_RUN;
Project.RENDERER_INDEX_MAIN = 0x0;
Project.RENDER_TARGET_INDEX_NONE = -0x1;
//CUSTOM_OUT_OF_CLASS_IMPLEMENTATION_END
module.exports = Project;

View File

@ -1,6 +1,6 @@
class R3 {
static version = '2.0.25';
static compileDate = '2021 Jul 05 - 10:20:49 am';
static version = '2.0.82';
static compileDate = '2021 Jul 12 - 12:02:40 pm';
}
//GENERATE_IMPORTS_START
@ -35,7 +35,6 @@ R3.Component = Component;
//GENERATE_CONVENIENT_DEFINES_END
//CUSTOM_CONVENIENT_DEFINES_START
R3.Project = Project;
//CUSTOM_CONVENIENT_DEFINES_END
module.exports = R3;

View File

@ -10,7 +10,7 @@ const System = require('./r3-system.js');
Properties:
- started (Default value false)
<no inherited properties>
Methods:
@ -55,6 +55,11 @@ const System = require('./r3-system.js');
CUSTOM_OPTIONS_START
CUSTOM_OPTIONS_END
CUSTOM_EVENT_LISTENERS_START
Event.OBJECT_CREATED
Event.INSTANCE_CREATED
CUSTOM_EVENT_LISTENERS_END
CUSTOM_METHODS_START
start(options) - Just calls System.Start(options)
stop(options) - Just calls System.Stop(options)
@ -108,6 +113,8 @@ class SystemLinking extends System {
start(options) {
//GENERATE_START_METHOD_START
SystemLinking.Start(options);
this.started = true;
//GENERATE_START_METHOD_END
//CUSTOM_START_METHOD_START
@ -123,6 +130,8 @@ class SystemLinking extends System {
stop(options) {
//GENERATE_STOP_METHOD_START
SystemLinking.Stop(options);
this.started = false;
//GENERATE_STOP_METHOD_END
//CUSTOM_STOP_METHOD_START
@ -132,8 +141,129 @@ class SystemLinking extends System {
//GENERATE_METHODS_END
//GENERATE_STATIC_METHODS_START
/**
* Start()
* - Starts the system by registering subscriptions to events
* @param options
*/
static Start(options) {
//GENERATE_STATIC_START_METHOD_START
if ('System' !== 'SystemLinking') {
System.Start();
}
//GENERATE_EVENT_LISTENERS_START_START
SystemLinking.Subscriptions.push(
new Event.Subscribe(
Event.OBJECT_CREATED,
SystemLinking.OnObjectCreated
)
);
SystemLinking.Subscriptions.push(
new Event.Subscribe(
Event.INSTANCE_CREATED,
SystemLinking.OnInstanceCreated
)
);
//GENERATE_EVENT_LISTENERS_START_END
SystemLinking.Started = true;
console.log('Started SystemLinking');
//GENERATE_STATIC_START_METHOD_END
//CUSTOM_STATIC_START_METHOD_START
//CUSTOM_STATIC_START_METHOD_END
}
/**
* Stop()
* - Stops the system by removing these subscriptions to events
* @param options
*/
static Stop(options) {
//GENERATE_STATIC_STOP_METHOD_START
if ('System' !== 'SystemLinking') {
System.Stop(options);
}
//GENERATE_EVENT_LISTENERS_STOP_START
SystemLinking.Subscriptions = SystemLinking.Subscriptions.reduce(
(result, subscription) => {
if (subscription.remove() !== true) {
result.push(subscription);
}
return result;
},
[]
);
SystemLinking.Subscriptions = SystemLinking.Subscriptions.reduce(
(result, subscription) => {
if (subscription.remove() !== true) {
result.push(subscription);
}
return result;
},
[]
);
//GENERATE_EVENT_LISTENERS_STOP_END
SystemLinking.Started = false;
console.log('Stopped SystemLinking');
//GENERATE_STATIC_STOP_METHOD_END
//CUSTOM_STATIC_STOP_METHOD_START
//CUSTOM_STATIC_STOP_METHOD_END
}
//GENERATE_STATIC_METHODS_END
//GENERATE_STATIC_EVENT_LISTENER_METHODS_START
/**
* OnObjectCreated()
* - Listens to events of type Event.OBJECT_CREATED and executes this function.
* @param data (The event data passed as argument - typically an R3Object)
* @return null
*/
static OnObjectCreated(data) {
//GENERATE_STATIC_ON_OBJECT_CREATED_METHOD_START
//GENERATE_STATIC_ON_OBJECT_CREATED_METHOD_END
//CUSTOM_STATIC_ON_OBJECT_CREATED_METHOD_START
//CUSTOM_STATIC_ON_OBJECT_CREATED_METHOD_END
}
/**
* OnInstanceCreated()
* - Listens to events of type Event.INSTANCE_CREATED and executes this function.
* @param data (The event data passed as argument - typically an R3Object)
* @return null
*/
static OnInstanceCreated(data) {
//GENERATE_STATIC_ON_INSTANCE_CREATED_METHOD_START
//GENERATE_STATIC_ON_INSTANCE_CREATED_METHOD_END
//CUSTOM_STATIC_ON_INSTANCE_CREATED_METHOD_START
//CUSTOM_STATIC_ON_INSTANCE_CREATED_METHOD_END
}
//GENERATE_STATIC_EVENT_LISTENER_METHODS_END
//CUSTOM_IMPLEMENTATION_START
//CUSTOM_IMPLEMENTATION_END

View File

@ -10,7 +10,7 @@ const System = require('./r3-system.js');
Properties:
- started (Default value false)
<no inherited properties>
Methods:
@ -55,6 +55,9 @@ const System = require('./r3-system.js');
CUSTOM_OPTIONS_START
CUSTOM_OPTIONS_END
CUSTOM_EVENT_LISTENERS_START
CUSTOM_EVENT_LISTENERS_END
CUSTOM_METHODS_START
start(options) - Just calls System.Start(options)
stop(options) - Just calls System.Stop(options)
@ -108,6 +111,8 @@ class SystemSocket extends System {
start(options) {
//GENERATE_START_METHOD_START
SystemSocket.Start(options);
this.started = true;
//GENERATE_START_METHOD_END
//CUSTOM_START_METHOD_START
@ -123,6 +128,8 @@ class SystemSocket extends System {
stop(options) {
//GENERATE_STOP_METHOD_START
SystemSocket.Stop(options);
this.started = false;
//GENERATE_STOP_METHOD_END
//CUSTOM_STOP_METHOD_START
@ -132,8 +139,65 @@ class SystemSocket extends System {
//GENERATE_METHODS_END
//GENERATE_STATIC_METHODS_START
/**
* Start()
* - Starts the system by registering subscriptions to events
* @param options
*/
static Start(options) {
//GENERATE_STATIC_START_METHOD_START
if ('System' !== 'SystemSocket') {
System.Start();
}
//GENERATE_EVENT_LISTENERS_START_START
//GENERATE_EVENT_LISTENERS_START_END
SystemSocket.Started = true;
console.log('Started SystemSocket');
//GENERATE_STATIC_START_METHOD_END
//CUSTOM_STATIC_START_METHOD_START
//CUSTOM_STATIC_START_METHOD_END
}
/**
* Stop()
* - Stops the system by removing these subscriptions to events
* @param options
*/
static Stop(options) {
//GENERATE_STATIC_STOP_METHOD_START
if ('System' !== 'SystemSocket') {
System.Stop(options);
}
//GENERATE_EVENT_LISTENERS_STOP_START
//GENERATE_EVENT_LISTENERS_STOP_END
SystemSocket.Started = false;
console.log('Stopped SystemSocket');
//GENERATE_STATIC_STOP_METHOD_END
//CUSTOM_STATIC_STOP_METHOD_START
//CUSTOM_STATIC_STOP_METHOD_END
}
//GENERATE_STATIC_METHODS_END
//GENERATE_STATIC_EVENT_LISTENER_METHODS_START
//GENERATE_STATIC_EVENT_LISTENER_METHODS_END
//CUSTOM_IMPLEMENTATION_START
//CUSTOM_IMPLEMENTATION_END

View File

@ -10,7 +10,7 @@ const System = require('./r3-system.js');
Properties:
- started (Default value false)
<no inherited properties>
Methods:
@ -55,6 +55,9 @@ const System = require('./r3-system.js');
CUSTOM_OPTIONS_START
CUSTOM_OPTIONS_END
CUSTOM_EVENT_LISTENERS_START
CUSTOM_EVENT_LISTENERS_END
CUSTOM_METHODS_START
start(options) - Just calls System.Start(options)
stop(options) - Just calls System.Stop(options)
@ -108,6 +111,8 @@ class SystemTest extends System {
start(options) {
//GENERATE_START_METHOD_START
SystemTest.Start(options);
this.started = true;
//GENERATE_START_METHOD_END
//CUSTOM_START_METHOD_START
@ -123,6 +128,8 @@ class SystemTest extends System {
stop(options) {
//GENERATE_STOP_METHOD_START
SystemTest.Stop(options);
this.started = false;
//GENERATE_STOP_METHOD_END
//CUSTOM_STOP_METHOD_START
@ -132,8 +139,65 @@ class SystemTest extends System {
//GENERATE_METHODS_END
//GENERATE_STATIC_METHODS_START
/**
* Start()
* - Starts the system by registering subscriptions to events
* @param options
*/
static Start(options) {
//GENERATE_STATIC_START_METHOD_START
if ('System' !== 'SystemTest') {
System.Start();
}
//GENERATE_EVENT_LISTENERS_START_START
//GENERATE_EVENT_LISTENERS_START_END
SystemTest.Started = true;
console.log('Started SystemTest');
//GENERATE_STATIC_START_METHOD_END
//CUSTOM_STATIC_START_METHOD_START
//CUSTOM_STATIC_START_METHOD_END
}
/**
* Stop()
* - Stops the system by removing these subscriptions to events
* @param options
*/
static Stop(options) {
//GENERATE_STATIC_STOP_METHOD_START
if ('System' !== 'SystemTest') {
System.Stop(options);
}
//GENERATE_EVENT_LISTENERS_STOP_START
//GENERATE_EVENT_LISTENERS_STOP_END
SystemTest.Started = false;
console.log('Stopped SystemTest');
//GENERATE_STATIC_STOP_METHOD_END
//CUSTOM_STATIC_STOP_METHOD_START
//CUSTOM_STATIC_STOP_METHOD_END
}
//GENERATE_STATIC_METHODS_END
//GENERATE_STATIC_EVENT_LISTENER_METHODS_START
//GENERATE_STATIC_EVENT_LISTENER_METHODS_END
//CUSTOM_IMPLEMENTATION_START
//CUSTOM_IMPLEMENTATION_END

View File

@ -4,7 +4,6 @@ const Utils = require('.././r3-utils');
/**
CUSTOM_OPTIONS_START
started=false
CUSTOM_OPTIONS_END
CUSTOM_METHODS_START
@ -13,8 +12,8 @@ const Utils = require('.././r3-utils');
CUSTOM_METHODS_END
CUSTOM_STATIC_METHODS_START
Start(options) - Starts the system by registering subscriptions to events
Stop(options) - Stops the system by removing these subscriptions to events
Start(options) - Starts the system by registering subscriptions to events
Stop(options) - Stops the system by removing these subscriptions to events
CUSTOM_STATIC_METHODS_END
**/
@ -27,12 +26,6 @@ class System {
Event.Emit(Event.OBJECT_CREATED, this);
//GENERATE_OPTIONS_INIT_START
if (typeof options === 'undefined') {
options = {};
}
if (Utils.UndefinedOrNull(options.started)) {
options.started = false;
}
//GENERATE_OPTIONS_INIT_END
//CUSTOM_OPTIONS_INIT_START
@ -63,16 +56,11 @@ class System {
start(options) {
//GENERATE_START_METHOD_START
System.Start(options);
this.started = true;
//GENERATE_START_METHOD_END
//CUSTOM_START_METHOD_START
System.Start(options);
/**
* Now do something else
*/
console.log('something else');
//CUSTOM_START_METHOD_END
}
@ -85,10 +73,11 @@ class System {
stop(options) {
//GENERATE_STOP_METHOD_START
System.Stop(options);
this.started = false;
//GENERATE_STOP_METHOD_END
//CUSTOM_STOP_METHOD_START
System.Stop(options);
//CUSTOM_STOP_METHOD_END
}
@ -104,10 +93,21 @@ class System {
static Start(options) {
//GENERATE_STATIC_START_METHOD_START
if ('System' !== 'System') {
System.Start();
}
//GENERATE_EVENT_LISTENERS_START_START
//GENERATE_EVENT_LISTENERS_START_END
System.Started = true;
console.log('Started System');
//GENERATE_STATIC_START_METHOD_END
//CUSTOM_STATIC_START_METHOD_START
console.log('Starting system X');
//CUSTOM_STATIC_START_METHOD_END
}
@ -120,10 +120,21 @@ class System {
static Stop(options) {
//GENERATE_STATIC_STOP_METHOD_START
if ('System' !== 'System') {
System.Stop(options);
}
//GENERATE_EVENT_LISTENERS_STOP_START
//GENERATE_EVENT_LISTENERS_STOP_END
System.Started = false;
console.log('Stopped System');
//GENERATE_STATIC_STOP_METHOD_END
//CUSTOM_STATIC_STOP_METHOD_START
console.log('Stopping system X');
//CUSTOM_STATIC_STOP_METHOD_END
}
@ -132,6 +143,7 @@ class System {
}
//CUSTOM_OUT_OF_CLASS_IMPLEMENTATION_START
System.Started = false;
//CUSTOM_OUT_OF_CLASS_IMPLEMENTATION_END
module.exports = System;

View File

@ -0,0 +1,6 @@
SYSTEM_NAME.Subscriptions.push(
new Event.Subscribe(
EVENT_NAME,
SYSTEM_NAME.CALL_BACK
)
);

View File

@ -0,0 +1,10 @@
SYSTEM_NAME.Subscriptions = SYSTEM_NAME.Subscriptions.reduce(
(result, subscription) => {
if (subscription.remove() !== true) {
result.push(subscription);
}
return result;
},
[]
);

View File

@ -0,0 +1,2 @@
CLASS_NAME.Start(options);
this.started = true;

View File

@ -0,0 +1,11 @@
if ('PARENT_SYSTEM' !== 'CLASS_NAME') {
PARENT_SYSTEM.Start();
}
//GENERATE_EVENT_LISTENERS_START_START
//GENERATE_EVENT_LISTENERS_START_END
CLASS_NAME.Started = true;
console.log('Started CLASS_NAME');

View File

@ -0,0 +1,11 @@
if ('PARENT_SYSTEM' !== 'CLASS_NAME') {
PARENT_SYSTEM.Stop(options);
}
//GENERATE_EVENT_LISTENERS_STOP_START
//GENERATE_EVENT_LISTENERS_STOP_END
CLASS_NAME.Started = false;
console.log('Stopped CLASS_NAME');

View File

@ -0,0 +1,2 @@
CLASS_NAME.Stop(options);
this.started = false;

View File

@ -35,6 +35,7 @@ class CLASS_NAME {
}
//CUSTOM_OUT_OF_CLASS_IMPLEMENTATION_START
CLASS_NAME.Started = false;
//CUSTOM_OUT_OF_CLASS_IMPLEMENTATION_END
module.exports = CLASS_NAME;

View File

@ -11,6 +11,9 @@ const EXTEND_CLASS = require('./EXTEND_CLASS_FILE_NAME');
CUSTOM_OPTIONS_START
CUSTOM_OPTIONS_END
CUSTOM_EVENT_LISTENERS_START
CUSTOM_EVENT_LISTENERS_END
CUSTOM_METHODS_START
start(options) - Just calls System.Start(options)
stop(options) - Just calls System.Stop(options)
@ -34,6 +37,9 @@ class CLASS_NAME extends EXTEND_CLASS {
//GENERATE_STATIC_METHODS_START
//GENERATE_STATIC_METHODS_END
//GENERATE_STATIC_EVENT_LISTENER_METHODS_START
//GENERATE_STATIC_EVENT_LISTENER_METHODS_END
//CUSTOM_IMPLEMENTATION_START
//CUSTOM_IMPLEMENTATION_END

View File

@ -2,13 +2,12 @@ GENERATE_ASYNC_METHOD
GENERATE_CONSTRUCTOR
GENERATE_CONSTRUCTOR_EXTENDS
GENERATE_CONVENIENT_DEFINES
GENERATE_CREATE_INSTANCE_METHOD
GENERATE_CREATE_INSTANCE_OPTIONS
GENERATE_DEFINES
GENERATE_DISPOSE_INSTANCE_METHOD
GENERATE_DISPOSE_METHOD
GENERATE_EMIT_METHOD
GENERATE_EVENT
GENERATE_EVENT_LISTENERS_START
GENERATE_EVENT_LISTENERS_STOP
GENERATE_EXPORTS
GENERATE_IMPORTS
GENERATE_INDEX_BODY
@ -19,26 +18,24 @@ GENERATE_OPTIONS_INIT
GENERATE_START_METHOD
GENERATE_STATIC_ASYNC_METHOD
GENERATE_STATIC_EMIT_METHOD
GENERATE_STATIC_EVENT_LISTENER_METHODS
GENERATE_STATIC_METHOD_NAME_UPPERCASE_METHOD
GENERATE_STATIC_METHODS
GENERATE_STATIC_ON_INSTANCE_CREATED_METHOD
GENERATE_STATIC_ON_OBJECT_CREATED_METHOD
GENERATE_STATIC_START_METHOD
GENERATE_STATIC_STOP_METHOD
GENERATE_STATIC_SUBSCRIBE_METHOD
GENERATE_STOP_METHOD
GENERATE_SUBSCRIBE_METHOD
GENERATE_TO_API_OBJECT_METHOD
GENERATE_UPDATE_FROM_INSTANCE_METHOD
GENERATE_UPDATE_FROM_INSTANCE_OPTIONS
GENERATE_UPDATE_INSTANCE_METHOD
GENERATE_UPDATE_INSTANCE_OPTIONS
CUSTOM_AFTER_INIT
CUSTOM_ASYNC_METHOD
CUSTOM_BEFORE_INIT
CUSTOM_CONVENIENT_DEFINES
CUSTOM_CREATE_INSTANCE_METHOD
CUSTOM_DISPOSE_INSTANCE_METHOD
CUSTOM_DISPOSE_METHOD
CUSTOM_EMIT_METHOD
CUSTOM_EVENT_LISTENERS
CUSTOM_EXCLUDED_FROM_INSTANCE_OPTIONS
CUSTOM_IMPLEMENTATION
CUSTOM_INSTANCE_OPTIONS_MAPPING
@ -53,11 +50,10 @@ CUSTOM_STATIC_ASYNC_METHOD
CUSTOM_STATIC_EMIT_METHOD
CUSTOM_STATIC_METHOD_NAME_UPPERCASE_METHOD
CUSTOM_STATIC_METHODS
CUSTOM_STATIC_ON_INSTANCE_CREATED_METHOD
CUSTOM_STATIC_ON_OBJECT_CREATED_METHOD
CUSTOM_STATIC_START_METHOD
CUSTOM_STATIC_STOP_METHOD
CUSTOM_STATIC_SUBSCRIBE_METHOD
CUSTOM_STOP_METHOD
CUSTOM_SUBSCRIBE_METHOD
CUSTOM_TO_API_OBJECT_METHOD
CUSTOM_UPDATE_FROM_INSTANCE_METHOD
CUSTOM_UPDATE_INSTANCE_METHOD

View File

@ -1 +1 @@
2.0.25
2.0.82