// Type definitions for Samchon Framework v2.0.0-beta.8 // Project: https://github.com/samchon/framework // Definitions by: Jeongho Nam // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// declare module "samchon-framework" { export = samchon; } /** *

Samchon-Framework

* *

*

* *

Samchon, a SDN (Software Defined Network) framework.

* *

With Samchon Framework, you can implement distributed processing system within framework of OOD like * handling S/W objects (classes). You can realize cloud and distributed system very easily with provided * system templates and even integration with C++ is possible.

* *

The goal, ultimate utilization model of Samchon Framework is, building cloud system with NodeJS and * takING heavy works to C++ distributed systems with provided modules (those are system templates).

* * @git https://github.com/samchon/framework * @author Jeongho Nam */ declare namespace samchon { /** *

Running on Node.

* *

Test whether the JavaScript is running on Node.

* * @references http://stackoverflow.com/questions/17575790/environment-detection-node-js-or-browser */ function is_node(): boolean; } declare namespace samchon.collection { /** * A {@link Vector} who can detect element I/O events. * *
    *
  • insert typed events:
      *
    • {@link assign}
    • *
    • {@link insert}
    • *
    • {@link push}
    • *
    • {@link push_back}
    • *
    • {@link unshift}
    • *
  • *
  • erase typed events:
      *
    • {@link assign}
    • *
    • {@link clear}
    • *
    • {@link erase}
    • *
    • {@link pop_back}
    • *
    • {@link shift}
    • *
    • {@link pop}
    • *
    • {@link splice}
    • *
  • *
  • erase typed events:
      *
    • {@link sort}
    • *
  • *
* * @author Jeongho Nam */ class ArrayCollection extends std.Vector implements ICollection { /** * A chain object taking responsibility of dispatching events. */ private event_dispatcher_; /** * @inheritdoc */ push(...items: U[]): number; /** * @inheritdoc */ push_back(val: T): void; /** * @hidden */ protected _Insert_by_repeating_val(position: std.VectorIterator, n: number, val: T): std.VectorIterator; /** * @hidden */ protected _Insert_by_range>(position: std.VectorIterator, begin: InputIterator, end: InputIterator): std.VectorIterator; /** * @hidden */ protected _Erase_by_range(first: std.VectorIterator, last: std.VectorIterator): std.VectorIterator; /** * @hidden */ private notify_insert(first, last); /** * @hidden */ private notify_erase(first, last); /** * @inheritdoc */ hasEventListener(type: string): boolean; /** * @inheritdoc */ dispatchEvent(event: library.BasicEvent): boolean; /** * @inheritdoc */ refresh(): void; /** * @inheritdoc */ refresh(it: std.VectorIterator): void; /** * @inheritdoc */ refresh(first: std.VectorIterator, last: std.VectorIterator): void; /** * @inheritdoc */ addEventListener(type: string, listener: library.BasicEventListener): void; addEventListener(type: "insert", listener: CollectionEventListener): void; addEventListener(type: "erase", listener: CollectionEventListener): void; addEventListener(type: "refresh", listener: CollectionEventListener): void; /** * @inheritdoc */ addEventListener(type: string, listener: library.BasicEventListener, thisArg: Object): void; addEventListener(type: "insert", listener: CollectionEventListener, thisArg: Object): void; addEventListener(type: "erase", listener: CollectionEventListener, thisArg: Object): void; addEventListener(type: "refresh", listener: CollectionEventListener, thisArg: Object): void; /** * @inheritdoc */ removeEventListener(type: string, listener: library.BasicEventListener): void; removeEventListener(type: "insert", listener: CollectionEventListener): void; removeEventListener(type: "erase", listener: CollectionEventListener): void; removeEventListener(type: "refresh", listener: CollectionEventListener): void; /** * @inheritdoc */ removeEventListener(type: string, listener: library.BasicEventListener, thisArg: Object): void; removeEventListener(type: "insert", listener: CollectionEventListener, thisArg: Object): void; removeEventListener(type: "erase", listener: CollectionEventListener, thisArg: Object): void; removeEventListener(type: "refresh", listener: CollectionEventListener, thisArg: Object): void; /** * @inheritdoc */ unshift(...items: U[]): number; /** * @inheritdoc */ pop(): T; /** * @inheritdoc */ splice(start: number): T[]; /** * @inheritdoc */ splice(start: number, deleteCount: number, ...items: T[]): T[]; } } declare namespace samchon.library { /** * A basic event class of Samchon Framework. * * @reference https://developer.mozilla.org/en-US/docs/Web/API/Event * @author Jeongho Nam */ class BasicEvent { protected type_: string; protected target_: IEventDispatcher; private currentTarget_; protected trusted_: boolean; protected bubbles_: boolean; protected cancelable_: boolean; protected defaultPrevented_: boolean; protected cancelBubble_: boolean; private timeStamp_; constructor(type: string, bubbles?: boolean, cancelable?: boolean); /** * @inheritdoc */ initEvent(type: string, bubbles: boolean, cancelable: boolean): void; /** * @inheritdoc */ /** * @inheritdoc */ stopImmediatePropagation(): void; /** * @inheritdoc */ stopPropagation(): void; /** * @inheritdoc */ type: string; /** * @inheritdoc */ target: IEventDispatcher; /** * @inheritdoc */ currentTarget: IEventDispatcher; /** * @inheritdoc */ isTrusted: boolean; /** * @inheritdoc */ bubbles: boolean; /** * @inheritdoc */ cancelable: boolean; /** * @inheritdoc */ eventPhase: number; /** * @inheritdoc */ defaultPrevented: boolean; /** * @inheritdoc */ srcElement: Element; /** * @inheritdoc */ cancelBubble: boolean; /** * @inheritdoc */ timeStamp: number; /** * Don't know what it is. */ returnValue: boolean; } } declare namespace samchon.collection { /** * Type of function pointer for listener of {@link CollectionEvent CollectionEvents}. */ type CollectionEventListener = (event: CollectionEvent) => void; } declare namespace samchon.collection { /** * @author Jeongho Nam */ class CollectionEvent extends library.BasicEvent { /** * @hidden */ protected first_: std.Iterator; /** * @hidden */ protected last_: std.Iterator; private temporary_container_; private origin_first_; /** * Initialization Constructor. * * @param type Type of collection event. * @param first * @param last */ constructor(type: string, first: std.Iterator, last: std.Iterator); constructor(type: "insert", first: std.Iterator, last: std.Iterator); constructor(type: "erase", first: std.Iterator, last: std.Iterator); constructor(type: "refresh", first: std.Iterator, last: std.Iterator); /** * Get associative target, the container. */ target: ICollection; /** * Get range of the first. */ first: std.Iterator; /** * Get range of the last. */ last: std.Iterator; /** * @inheritdoc */ preventDefault(): void; } } /** * @hidden */ declare namespace samchon.collection.CollectionEvent { const INSERT: "insert"; const ERASE: "erase"; const REFRESH: "refresh"; } declare namespace samchon.collection { /** * A {@link Deque} who can detect element I/O events. * *

Below are list of methods who are dispatching {@link CollectionEvent}:

* *
    *
  • insert typed events:
      *
    • {@link assign}
    • *
    • {@link insert}
    • *
    • {@link push}
    • *
    • {@link push_front}
    • *
    • {@link push_back}
    • *
  • *
  • erase typed events:
      *
    • {@link assign}
    • *
    • {@link clear}
    • *
    • {@link erase}
    • *
    • {@link pop_front}
    • *
    • {@link pop_back}
    • *
  • *
* * @author Jeongho Nam */ class DequeCollection extends std.Deque implements ICollection { /** * A chain object taking responsibility of dispatching events. */ private event_dispatcher_; /** * @inheritdoc */ push(...items: U[]): number; /** * @inheritdoc */ push_back(val: T): void; /** * @hidden */ protected _Insert_by_repeating_val(position: std.DequeIterator, n: number, val: T): std.DequeIterator; /** * @hidden */ protected _Insert_by_range>(position: std.DequeIterator, begin: InputIterator, end: InputIterator): std.DequeIterator; /** * @inheritdoc */ pop_back(): void; /** * @hidden */ protected _Erase_by_range(first: std.DequeIterator, last: std.DequeIterator): std.DequeIterator; /** * @hidden */ private notify_insert(first, last); /** * @hidden */ private notify_erase(first, last); /** * @inheritdoc */ hasEventListener(type: string): boolean; /** * @inheritdoc */ dispatchEvent(event: library.BasicEvent): boolean; /** * @inheritdoc */ refresh(): void; /** * @inheritdoc */ refresh(it: std.DequeIterator): void; /** * @inheritdoc */ refresh(first: std.DequeIterator, last: std.DequeIterator): void; /** * @inheritdoc */ addEventListener(type: string, listener: library.BasicEventListener): void; addEventListener(type: "insert", listener: CollectionEventListener): void; addEventListener(type: "erase", listener: CollectionEventListener): void; addEventListener(type: "refresh", listener: CollectionEventListener): void; /** * @inheritdoc */ addEventListener(type: string, listener: library.BasicEventListener, thisArg: Object): void; addEventListener(type: "insert", listener: CollectionEventListener, thisArg: Object): void; addEventListener(type: "erase", listener: CollectionEventListener, thisArg: Object): void; addEventListener(type: "refresh", listener: CollectionEventListener, thisArg: Object): void; /** * @inheritdoc */ removeEventListener(type: string, listener: library.BasicEventListener): void; removeEventListener(type: "insert", listener: CollectionEventListener): void; removeEventListener(type: "erase", listener: CollectionEventListener): void; removeEventListener(type: "refresh", listener: CollectionEventListener): void; /** * @inheritdoc */ removeEventListener(type: string, listener: library.BasicEventListener, thisArg: Object): void; removeEventListener(type: "insert", listener: CollectionEventListener, thisArg: Object): void; removeEventListener(type: "erase", listener: CollectionEventListener, thisArg: Object): void; removeEventListener(type: "refresh", listener: CollectionEventListener, thisArg: Object): void; } } declare namespace samchon.collection { /** * A {@link HashMap} who can detect element I/O events. * *
    *
  • insert typed events:
      *
    • {@link assign}
    • *
    • {@link insert}
    • *
    • {@link push}
    • *
    • {@link set}
    • *
    • {@link insert_or_assign}
    • *
  • *
  • erase typed events:
      *
    • {@link assign}
    • *
    • {@link clear}
    • *
    • {@link erase}
    • *
    • {@link extract}
    • *
  • *
  • refresh typed events:
      *
    • {@link set}
    • *
    • {@link insert_or_assign}
    • *
  • *
* * @author Jeongho Nam */ class HashMapCollection extends std.HashMap implements ICollection> { /** * A chain object taking responsibility of dispatching events. */ private event_dispatcher_; /** * @inheritdoc */ protected _Handle_insert(first: std.MapIterator, last: std.MapIterator): void; /** * @inheritdoc */ protected _Handle_erase(first: std.MapIterator, last: std.MapIterator): void; /** * @inheritdoc */ hasEventListener(type: string): boolean; /** * @inheritdoc */ dispatchEvent(event: library.BasicEvent): boolean; /** * @inheritdoc */ refresh(): void; /** * @inheritdoc */ refresh(it: std.MapIterator): void; /** * @inheritdoc */ refresh(first: std.MapIterator, last: std.MapIterator): void; /** * @inheritdoc */ addEventListener(type: string, listener: library.BasicEventListener): void; addEventListener(type: "insert", listener: MapCollectionEventListener): void; addEventListener(type: "erase", listener: MapCollectionEventListener): void; addEventListener(type: "refresh", listener: MapCollectionEventListener): void; /** * @inheritdoc */ addEventListener(type: string, listener: library.BasicEventListener, thisArg: Object): void; addEventListener(type: "insert", listener: MapCollectionEventListener, thisArg: Object): void; addEventListener(type: "erase", listener: MapCollectionEventListener, thisArg: Object): void; addEventListener(type: "refresh", listener: MapCollectionEventListener, thisArg: Object): void; /** * @inheritdoc */ removeEventListener(type: string, listener: library.BasicEventListener): void; removeEventListener(type: "insert", listener: MapCollectionEventListener): void; removeEventListener(type: "erase", listener: MapCollectionEventListener): void; removeEventListener(type: "refresh", listener: MapCollectionEventListener): void; /** * @inheritdoc */ removeEventListener(type: string, listener: library.BasicEventListener, thisArg: Object): void; removeEventListener(type: "insert", listener: MapCollectionEventListener, thisArg: Object): void; removeEventListener(type: "erase", listener: MapCollectionEventListener, thisArg: Object): void; removeEventListener(type: "refresh", listener: MapCollectionEventListener, thisArg: Object): void; } } declare namespace samchon.collection { /** * A {@link HashMultiMap} who can detect element I/O events. * *
    *
  • insert typed events:
      *
    • {@link assign}
    • *
    • {@link insert}
    • *
    • {@link push}
    • *
  • *
  • erase typed events:
      *
    • {@link assign}
    • *
    • {@link clear}
    • *
    • {@link erase}
    • *
  • *
* * @author Jeongho Nam */ class HashMultiMapCollection extends std.HashMap implements ICollection> { /** * A chain object taking responsibility of dispatching events. */ private event_dispatcher_; /** * @inheritdoc */ protected _Handle_insert(first: std.MapIterator, last: std.MapIterator): void; /** * @inheritdoc */ protected _Handle_erase(first: std.MapIterator, last: std.MapIterator): void; /** * @inheritdoc */ hasEventListener(type: string): boolean; /** * @inheritdoc */ dispatchEvent(event: library.BasicEvent): boolean; /** * @inheritdoc */ refresh(): void; /** * @inheritdoc */ refresh(it: std.MapIterator): void; /** * @inheritdoc */ refresh(first: std.MapIterator, last: std.MapIterator): void; /** * @inheritdoc */ addEventListener(type: string, listener: library.BasicEventListener): void; addEventListener(type: "insert", listener: MapCollectionEventListener): void; addEventListener(type: "erase", listener: MapCollectionEventListener): void; addEventListener(type: "refresh", listener: MapCollectionEventListener): void; /** * @inheritdoc */ addEventListener(type: string, listener: library.BasicEventListener, thisArg: Object): void; addEventListener(type: "insert", listener: MapCollectionEventListener, thisArg: Object): void; addEventListener(type: "erase", listener: MapCollectionEventListener, thisArg: Object): void; addEventListener(type: "refresh", listener: MapCollectionEventListener, thisArg: Object): void; /** * @inheritdoc */ removeEventListener(type: string, listener: library.BasicEventListener): void; removeEventListener(type: "insert", listener: MapCollectionEventListener): void; removeEventListener(type: "erase", listener: MapCollectionEventListener): void; removeEventListener(type: "refresh", listener: MapCollectionEventListener): void; /** * @inheritdoc */ removeEventListener(type: string, listener: library.BasicEventListener, thisArg: Object): void; removeEventListener(type: "insert", listener: MapCollectionEventListener, thisArg: Object): void; removeEventListener(type: "erase", listener: MapCollectionEventListener, thisArg: Object): void; removeEventListener(type: "refresh", listener: MapCollectionEventListener, thisArg: Object): void; } } declare namespace samchon.collection { /** * A {@link HashMultiSet} who can detect element I/O events. * *
    *
  • insert typed events:
      *
    • {@link assign}
    • *
    • {@link insert}
    • *
    • {@link push}
    • *
  • *
  • erase typed events:
      *
    • {@link assign}
    • *
    • {@link clear}
    • *
    • {@link erase}
    • *
  • *
* * @author Jeongho Nam */ class HashMultiSetCollection extends std.HashMultiSet implements ICollection { /** * A chain object taking responsibility of dispatching events. */ private event_dispatcher_; /** * @inheritdoc */ protected _Handle_insert(first: std.SetIterator, last: std.SetIterator): void; /** * @inheritdoc */ protected _Handle_erase(first: std.SetIterator, last: std.SetIterator): void; /** * @inheritdoc */ hasEventListener(type: string): boolean; /** * @inheritdoc */ dispatchEvent(event: library.BasicEvent): boolean; /** * @inheritdoc */ refresh(): void; /** * @inheritdoc */ refresh(it: std.SetIterator): void; /** * @inheritdoc */ refresh(first: std.SetIterator, last: std.SetIterator): void; /** * @inheritdoc */ addEventListener(type: string, listener: library.BasicEventListener): void; addEventListener(type: "insert", listener: CollectionEventListener): void; addEventListener(type: "erase", listener: CollectionEventListener): void; addEventListener(type: "refresh", listener: CollectionEventListener): void; /** * @inheritdoc */ addEventListener(type: string, listener: library.BasicEventListener, thisArg: Object): void; addEventListener(type: "insert", listener: CollectionEventListener, thisArg: Object): void; addEventListener(type: "erase", listener: CollectionEventListener, thisArg: Object): void; addEventListener(type: "refresh", listener: CollectionEventListener, thisArg: Object): void; /** * @inheritdoc */ removeEventListener(type: string, listener: library.BasicEventListener): void; removeEventListener(type: "insert", listener: CollectionEventListener): void; removeEventListener(type: "erase", listener: CollectionEventListener): void; removeEventListener(type: "refresh", listener: CollectionEventListener): void; /** * @inheritdoc */ removeEventListener(type: string, listener: library.BasicEventListener, thisArg: Object): void; removeEventListener(type: "insert", listener: CollectionEventListener, thisArg: Object): void; removeEventListener(type: "erase", listener: CollectionEventListener, thisArg: Object): void; removeEventListener(type: "refresh", listener: CollectionEventListener, thisArg: Object): void; } } declare namespace samchon.collection { /** * A {@link HashSet} who can detect element I/O events. * *
    *
  • insert typed events:
      *
    • {@link assign}
    • *
    • {@link insert}
    • *
    • {@link push}
    • *
  • *
  • erase typed events:
      *
    • {@link assign}
    • *
    • {@link clear}
    • *
    • {@link erase}
    • *
    • {@link extract}
    • *
  • *
* * @author Jeongho Nam */ class HashSetCollection extends std.HashSet implements ICollection { /** * A chain object taking responsibility of dispatching events. */ private event_dispatcher_; /** * @inheritdoc */ protected _Handle_insert(first: std.SetIterator, last: std.SetIterator): void; /** * @inheritdoc */ protected _Handle_erase(first: std.SetIterator, last: std.SetIterator): void; /** * @inheritdoc */ hasEventListener(type: string): boolean; /** * @inheritdoc */ dispatchEvent(event: library.BasicEvent): boolean; /** * @inheritdoc */ refresh(): void; /** * @inheritdoc */ refresh(it: std.SetIterator): void; /** * @inheritdoc */ refresh(first: std.SetIterator, last: std.SetIterator): void; /** * @inheritdoc */ addEventListener(type: string, listener: library.BasicEventListener): void; addEventListener(type: "insert", listener: CollectionEventListener): void; addEventListener(type: "erase", listener: CollectionEventListener): void; addEventListener(type: "refresh", listener: CollectionEventListener): void; /** * @inheritdoc */ addEventListener(type: string, listener: library.BasicEventListener, thisArg: Object): void; addEventListener(type: "insert", listener: CollectionEventListener, thisArg: Object): void; addEventListener(type: "erase", listener: CollectionEventListener, thisArg: Object): void; addEventListener(type: "refresh", listener: CollectionEventListener, thisArg: Object): void; /** * @inheritdoc */ removeEventListener(type: string, listener: library.BasicEventListener): void; removeEventListener(type: "insert", listener: CollectionEventListener): void; removeEventListener(type: "erase", listener: CollectionEventListener): void; removeEventListener(type: "refresh", listener: CollectionEventListener): void; /** * @inheritdoc */ removeEventListener(type: string, listener: library.BasicEventListener, thisArg: Object): void; removeEventListener(type: "insert", listener: CollectionEventListener, thisArg: Object): void; removeEventListener(type: "erase", listener: CollectionEventListener, thisArg: Object): void; removeEventListener(type: "refresh", listener: CollectionEventListener, thisArg: Object): void; } } declare namespace samchon.collection { /** * An interface for {@link IContainer containers} who can detect element I/O events. * *

Below are list of methods who are dispatching {@link CollectionEvent}:

* *
    *
  • insert typed events:
      *
    • {@link assign}
    • *
    • {@link insert}
    • *
    • {@link push}
    • *
  • *
  • erase typed events:
      *
    • {@link assign}
    • *
    • {@link clear}
    • *
    • {@link erase}
    • *
  • * * @author Jeongho Nam */ interface ICollection extends std.base.IContainer, library.IEventDispatcher { /** *

    Dispatch a {@link CollectionEvent} with refresh typed.

    * *

    {@link ICollection} dispatches {@link CollectionEvent} typed insert or erase whenever * elements I/O has occured. However, unlike those elements I/O events, content change in element level can't be * detected. There's no way to detect those events automatically by {@link IContainer}.

    * *

    If you want to dispatch those typed events (notifying change on contents in element level), you've to * dispatch refresh typed event manually, by yourself. Call {@link refresh refresh()} with specified * iterators who're pointing the elements whose content have changed. Then a {@link CollectionEvent} with * refresh typed will be dispatched.

    * *

    If you don't specify any iterator, then the range of the refresh event will be all elements in this * {@link ICollection collection}; {@link begin begin()} to {@link end end()}.

    */ refresh(): void; /** *

    Dispatch a {@link CollectionEvent} with refresh typed.

    * *

    {@link ICollection} dispatches {@link CollectionEvent} typed insert or erase whenever * elements I/O has occured. However, unlike those elements I/O events, content change in element level can't be * detected. There's no way to detect those events automatically by {@link IContainer}.

    * *

    If you want to dispatch those typed events (notifying change on contents in element level), you've to * dispatch refresh typed event manually, by yourself. Call {@link refresh refresh()} with specified * iterators who're pointing the elements whose content have changed. Then a {@link CollectionEvent} with * refresh typed will be dispatched.

    * * @param it An iterator targeting the content changed element. */ refresh(it: std.Iterator): void; /** *

    Dispatch a {@link CollectionEvent} with refresh typed.

    * *

    {@link ICollection} dispatches {@link CollectionEvent} typed insert or erase whenever * elements I/O has occured. However, unlike those elements I/O events, content change in element level can't be * detected. There's no way to detect those events automatically by {@link IContainer}.

    * *

    If you want to dispatch those typed events (notifying change on contents in element level), you've to * dispatch refresh typed event manually, by yourself. Call {@link refresh refresh()} with specified * iterators who're pointing the elements whose content have changed. Then a {@link CollectionEvent} with * refresh typed will be dispatched.

    * * @param first An Iterator to the initial position in a sequence of the content changed elmeents. * @param last An {@link Iterator} to the final position in a sequence of the content changed elements. The range * used is [first, last), which contains all the elements between first and * last, including the element pointed by first but not the element pointed by * last. */ refresh(first: std.Iterator, last: std.Iterator): void; /** * @inheritdoc */ addEventListener(type: string, listener: library.BasicEventListener): void; addEventListener(type: "insert", listener: CollectionEventListener): void; addEventListener(type: "erase", listener: CollectionEventListener): void; addEventListener(type: "refresh", listener: CollectionEventListener): void; /** * @inheritdoc */ addEventListener(type: string, listener: library.BasicEventListener, thisArg: Object): void; addEventListener(type: "insert", listener: CollectionEventListener, thisArg: Object): void; addEventListener(type: "erase", listener: CollectionEventListener, thisArg: Object): void; addEventListener(type: "refresh", listener: CollectionEventListener, thisArg: Object): void; /** * @inheritdoc */ removeEventListener(type: string, listener: library.BasicEventListener): void; removeEventListener(type: "insert", listener: CollectionEventListener): void; removeEventListener(type: "erase", listener: CollectionEventListener): void; removeEventListener(type: "refresh", listener: CollectionEventListener): void; /** * @inheritdoc */ removeEventListener(type: string, listener: library.BasicEventListener, thisArg: Object): void; removeEventListener(type: "insert", listener: CollectionEventListener, thisArg: Object): void; removeEventListener(type: "erase", listener: CollectionEventListener, thisArg: Object): void; removeEventListener(type: "refresh", listener: CollectionEventListener, thisArg: Object): void; } /** * @hidden */ namespace ICollection { function _Dispatch_CollectionEvent(collection: ICollection, type: string, first: std.Iterator, last: std.Iterator): void; function _Dispatch_MapCollectionEvent(collection: ICollection>, type: string, first: std.MapIterator, last: std.MapIterator): void; } } declare namespace samchon.collection { /** * A {@link List} who can detect element I/O events. * *
      *
    • insert typed events:
        *
      • {@link assign}
      • *
      • {@link insert}
      • *
      • {@link push}
      • *
      • {@link push_front}
      • *
      • {@link push_back}
      • *
      • {@link merge}
      • *
    • *
    • erase typed events:
        *
      • {@link assign}
      • *
      • {@link clear}
      • *
      • {@link erase}
      • *
      • {@link pop_front}
      • *
      • {@link pop_back}
      • *
      • {@link unique}
      • *
      • {@link remove}
      • *
      • {@link remove_if}
      • *
      • {@link splice}
      • *
    • *
    • erase typed events:
        *
      • {@link sort}
      • *
    • *
    * * @author Jeongho Nam */ class ListCollection extends std.List implements ICollection { /** * A chain object taking responsibility of dispatching events. */ private event_dispatcher_; /** * @inheritdoc */ push(...items: T[]): number; /** * @inheritdoc */ push_front(val: T): void; /** * @inheritdoc */ push_back(val: T): void; /** * @hidden */ protected _Insert_by_repeating_val(position: std.ListIterator, n: number, val: T): std.ListIterator; /** * @hidden */ protected _Insert_by_range>(position: std.ListIterator, begin: InputIterator, end: InputIterator): std.ListIterator; /** * @inheritdoc */ pop_front(): void; /** * @inheritdoc */ pop_back(): void; /** * @hidden */ protected _Erase_by_range(first: std.ListIterator, last: std.ListIterator): std.ListIterator; /** * @hidden */ private notify_insert(first, last); /** * @hidden */ private notify_erase(first, last); /** * @inheritdoc */ hasEventListener(type: string): boolean; /** * @inheritdoc */ dispatchEvent(event: library.BasicEvent): boolean; /** * @inheritdoc */ refresh(): void; /** * @inheritdoc */ refresh(it: std.ListIterator): void; /** * @inheritdoc */ refresh(first: std.ListIterator, last: std.ListIterator): void; /** * @inheritdoc */ addEventListener(type: string, listener: library.BasicEventListener): void; addEventListener(type: "insert", listener: CollectionEventListener): void; addEventListener(type: "erase", listener: CollectionEventListener): void; addEventListener(type: "refresh", listener: CollectionEventListener): void; /** * @inheritdoc */ addEventListener(type: string, listener: library.BasicEventListener, thisArg: Object): void; addEventListener(type: "insert", listener: CollectionEventListener, thisArg: Object): void; addEventListener(type: "erase", listener: CollectionEventListener, thisArg: Object): void; addEventListener(type: "refresh", listener: CollectionEventListener, thisArg: Object): void; /** * @inheritdoc */ removeEventListener(type: string, listener: library.BasicEventListener): void; removeEventListener(type: "insert", listener: CollectionEventListener): void; removeEventListener(type: "erase", listener: CollectionEventListener): void; removeEventListener(type: "refresh", listener: CollectionEventListener): void; /** * @inheritdoc */ removeEventListener(type: string, listener: library.BasicEventListener, thisArg: Object): void; removeEventListener(type: "insert", listener: CollectionEventListener, thisArg: Object): void; removeEventListener(type: "erase", listener: CollectionEventListener, thisArg: Object): void; removeEventListener(type: "refresh", listener: CollectionEventListener, thisArg: Object): void; } } declare namespace samchon.collection { type MapCollectionEventListener = (event: MapCollectionEvent) => void; class MapCollectionEvent extends CollectionEvent> { /** * @inheritdoc */ first: std.MapIterator; /** * @inheritdoc */ last: std.MapIterator; } } declare namespace samchon.collection { /** * A {@link TreeMap} who can detect element I/O events. * *
      *
    • insert typed events:
        *
      • {@link assign}
      • *
      • {@link insert}
      • *
      • {@link push}
      • *
      • {@link set}
      • *
      • {@link insert_or_assign}
      • *
    • *
    • erase typed events:
        *
      • {@link assign}
      • *
      • {@link clear}
      • *
      • {@link erase}
      • *
      • {@link extract}
      • *
    • *
    • refresh typed events:
        *
      • {@link set}
      • *
      • {@link insert_or_assign}
      • *
    • *
    * * @author Jeongho Nam */ class TreeMapCollection extends std.TreeMap implements ICollection> { /** * A chain object taking responsibility of dispatching events. */ private event_dispatcher_; /** * @inheritdoc */ protected _Handle_insert(first: std.MapIterator, last: std.MapIterator): void; /** * @inheritdoc */ protected _Handle_erase(first: std.MapIterator, last: std.MapIterator): void; /** * @inheritdoc */ hasEventListener(type: string): boolean; /** * @inheritdoc */ dispatchEvent(event: library.BasicEvent): boolean; /** * @inheritdoc */ refresh(): void; /** * @inheritdoc */ refresh(it: std.MapIterator): void; /** * @inheritdoc */ refresh(first: std.MapIterator, last: std.MapIterator): void; /** * @inheritdoc */ addEventListener(type: string, listener: library.BasicEventListener): void; addEventListener(type: "insert", listener: MapCollectionEventListener): void; addEventListener(type: "erase", listener: MapCollectionEventListener): void; addEventListener(type: "refresh", listener: MapCollectionEventListener): void; /** * @inheritdoc */ addEventListener(type: string, listener: library.BasicEventListener, thisArg: Object): void; addEventListener(type: "insert", listener: MapCollectionEventListener, thisArg: Object): void; addEventListener(type: "erase", listener: MapCollectionEventListener, thisArg: Object): void; addEventListener(type: "refresh", listener: MapCollectionEventListener, thisArg: Object): void; /** * @inheritdoc */ removeEventListener(type: string, listener: library.BasicEventListener): void; removeEventListener(type: "insert", listener: MapCollectionEventListener): void; removeEventListener(type: "erase", listener: MapCollectionEventListener): void; removeEventListener(type: "refresh", listener: MapCollectionEventListener): void; /** * @inheritdoc */ removeEventListener(type: string, listener: library.BasicEventListener, thisArg: Object): void; removeEventListener(type: "insert", listener: MapCollectionEventListener, thisArg: Object): void; removeEventListener(type: "erase", listener: MapCollectionEventListener, thisArg: Object): void; removeEventListener(type: "refresh", listener: MapCollectionEventListener, thisArg: Object): void; } } declare namespace samchon.collection { /** * A {@link TreeMultiMap} who can detect element I/O events. * *
      *
    • insert typed events:
        *
      • {@link assign}
      • *
      • {@link insert}
      • *
      • {@link push}
      • *
    • *
    • erase typed events:
        *
      • {@link assign}
      • *
      • {@link clear}
      • *
      • {@link erase}
      • *
    • *
    * * @author Jeongho Nam */ class TreeMultiMapCollection extends std.TreeMultiMap implements ICollection> { /** * A chain object taking responsibility of dispatching events. */ private event_dispatcher_; /** * @inheritdoc */ protected _Handle_insert(first: std.MapIterator, last: std.MapIterator): void; /** * @inheritdoc */ protected _Handle_erase(first: std.MapIterator, last: std.MapIterator): void; /** * @inheritdoc */ hasEventListener(type: string): boolean; /** * @inheritdoc */ dispatchEvent(event: library.BasicEvent): boolean; /** * @inheritdoc */ refresh(): void; /** * @inheritdoc */ refresh(it: std.MapIterator): void; /** * @inheritdoc */ refresh(first: std.MapIterator, last: std.MapIterator): void; /** * @inheritdoc */ addEventListener(type: string, listener: library.BasicEventListener): void; addEventListener(type: "insert", listener: MapCollectionEventListener): void; addEventListener(type: "erase", listener: MapCollectionEventListener): void; addEventListener(type: "refresh", listener: MapCollectionEventListener): void; /** * @inheritdoc */ addEventListener(type: string, listener: library.BasicEventListener, thisArg: Object): void; addEventListener(type: "insert", listener: MapCollectionEventListener, thisArg: Object): void; addEventListener(type: "erase", listener: MapCollectionEventListener, thisArg: Object): void; addEventListener(type: "refresh", listener: MapCollectionEventListener, thisArg: Object): void; /** * @inheritdoc */ removeEventListener(type: string, listener: library.BasicEventListener): void; removeEventListener(type: "insert", listener: MapCollectionEventListener): void; removeEventListener(type: "erase", listener: MapCollectionEventListener): void; removeEventListener(type: "refresh", listener: MapCollectionEventListener): void; /** * @inheritdoc */ removeEventListener(type: string, listener: library.BasicEventListener, thisArg: Object): void; removeEventListener(type: "insert", listener: MapCollectionEventListener, thisArg: Object): void; removeEventListener(type: "erase", listener: MapCollectionEventListener, thisArg: Object): void; removeEventListener(type: "refresh", listener: MapCollectionEventListener, thisArg: Object): void; } } declare namespace samchon.collection { /** * A {@link TreeMultiSet} who can detect element I/O events. * *
      *
    • insert typed events:
        *
      • {@link assign}
      • *
      • {@link insert}
      • *
      • {@link push}
      • *
    • *
    • erase typed events:
        *
      • {@link assign}
      • *
      • {@link clear}
      • *
      • {@link erase}
      • *
    • *
    * * @author Jeongho Nam */ class TreeMultiSetCollection extends std.TreeMultiSet implements ICollection { /** * A chain object taking responsibility of dispatching events. */ private event_dispatcher_; /** * @inheritdoc */ protected _Handle_insert(first: std.SetIterator, last: std.SetIterator): void; /** * @inheritdoc */ protected _Handle_erase(first: std.SetIterator, last: std.SetIterator): void; /** * @inheritdoc */ hasEventListener(type: string): boolean; /** * @inheritdoc */ dispatchEvent(event: library.BasicEvent): boolean; /** * @inheritdoc */ refresh(): void; /** * @inheritdoc */ refresh(it: std.SetIterator): void; /** * @inheritdoc */ refresh(first: std.SetIterator, last: std.SetIterator): void; /** * @inheritdoc */ addEventListener(type: string, listener: library.BasicEventListener): void; addEventListener(type: "insert", listener: CollectionEventListener): void; addEventListener(type: "erase", listener: CollectionEventListener): void; addEventListener(type: "refresh", listener: CollectionEventListener): void; /** * @inheritdoc */ addEventListener(type: string, listener: library.BasicEventListener, thisArg: Object): void; addEventListener(type: "insert", listener: CollectionEventListener, thisArg: Object): void; addEventListener(type: "erase", listener: CollectionEventListener, thisArg: Object): void; addEventListener(type: "refresh", listener: CollectionEventListener, thisArg: Object): void; /** * @inheritdoc */ removeEventListener(type: string, listener: library.BasicEventListener): void; removeEventListener(type: "insert", listener: CollectionEventListener): void; removeEventListener(type: "erase", listener: CollectionEventListener): void; removeEventListener(type: "refresh", listener: CollectionEventListener): void; /** * @inheritdoc */ removeEventListener(type: string, listener: library.BasicEventListener, thisArg: Object): void; removeEventListener(type: "insert", listener: CollectionEventListener, thisArg: Object): void; removeEventListener(type: "erase", listener: CollectionEventListener, thisArg: Object): void; removeEventListener(type: "refresh", listener: CollectionEventListener, thisArg: Object): void; } } declare namespace samchon.collection { /** * A {@link TreeMap} who can detect element I/O events. * *
      *
    • insert typed events:
        *
      • {@link assign}
      • *
      • {@link insert}
      • *
      • {@link push}
      • *
    • *
    • erase typed events:
        *
      • {@link assign}
      • *
      • {@link clear}
      • *
      • {@link erase}
      • *
      • {@link extract}
      • *
    • *
    * * @author Jeongho Nam */ class TreeSetCollection extends std.TreeSet implements ICollection { /** * A chain object taking responsibility of dispatching events. */ private event_dispatcher_; /** * @inheritdoc */ protected _Handle_insert(first: std.SetIterator, last: std.SetIterator): void; /** * @inheritdoc */ protected _Handle_erase(first: std.SetIterator, last: std.SetIterator): void; /** * @inheritdoc */ hasEventListener(type: string): boolean; /** * @inheritdoc */ dispatchEvent(event: library.BasicEvent): boolean; /** * @inheritdoc */ refresh(): void; /** * @inheritdoc */ refresh(it: std.SetIterator): void; /** * @inheritdoc */ refresh(first: std.SetIterator, last: std.SetIterator): void; /** * @inheritdoc */ addEventListener(type: string, listener: library.BasicEventListener): void; addEventListener(type: "insert", listener: CollectionEventListener): void; addEventListener(type: "erase", listener: CollectionEventListener): void; addEventListener(type: "refresh", listener: CollectionEventListener): void; /** * @inheritdoc */ addEventListener(type: string, listener: library.BasicEventListener, thisArg: Object): void; addEventListener(type: "insert", listener: CollectionEventListener, thisArg: Object): void; addEventListener(type: "erase", listener: CollectionEventListener, thisArg: Object): void; addEventListener(type: "refresh", listener: CollectionEventListener, thisArg: Object): void; /** * @inheritdoc */ removeEventListener(type: string, listener: library.BasicEventListener): void; removeEventListener(type: "insert", listener: CollectionEventListener): void; removeEventListener(type: "erase", listener: CollectionEventListener): void; removeEventListener(type: "refresh", listener: CollectionEventListener): void; /** * @inheritdoc */ removeEventListener(type: string, listener: library.BasicEventListener, thisArg: Object): void; removeEventListener(type: "insert", listener: CollectionEventListener, thisArg: Object): void; removeEventListener(type: "erase", listener: CollectionEventListener, thisArg: Object): void; removeEventListener(type: "refresh", listener: CollectionEventListener, thisArg: Object): void; } } declare namespace samchon.library { /** *

    XML is a class representing a tree structued xml objects.

    *

    The XML class provides methods and properties for working with XML objects.

    * *

    The XML class (along with the XMLList and Namespace) implements * the powerful XML-handling standard defined in ECMAScript for XML (E4X) specification.

    * *

    XML class has a recursive, hierarchical relationship.

    * *

    Relationships between XML and XMLList

    *
      *
    • XML is std.HashMap
    • *
    • XMLList is std.Deque
    • *
    * *

    Note

    *

    Do not abuse values for expressing member variables.

    * * * * * * * * * * *
    Standard UsageNon-standard usage abusing value
    * * * * * * * * * * * jhnam88 * Jeongho Nam * 1988-03-11 * * * master * Administartor * 2011-07-28 * * * *
    * * @author Jeongho Nam */ class XML extends std.HashMap { /** *

    Tag name of the XML.

    * *
      *
    • \<tag label='property' /\>: tag => \"tag\"
    • *
    • \<price high='1500' low='1300' open='1450' close='1320' /\>: tag => \"price\"
    • *
    */ private tag_; /** *

    Value of the XML.

    * *
      *
    • \26\: value => 26
    • *
    • \: value => null
    • *
    */ private value_; /** *

    Properties belongs to the XML.

    *

    A Dictionary of properties accessing each property by its key.

    * *
      *
    • \high='1500' low='1300' open='1450' close='1320' /\>: * propertyMap => {{\"high\": 1500}, {\"low\": 1300}, {\"open\": 1450}, {\"close\", 1320}}
    • *
    • \id='jhnam88' name='Jeongho+Nam' comment='Hello.+My+name+is+Jeongho+Nam' \>: * propertyMap => {{\"id\", \"jhnam88\"}, {\"name\", \"Jeongho Nam \"}, * {\"comment\", \"Hello. My name is Jeongho Nam \"}}
    • *
    */ private property_map_; /** *

    Default Constructor.

    * *

    If the string parameter is not omitted, constructs its tag, value and * properties by parsing the string. If there's children, then construct the * children XML, XMLList objects, too.

    * * @param str A string to be parsed */ constructor(str?: string); /** *

    Construct XML objects by parsing a string.

    */ private construct(str); /** *

    Parse and fetch a tag.

    */ private parseTag(str); /** *

    Parse and fetch properties.

    */ private parseProperty(str); /** *

    Parse and fetch a value.

    */ private parseValue(str); /** *

    Parse and construct children XML objects.

    */ private parseChildren(str); /** *

    Get tag.

    */ getTag(): string; /** *

    Get value.

    */ getValue(): string; /** *

    Test whether a property exists or not.

    */ hasProperty(key: string): boolean; /** *

    Get property by its key.

    */ getProperty(key: string): string; getPropertyMap(): std.HashMap; /** *

    Set tag (identifier) of the XML.

    */ setTag(str: string): void; /** *

    Set value of the XML.

    * *

    Do not abuse values for expressing member variables.

    * * * * * * * * * *
    Standard UsageNon-standard usage abusing value
    * \\n *     \\n *     \\n * \ * * \\n * \jhnam88\\n * \Jeongho+Nam\\n * \1988-03-11\\n * \ *
    * * @param val A value to set */ setValue(str: string): void; /** *

    Set a property with its key.

    */ setProperty(key: string, value: string): void; /** *

    Erase a property by its key.

    * * @param key The key of the property to erase * @throw exception out of range */ eraseProperty(key: string): void; push(...args: std.Pair[]): number; push(...args: [L, U][]): number; push(...xmls: XML[]): number; push(...xmlLists: XMLList[]): number; addAllProperties(xml: XML): void; clearProperties(): void; private calcMinIndex(...args); /** *

    Decode a value.

    * * * * * * * * * * * * * * * * * * *
    EncodedDecoded
    \&\&
    \<\<
    \>\>
    * * @return A decoded string represents a value */ static decodeValue(str: string): string; /** *

    Encode a value.

    * * * * * * * * * * * * * * * * * * *
    OriginalEncoded
    \&\&
    \<\<
    \>\>
    * * @return A encoded string represents a value */ static encodeValue(str: string): string; /** *

    Decode a property.

    * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
    EncodedDecoded
    \&\&
    \<\<
    \>\>
    "\"
    ''
    '
    '\\t
    \\n
    \\r
    * * @return A decoded string represents a property */ static decodeProperty(str: string): string; /** *

    Decode a property.

    * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
    OriginalEncoded
    \&\&
    \<\<
    \>\>
    \""
    ''
    '
    \\t'
    \\n
    \\r
    * * @return A encoded string represents a property */ static encodeProperty(str: string): string; /** *

    Convert the XML to a string.

    */ toString(level?: number): string; /** *

    Convert the XML to HTML string.

    */ toHTML(level?: number): string; } /** *

    List of XML(s) having same tag.

    * * @author Jeongho Nam */ class XMLList extends std.Deque { getTag(): string; /** *

    Convert XMLList to string.

    * * @param level Level(depth) of the XMLList. */ toString(level?: number): string; /** *

    Convert XMLList to HTML string.

    * * @param level Level(depth) of the XMLList. */ toHTML(level?: number): string; } } declare namespace samchon.collection { /** * An {@link XMLList} who can detect element I/O events. * *

    Below are list of methods who are dispatching {@link CollectionEvent}:

    * *
      *
    • insert typed events:
        *
      • {@link assign}
      • *
      • {@link insert}
      • *
      • {@link push}
      • *
      • {@link push_front}
      • *
      • {@link push_back}
      • *
    • *
    • erase typed events:
        *
      • {@link assign}
      • *
      • {@link clear}
      • *
      • {@link erase}
      • *
      • {@link pop_front}
      • *
      • {@link pop_back}
      • *
    • *
    * * @author Jeongho Nam */ class XMLListCollection extends library.XMLList implements ICollection { /** * A chain object taking responsibility of dispatching events. */ private event_dispatcher_; /** * @inheritdoc */ push(...items: U[]): number; /** * @inheritdoc */ push_back(val: library.XML): void; /** * @hidden */ protected _Insert_by_repeating_val(position: std.DequeIterator, n: number, val: library.XML): std.DequeIterator; /** * @hidden */ protected _Insert_by_range>(position: std.DequeIterator, begin: InputIterator, end: InputIterator): std.DequeIterator; /** * @inheritdoc */ pop_back(): void; /** * @hidden */ protected _Erase_by_range(first: std.DequeIterator, last: std.DequeIterator): std.DequeIterator; /** * @hidden */ private notify_insert(first, last); /** * @hidden */ private notify_erase(first, last); /** * @inheritdoc */ hasEventListener(type: string): boolean; /** * @inheritdoc */ dispatchEvent(event: library.BasicEvent): boolean; /** * @inheritdoc */ refresh(): void; /** * @inheritdoc */ refresh(it: std.DequeIterator): void; /** * @inheritdoc */ refresh(first: std.DequeIterator, last: std.DequeIterator): void; /** * @inheritdoc */ addEventListener(type: string, listener: library.BasicEventListener): void; addEventListener(type: "insert", listener: CollectionEventListener): void; addEventListener(type: "erase", listener: CollectionEventListener): void; addEventListener(type: "refresh", listener: CollectionEventListener): void; /** * @inheritdoc */ addEventListener(type: string, listener: library.BasicEventListener, thisArg: Object): void; addEventListener(type: "insert", listener: CollectionEventListener, thisArg: Object): void; addEventListener(type: "erase", listener: CollectionEventListener, thisArg: Object): void; addEventListener(type: "refresh", listener: CollectionEventListener, thisArg: Object): void; /** * @inheritdoc */ removeEventListener(type: string, listener: library.BasicEventListener): void; removeEventListener(type: "insert", listener: CollectionEventListener): void; removeEventListener(type: "erase", listener: CollectionEventListener): void; removeEventListener(type: "refresh", listener: CollectionEventListener): void; /** * @inheritdoc */ removeEventListener(type: string, listener: library.BasicEventListener, thisArg: Object): void; removeEventListener(type: "insert", listener: CollectionEventListener, thisArg: Object): void; removeEventListener(type: "erase", listener: CollectionEventListener, thisArg: Object): void; removeEventListener(type: "refresh", listener: CollectionEventListener, thisArg: Object): void; } } declare namespace samchon.library { /** *

    Case generator.

    * *

    {@link CaseGenerator} is an abstract case generator being used like a matrix.

    *
      *
    • n��r(n^r) -> {@link CombinedPermutationGenerator}
    • *
    • nPr -> {@link PermutationGenerator}
    • *
    • n! -> {@link FactorialGenerator}
    • *
    * * @author Jeongho Nam */ abstract class CaseGenerator { /** *

    Size, the number of all cases.

    */ protected size_: number; /** *

    N, size of the candidates.

    */ protected n_: number; /** *

    R, size of elements of each case.

    */ protected r_: number; /** *

    Construct from size of N and R.

    * * @param n Size of candidates. * @param r Size of elements of each case. */ constructor(n: number, r: number); /** *

    Get size of all cases.

    * * @return Get a number of the all cases. */ size(): number; /** *

    Get size of the N.

    */ n(): number; /** *

    Get size of the R.

    */ r(): number; /** *

    Get index'th case.

    * * @param index Index number * @return The row of the index'th in combined permuation case */ abstract at(index: number): number[]; } /** *

    A combined-permutation case generator.

    * *

    n��r

    * * @author Jeongho Nam */ class CombinedPermutationGenerator extends CaseGenerator { /** *

    An array using for dividing each element index.

    */ private divider_array; /** *

    Construct from size of N and R.

    * * @param n Size of candidates. * @param r Size of elements of each case. */ constructor(n: number, r: number); at(index: number): number[]; } /** *

    A permutation case generator.

    * *

    nPr

    * * @author Jeongho Nam */ class PermuationGenerator extends CaseGenerator { /** *

    Construct from size of N and R.

    * * @param n Size of candidates. * @param r Size of elements of each case. */ constructor(n: number, r: number); /** * @inheritdoc */ at(index: number): number[]; } /** *

    Factorial case generator.

    * *

    n! = nPn

    * * @author Jeongho Nam */ class FactorialGenerator extends PermuationGenerator { /** * Construct from factorial size N. * * @param n Factoria size N. */ constructor(n: number); } } declare namespace samchon.library { type BasicEventListener = (event: BasicEvent) => void; /** *

    The IEventDispatcher interface defines methods for adding or removing event listeners, checks * whether specific types of event listeners are registered, and dispatches events.

    * *

    Event targets are an important part of the Flash�� Player and Adobe AIR event model. The event * target serves as the local point for how events flow through the display list hierarchy. When an * event such as a mouse click or a key press occurs, an event object is dispatched into the event flow * from the root of the display list. The event object makes a round-trip journey to the event target, * which is conceptually divided into three phases: the capture phase includes the journey from the * root to the last node before the event target's node; the target phase includes only the event * target node; and the bubbling phase includes any subsequent nodes encountered on the return trip to * the root of the display list.

    * *

    In general, the easiest way for a user-defined class to gain event dispatching capabilities is * to extend EventDispatcher. If this is impossible (that is, if the class is already extending another * class), you can instead implement the IEventDispatcher interface, create an EventDispatcher member, * and write simple hooks to route calls into the aggregated EventDispatcher.

    * * @reference http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/events/IEventDispatcher.html * @author Migrated by Jeongho Nam */ interface IEventDispatcher { /** *

    Checks whether the EventDispatcher object has any listeners registered for a specific type * of event. This allows you to determine where an EventDispatcher object has altered handling of * an event type in the event flow hierarchy. To determine whether a specific event type actually * triggers an event listener, use willTrigger().

    * *

    The difference between hasEventListener() and willTrigger() is that hasEventListener() * examines only the object to which it belongs, whereas willTrigger() examines the entire event * flow for the event specified by the type parameter.

    * * @param type The type of event. */ hasEventListener(type: string): boolean; /** *

    Dispatches an event into the event flow.

    *

    The event target is the EventDispatcher object upon which the dispatchEvent() method is called.

    * * @param event The Event object that is dispatched into the event flow. If the event is being * redispatched, a clone of the event is created automatically. After an event is * dispatched, its target property cannot be changed, so you must create a new copy * of the event for redispatching to work. */ dispatchEvent(event: library.BasicEvent): boolean; /** *

    Registers an event listener object with an EventDispatcher object so that the listener * receives notification of an event. You can register event listeners on all nodes in the display * list for a specific type of event, phase, and priority. * *

    After you successfully register an event listener, you cannot change its priority through * additional calls to addEventListener(). To change a listener's priority, you must first call * removeEventListener(). Then you can register the listener again with the new priority level.

    * *

    Keep in mind that after the listener is registered, subsequent calls to addEventListener() * with a different type or useCapture value result in the creation of a separate listener * registration. For example, if you first register a listener with useCapture set to true, * it listens only during the capture phase. If you call addEventListener() again using the same * listener object, but with useCapture set to false, you have two separate listeners: one that * listens during the capture phase and another that listens during the target and bubbling phases.

    * *

    You cannot register an event listener for only the target phase or the bubbling phase. * Those phases are coupled during registration because bubbling applies only to the ancestors of * the target node.

    * *

    If you no longer need an event listener, remove it by calling removeEventListener(), or * memory problems could result. Event listeners are not automatically removed from memory because * the garbage collector does not remove the listener as long as the dispatching object exists * (unless the useWeakReference parameter is set to true).

    * *

    Copying an EventDispatcher instance does not copy the event listeners attached to it. (If * your newly created node needs an event listener, you must attach the listener after creating * the node.) However, if you move an EventDispatcher instance, the event listeners attached to * it move along with it.

    * *

    If the event listener is being registered on a node while an event is also being processed * on this node, the event listener is not triggered during the current phase but may be triggered * during a later phase in the event flow, such as the bubbling phase.

    * *

    If an event listener is removed from a node while an event is being processed on the node, * it is still triggered by the current actions. After it is removed, the event listener is never * invoked again (unless it is registered again for future processing).

    * * @param event The type of event. * @param listener The listener function that processes the event. * This function must accept an Event object as its only parameter and must return * nothing. */ addEventListener(type: string, listener: library.BasicEventListener): void; /** *

    Registers an event listener object with an EventDispatcher object so that the listener * receives notification of an event. You can register event listeners on all nodes in the display * list for a specific type of event, phase, and priority. * *

    After you successfully register an event listener, you cannot change its priority through * additional calls to addEventListener(). To change a listener's priority, you must first call * removeEventListener(). Then you can register the listener again with the new priority level.

    * *

    Keep in mind that after the listener is registered, subsequent calls to addEventListener() * with a different type or useCapture value result in the creation of a separate listener * registration. For example, if you first register a listener with useCapture set to true, * it listens only during the capture phase. If you call addEventListener() again using the same * listener object, but with useCapture set to false, you have two separate listeners: one that * listens during the capture phase and another that listens during the target and bubbling phases.

    * *

    You cannot register an event listener for only the target phase or the bubbling phase. * Those phases are coupled during registration because bubbling applies only to the ancestors of * the target node.

    * *

    If you no longer need an event listener, remove it by calling removeEventListener(), or * memory problems could result. Event listeners are not automatically removed from memory because * the garbage collector does not remove the listener as long as the dispatching object exists * (unless the useWeakReference parameter is set to true).

    * *

    Copying an EventDispatcher instance does not copy the event listeners attached to it. (If * your newly created node needs an event listener, you must attach the listener after creating * the node.) However, if you move an EventDispatcher instance, the event listeners attached to * it move along with it.

    * *

    If the event listener is being registered on a node while an event is also being processed * on this node, the event listener is not triggered during the current phase but may be triggered * during a later phase in the event flow, such as the bubbling phase.

    * *

    If an event listener is removed from a node while an event is being processed on the node, * it is still triggered by the current actions. After it is removed, the event listener is never * invoked again (unless it is registered again for future processing).

    * * @param event The type of event. * @param listener The listener function that processes the event. * This function must accept an Event object as its only parameter and must return * nothing. * @param thisArg The object to be used as the this object. */ addEventListener(type: string, listener: library.BasicEventListener, thisArg: Object): void; /** * Removes a listener from the EventDispatcher object. If there is no matching listener registered * with the EventDispatcher object, a call to this method has no effect. * * @param type The type of event. * @param listener The listener object to remove. */ removeEventListener(type: string, listener: library.BasicEventListener): void; /** * Removes a listener from the EventDispatcher object. If there is no matching listener registered * with the EventDispatcher object, a call to this method has no effect. * * @param type The type of event. * @param listener The listener object to remove. * @param thisArg The object to be used as the this object. */ removeEventListener(type: string, listener: library.BasicEventListener, thisArg: Object): void; } /** *

    Registers an event listener object with an EventDispatcher object so that the listener * receives notification of an event. You can register event listeners on all nodes in the display * list for a specific type of event, phase, and priority.

    * *

    After you successfully register an event listener, you cannot change its priority through * additional calls to addEventListener(). To change a listener's priority, you must first call * removeListener(). Then you can register the listener again with the new priority level.

    * * Keep in mind that after the listener is registered, subsequent calls to addEventListener() * with a different type or useCapture value result in the creation of a separate listener registration. * For example, if you first register a listener with useCapture set to true, it listens only during the * capture phase. If you call addEventListener() again using the same listener object, but with * useCapture set to false, you have two separate listeners: one that listens during the capture * phase and another that listens during the target and bubbling phases. * *

    You cannot register an event listener for only the target phase or the bubbling phase. Those * phases are coupled during registration because bubbling applies only to the ancestors of the * target node.

    * *

    If you no longer need an event listener, remove it by calling removeEventListener(), * or memory problems could result. Event listeners are not automatically removed from memory * because the garbage collector does not remove the listener as long as the dispatching object * exists (unless the useWeakReference parameter is set to true).

    * *

    Copying an EventDispatcher instance does not copy the event listeners attached to it. (If your * newly created node needs an event listener, you must attach the listener after creating the * node.) However, if you move an EventDispatcher instance, the event listeners attached to it move * along with it.

    * *

    If the event listener is being registered on a node while an event is being processed on * this node, the event listener is not triggered during the current phase but can be triggered * during a later phase in the event flow, such as the bubbling phase.

    * *

    If an event listener is removed from a node while an event is being processed on the node, it is * still triggered by the current actions. After it is removed, the event listener is never invoked * again (unless registered again for future processing).

    * *
      *
    • Made by AS3 - http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/events/EventDispatcher.html *
    * * @author Migrated by Jeongho Nam */ class EventDispatcher implements IEventDispatcher { /** * The origin object who issuing events. */ protected event_dispatcher_: IEventDispatcher; /** * Container of listeners. */ protected event_listeners_: std.HashMap>>; /** * Default Constructor. */ constructor(); /** * Construct from the origin event dispatcher. * * @param dispatcher The origin object who issuing events. */ constructor(dispatcher: IEventDispatcher); /** * @inheritdoc */ hasEventListener(type: string): boolean; /** * @inheritdoc */ dispatchEvent(event: library.BasicEvent): boolean; /** * @inheritdoc */ addEventListener(type: string, listener: library.BasicEventListener): void; /** * @inheritdoc */ addEventListener(type: string, listener: library.BasicEventListener, thisArg: Object): void; /** * @inheritdoc */ removeEventListener(type: string, listener: library.BasicEventListener): void; /** * @inheritdoc */ removeEventListener(type: string, listener: library.BasicEventListener, thisArg: Object): void; } } declare namespace samchon.library { /** *

    The {@link FileReference} class provides a means to load and save files in browser level.

    * *

    The {@link FileReference} class provides a means to {@link load} and {@link save} files in browser level. A * browser-system dialog box prompts the user to select a file to {@link load} or a location for {@link svae}. Each * {@link FileReference} object refers to a single file on the user's disk and has properties that contain * information about the file's size, type, name, creation date, modification date, and creator type (Macintosh only). *

    * *

    FileReference instances are created in the following ways:

    *
      *
    • * When you use the new operator with the {@link FileReference} constructor: * var myFileReference = new FileReference(); *
    • *
    • * When you call the {@link FileReferenceList.browse} method, which creates an array of {@link FileReference} * objects. *
    • *
    * *

    During a load operation, all the properties of a {@link FileReference} object are populated by calls to the * {@link FileReference.browse} or {@link FileReferenceList.browse} methods. During a save operation, the name * property is populated when the select event is dispatched; all other properties are populated when the complete * event is dispatched.

    * *

    The {@link browse browse()} method opens an browser-system dialog box that prompts the user to select a file * for {@link load}. The {@link FileReference.browse} method lets the user select a single file; the * {@link FileReferenceList.browse} method lets the user select multiple files. After a successful call to the * {@link browse browse()} method, call the {@link FileReference.load} method to load one file at a time. The * {@link FileReference.save} method prompts the user for a location to save the file and initiates downloading from * a binary or string data.

    * *

    The {@link FileReference} and {@link FileReferenceList} classes do not let you set the default file location * for the dialog box that the {@link browse} or {@link save} methods generate. The default location shown in the * dialog box is the most recently browsed folder, if that location can be determined, or the desktop. The classes do * not allow you to read from or write to the transferred file. They do not allow the browser that initiated the * {@link load} or {@link save} to access the loaded or saved file or the file's location on the user's disk.

    * * @references http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/FileReference.html * @author Jeongho Nam */ class FileReference extends EventDispatcher { /** * @hidden */ private file_; /** * @hidden */ private data_; /** * Default Constructor. */ constructor(); /** *

    The data from the loaded file after a successful call to the {@link load load()} method.

    * *

    If the {@link FileReference} object was not populated (by a valid call to {@link FileReference.browse}), * an {@link LogicError exception} will be thrown when you try to get the value of this property.

    * *

    All the properties of a {@link FileReference} object are populated by calling the {@link browse browse()}. *

    */ data: any; /** *

    The name of the file on the local disk.

    * *

    If the {@link FileReference} object was not populated (by a valid call to {@link FileReference.browse}), * an {@link LogicError exception} will be thrown when you try to get the value of this property.

    * *

    All the properties of a {@link FileReference} object are populated by calling the {@link browse browse()}. *

    */ name: string; /** *

    The filename extension.

    * *

    A file's extension is the part of the name following (and not including) the final dot ("."). If * there is no dot in the filename, the extension is null.

    * *

    If the {@link FileReference} object was not populated (by a valid call to {@link FileReference.browse}), * an {@link LogicError exception} will be thrown when you try to get the value of this property.

    * *

    All the properties of a {@link FileReference} object are populated by calling the {@link browse browse()}. *

    */ extension: string; /** *

    The file type, metadata of the {@link extension}.

    * *

    If the {@link FileReference} object was not populated (by a valid call to {@link FileReference.browse}), * an {@link LogicError exception} will be thrown when you try to get the value of this property.

    * *

    All the properties of a {@link FileReference} object are populated by calling the {@link browse browse()}. *

    */ type: string; /** *

    The size of the file on the local disk in bytes.

    * *

    If the {@link FileReference} object was not populated (by a valid call to {@link FileReference.browse}), * an {@link LogicError exception} will be thrown when you try to get the value of this property.

    * *

    All the properties of a {@link FileReference} object are populated by calling the {@link browse browse()}. *

    */ size: number; /** *

    The date that the file on the local disk was last modified.

    * *

    If the {@link FileReference} object was not populated (by a valid call to {@link FileReference.browse}), * an {@link LogicError exception} will be thrown when you try to get the value of this property.

    * *

    All the properties of a {@link FileReference} object are populated by calling the {@link browse browse()}. *

    */ modificationDate: Date; /** * @hidden */ _Set_file(val: File): void; /** *

    Displays a file-browsing dialog box that lets the user select a file to upload. The dialog box is native * to the user's browser system. The user can select a file on the local computer or from other systems, for * example, through a UNC path on Windows.

    * *

    When you call this method and the user successfully selects a file, the properties of this * {@link FileReference} object are populated with the properties of that file. Each subsequent time that the * {@link FileReference.browse} method is called, the {@link FileReference} object's properties are reset to * the file that the user selects in the dialog box. Only one {@link browse browse()} can be performed at a time * (because only one dialog box can be invoked at a time).

    * *

    Using the typeFilter parameter, you can determine which files the dialog box displays.

    * * @param typeFilter An array of filter strings used to filter the files that are displayed in the dialog box. * If you omit this parameter, all files are displayed. */ browse(...typeFilter: string[]): void; /** *

    Starts the load of a local file selected by a user.

    * *

    You must call the {@link FileReference.browse} or {@link FileReferenceList.browse} method before you call * the {@link load load()} method.

    * *

    Listeners receive events to indicate the progress, success, or failure of the load. Although you can use * the {@link FileReferenceList} object to let users select multiple files to load, you must {@link load} the * {@link FileReferenceList files} one by one. To {@link load} the files one by one, iterate through the * {@link FileReferenceList.fileList} array of {@link FileReference} objects.

    * *

    If the file finishes loading successfully, its contents are stored in the {@link data} property.

    */ load(): void; /** *

    Save a file to local filesystem.

    * *

    {@link FileReference.save} implemented the save function by downloading a file from a hidden anchor tag. * However, the plan, future's {@link FileReference} will follow such rule:

    * *

    Opens a dialog box that lets the user save a file to the local filesystem.

    * *

    The {@link save save()} method first opens an browser-system dialog box that asks the user to enter a * filename and select a location on the local computer to save the file. When the user selects a location and * confirms the save operation (for example, by clicking Save), the save process begins. Listeners receive events * to indicate the progress, success, or failure of the save operation. To ascertain the status of the dialog box * and the save operation after calling {@link save save()}, your code must listen for events such as cancel, * open, progress, and complete.

    * *

    When the file is saved successfully, the properties of the {@link FileReference} object are populated with * the properties of the local file. The complete event is dispatched if the save is successful.

    * *

    Only one {@link browse browse()} or {@link save()} session can be performed at a time (because only one * dialog box can be invoked at a time).

    * * @param data The data to be saved. The data can be in one of several formats, and will be treated appropriately. * @param fileName File name to be saved. */ save(data: string, fileName: string): void; /** *

    Save a file to local filesystem.

    * *

    {@link FileReference.save} implemented the save function by downloading a file from a hidden anchor tag. * However, the plan, future's {@link FileReference} will follow such rule:

    * *

    Opens a dialog box that lets the user save a file to the local filesystem.

    * *

    The {@link save save()} method first opens an browser-system dialog box that asks the user to enter a * filename and select a location on the local computer to save the file. When the user selects a location and * confirms the save operation (for example, by clicking Save), the save process begins. Listeners receive events * to indicate the progress, success, or failure of the save operation. To ascertain the status of the dialog box * and the save operation after calling {@link save save()}, your code must listen for events such as cancel, * open, progress, and complete.

    * *

    When the file is saved successfully, the properties of the {@link FileReference} object are populated with * the properties of the local file. The complete event is dispatched if the save is successful.

    * *

    Only one {@link browse browse()} or {@link save()} session can be performed at a time (because only one * dialog box can be invoked at a time).

    * * @param data The data to be saved. The data can be in one of several formats, and will be treated appropriately. * @param fileName File name to be saved. */ static save(data: string, fileName: string): void; } /** *

    The {@link FileReferenceList} class provides a means to let users select one or more files for * {@link FileReference.load loading}. A {@link FileReferenceList} object represents a group of one or more local * files on the user's disk as an array of {@link FileReference} objects. For detailed information and important * considerations about {@link FileReference} objects and the FileReference class, which you use with * {@link FileReferenceList}, see the {@link FileReference} class.

    * *

    To work with the {@link FileReferenceList} class:

    *
      *
    • Instantiate the class: var myFileRef = new FileReferenceList();
    • *
    • * Call the {@link FileReferenceList.browse} method, which opens a dialog box that lets the user select one or * more files for upload: myFileRef.browse(); *
    • *
    • * After the {@link browse browse()} method is called successfully, the {@link fileList} property of the * {@link FileReferenceList} object is populated with an array of {@link FileReference} objects. *
    • *
    • Call {@link FileReference.load} on each element in the {@link fileList} array.
    • *
    * *

    The {@link FileReferenceList} class includes a {@link browse browse()} method and a {@link fileList} property * for working with multiple files.

    * * @reference http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/FileReferenceList.html * @author Jeongho Nam */ class FileReferenceList extends EventDispatcher { /** * @hidden */ file_list: std.Vector; /** * Default Constructor. */ constructor(); /** *

    An array of {@link FileReference} objects.

    * *

    When the {@link FileReferenceList.browse} method is called and the user has selected one or more files * from the dialog box that the {@link browse browse()} method opens, this property is populated with an array of * {@link FileReference} objects, each of which represents the files the user selected.

    * *

    The {@link fileList} property is populated anew each time {@link browse browse()} is called on that * {@link FileReferenceList} object.

    */ fileList: std.Vector; /** *

    Displays a file-browsing dialog box that lets the user select one or more local files to upload. The * dialog box is native to the user's browser system.

    * *

    When you call this method and the user successfully selects files, the {@link fileList} property of this * {@link FileReferenceList} object is populated with an array of {@link FileReference} objects, one for each * file that the user selects. Each subsequent time that the {@link FileReferenceList.browse} method is called, * the {@link FileReferenceList.fileList} property is reset to the file(s) that the user selects in the dialog * box.

    * *

    Using the typeFilter parameter, you can determine which files the dialog box displays.

    * *

    Only one {@link FileReference.browse}, {@link FileReference.load}, or {@link FileReferenceList.browse} * session can be performed at a time on a {@link FileReferenceList} object (because only one dialog box can be * opened at a time).

    * * @param typeFilter An array of filter strings used to filter the files that are displayed in the dialog box. * If you omit this parameter, all files are displayed. */ browse(...typeFilter: string[]): void; } } declare namespace samchon.library { /** *

    A genetic algorithm class.

    * * @details *

    In the field of artificial intelligence, a genetic algorithm (GA) is a search heuristic that mimics the * process of natural selection. This heuristic (also sometimes called a metaheuristic) is routinely used to generate * useful solutions to optimization and search problems.

    * *

    Genetic algorithms belong to the larger class of evolutionary algorithms (EA), which generate solutions to * optimization problems using techniques inspired by natural evolution, such as inheritance, {@link mutate mutation}, * {@link selection}, and {@link crossover}.

    * * @reference https://en.wikipedia.org/wiki/Genetic_algorithm * @author Jeongho Nam */ class GeneticAlgorithm { /** * Whether each element (Gene) is unique in their GeneArray. */ private unique_; /** * Rate of mutation. * * The {@link mutation_rate} determines the percentage of occurence of mutation in GeneArray. * *
      *
    • When {@link mutation_rate} is too high, it is hard to ancitipate studying on genetic algorithm.
    • *
    • * When {@link mutation_rate} is too low and initial set of genes (GeneArray) is far away from optimal, the * evolution tends to wandering outside of he optimal. *
    • *
    */ private mutation_rate_; /** * Number of tournaments in selection. */ private tournament_; /** * Initialization Constructor. * * @param unique Whether each Gene is unique in their GeneArray. * @param mutation_rate Rate of mutation. * @param tournament Number of tournaments in selection. */ constructor(unique?: boolean, mutation_rate?: number, tournament?: number); /** *

    Evolove GeneArray.

    * *

    Convenient method accessing to {@link evolvePopulation evolvePopulation()}.

    * * @param individual An initial set of genes; sequence listing. * @param population Size of population in a generation. * @param generation Size of generation in evolution. * @param compare A comparison function returns whether left gene is more optimal. * * @return An evolved GeneArray, optimally. * * @see {@link GAPopulation.compare} */ evolveGeneArray>(individual: GeneArray, population: number, generation: number, compare?: (left: T, right: T) => boolean): GeneArray; /** * Evolve population, a mass of GeneArraies. * * @param population An initial population. * @param compare A comparison function returns whether left gene is more optimal. * * @return An evolved population. * * @see {@link GAPopulation.compare} */ evolvePopulation>(population: GAPopulation, compare?: (left: T, right: T) => boolean): GAPopulation; /** *

    Select the best GeneArray in population from tournament.

    * *

    {@link selection Selection} is the stage of a genetic algorithm in which individual genomes are chosen * from a population for later breeding (using {@linlk crossover} operator). A generic {@link selection} * procedure may be implemented as follows:

    * *
      *
    1. * The fitness function is evaluated for each individual, providing fitness values, which are then * normalized. ization means dividing the fitness value of each individual by the sum of all fitness * values, so that the sum of all resulting fitness values equals 1. *
    2. *
    3. The population is sorted by descending fitness values.
    4. *
    5. * Accumulated normalized fitness values are computed (the accumulated fitness value of an individual is the * sum of its own fitness value plus the fitness values of all the previous individuals). The accumulated * fitness of the last individual should be 1 (otherwise something went wrong in the normalization step). *
    6. *
    7. A random number R between 0 and 1 is chosen.
    8. *
    9. The selected individual is the first one whose accumulated normalized value is greater than R.
    10. *
    * * @param population The target of tournament. * @return The best genes derived by the tournament. * * @reference https://en.wikipedia.org/wiki/Selection_(genetic_algorithm) */ private selection(population); /** *

    Create a new GeneArray by crossing over two GeneArray(s).

    * *

    {@link crossover} is a genetic operator used to vary the programming of a chromosome or chromosomes from * one generation to the next. It is analogous to reproduction and biological crossover, upon which genetic * algorithms are based.

    * *

    {@link crossover Cross over} is a process of taking more than one parent solutions and producing a child * solution from them. There are methods for selection of the chromosomes.

    * * @param parent1 A parent sequence listing * @param parent2 A parent sequence listing * * @reference https://en.wikipedia.org/wiki/Crossover_(genetic_algorithm) */ private crossover(parent1, parent2); /** *

    Cause a mutation on the GeneArray.

    * *

    {@link mutate Mutation} is a genetic operator used to maintain genetic diversity from one generation of a * population of genetic algorithm chromosomes to the next. It is analogous to biological mutation.

    * *

    {@link mutate Mutation} alters one or more gene values in a chromosome from its initial state. In * {@link mutate mutation}, the solution may change entirely from the previous solution. Hence GA can come to * better solution by using {@link mutate mutation}.

    * *

    {@link mutate Mutation} occurs during evolution according to a user-definable mutation probability. This * probability should be set low. If it is set too high, the search will turn into a primitive random search.

    * *

    Note

    *

    Muttion is pursuing diversity. Mutation is useful for avoiding the following problem.

    * *

    When initial set of genes(GeneArray) is far away from optimail, without mutation (only with selection and * crossover), the genetic algorithm has a tend to wandering outside of the optimal.

    * *

    Genes in the GeneArray will be swapped following percentage of the {@link mutation_rate}.

    * * @param individual A container of genes to mutate * * @reference https://en.wikipedia.org/wiki/Mutation_(genetic_algorithm) * @see {@link mutation_rate} */ private mutate(individual); } /** *

    A population in a generation.

    * *

    {@link GAPopulation} is a class representing population of candidate genes (sequence listing) having an array * of GeneArray as a member. {@link GAPopulation} also manages initial set of genes and handles fitting test direclty * by the method {@link fitTest fitTest()}.

    * *

    The success of evolution of genetic algorithm is depend on the {@link GAPopulation}'s initial set and fitting * test. (GeneArray and {@link compare}.)

    * *

    Warning

    *

    Be careful for the mistakes of direction or position of the {@link compare}.

    *

    Most of logical errors failed to access optimal solution are occured from those mistakes.

    * * @param Type of gene elements. * @param An array containing genes as elments; sequnce listing. * * @author Jeongho Nam */ class GAPopulation> { /** * Genes representing the population. */ private children_; /** *

    A comparison function returns whether left gene is more optimal, greater.

    * *

    Default value of this {@link compare} is {@link std.greater}. It means to compare two array * (GeneArray must be a type of {@link std.base.IArrayContainer}). Thus, you've to keep follwing rule.

    * *
      *
    • GeneArray is implemented from {@link std.base.IArrayContainer}.
    • *
        *
      • {@link std.Vector}
      • *
      • {@link std.Deque}
      • *
      *
    • GeneArray has custom public less(obj: T): boolean; function.
    • *
    * *

    If you don't want to follow the rule or want a custom comparison function, you have to realize a * comparison function.

    */ private compare_; /** *

    Private constructor with population.

    * *

    Private constructor of GAPopulation does not create {@link children}. (candidate genes) but only assigns * null repeatedly following the population size.

    * *

    This private constructor is designed only for {@link GeneticAlgorithm}. Don't create {@link GAPopulation} * with this constructor, by yourself.

    * * @param size Size of the population. */ constructor(size: number); /** *

    Construct from a {@link GeneArray} and size of the population.

    * *

    This public constructor creates GeneArray(s) as population (size) having shuffled genes which are * came from the initial set of genes (geneArray). It uses {@link std.greater} as default comparison function. *

    * * @param geneArray An initial sequence listing. * @param size The size of population to have as children. */ constructor(geneArray: GeneArray, size: number); /** *

    Constructor from a GeneArray, size of the poluation and custom comparison function.

    * *

    This public constructor creates GeneArray(s) as population (size) having shuffled genes which are * came from the initial set of genes (geneArray). The compare is used for comparison function. *

    * * @param geneArray An initial sequence listing. * @param size The size of population to have as children. * @param compare A comparison function returns whether left gene is more optimal. */ constructor(geneArray: GeneArray, size: number, compare: (left: GeneArray, right: GeneArray) => boolean); _Get_children(): std.Vector; /** * Test fitness of each GeneArray in the {@link population}. * * @return The best GeneArray in the {@link population}. */ fitTest(): GeneArray; /** * @hidden */ private clone(obj); } } declare namespace samchon.library { /** *

    A utility class supporting static methods of string.

    * *

    The {@link StringUtil} utility class is an all-static class with methods for working with string objects within * Samchon Framework. You do not create instances of {@link StringUtil}; instead you call methods such as the * StringUtil.substitute() method.

    * * @reference http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/utils/StringUtil.html * @author Jeongho Nam */ class StringUtil { /** *

    Generate a substring.

    * *

    Extracts a substring consisting of the characters from specified start to end. * It's same with str.substring( ? = (str.find(start) + start.size()), str.find(end, ?) )

    * * let str = between("ABCD[EFGH]IJK", "[", "]"); console.log(str); // PRINTS "EFGH" * * *
      *
    • If start is not specified, extracts from begin of the string to end.
    • *
    • If end is not specified, extracts from start to end of the string.
    • *
    • If start and end are all omitted, returns str, itself.
    • *
    * * @param str Target string to be applied between. * @param start A string for separating substring at the front. * @param end A string for separating substring at the end. * * @return substring by specified terms. */ static between(str: string, start?: string, end?: string): string; /** *

    Fetch substrings.

    * *

    Splits a string into an array of substrings dividing by specified delimeters of start and end. * It's the array of substrings adjusted the between.

    * *
      *
    • If startStr is omitted, it's same with the split by endStr not having last item.
    • *
    • If endStr is omitted, it's same with the split by startStr not having first item.
    • *
    • If startStr and endStar are all omitted, returns str.
    • *
    * * @param str Target string to split by between. * @param start A string for separating substring at the front. * If omitted, it's same with split(end) not having last item. * @param end A string for separating substring at the end. * If omitted, it's same with split(start) not having first item. * @return An array of substrings. */ static betweens(str: string, start?: string, end?: string): Array; /** * An array containing whitespaces. */ private static SPACE_ARRAY; /** * Remove all designated characters from the beginning and end of the specified string. * * @param str The string whose designated characters should be trimmed. * @param args Designated character(s). * * @return Updated string where designated characters was removed from the beginning and end. */ static trim(str: string, ...args: string[]): string; /** * Remove all designated characters from the beginning of the specified string. * * @param str The string should be trimmed. * @param delims Designated character(s). * * @return Updated string where designated characters was removed from the beginning */ static ltrim(str: string, ...args: string[]): string; /** * Remove all designated characters from the end of the specified string. * * @param str The string should be trimmed. * @param delims Designated character(s). * * @return Updated string where designated characters was removed from the end. */ static rtrim(str: string, ...args: string[]): string; /** * Substitute {n} tokens within the specified string. * * @param format The string to make substitutions in. This string can contain special tokens of the form * {n}, where n is a zero based index, that will be replaced with the * additional parameters found at that index if specified. * @param args Additional parameters that can be substituted in the format parameter at each * {n} location, where n is an integer (zero based) index value into * the array of values specified. * * @return New string with all of the {n} tokens replaced with the respective arguments specified. */ static substitute(format: string, ...args: any[]): string; /** * Returns a string specified word is replaced. * * @param str Target string to replace * @param before Specific word you want to be replaced * @param after Specific word you want to replace * * @return A string specified word is replaced */ static replaceAll(str: string, before: string, after: string): string; /** * Returns a string specified words are replaced. * * @param str Target string to replace * @param pairs A specific word's pairs you want to replace and to be replaced * * @return A string specified words are replaced */ static replaceAll(str: string, ...pairs: std.Pair[]): string; /** * Replace all HTML spaces to a literal space. * * @param str Target string to replace. */ static removeHTMLSpaces(str: string): string; /** *

    Repeat a string.

    * *

    Returns a string consisting of a specified string concatenated with itself a specified number of times.

    * * @param str The string to be repeated. * @param n The repeat count. * * @return The repeated string. */ static repeat(str: string, n: number): string; /** *

    Number to formatted string with "," sign.

    * *

    Returns a string converted from the number rounded off from specified precision with "," symbols.

    * * @param val A number wants to convert to string. * @param precision Target precision of round off. * * @return A string who represents the number with roundoff and "," symbols. */ static numberFormat(val: number, precision?: number): string; static percentFormat(val: number, precision?: number): string; } } declare namespace samchon.library { /** *

    URLVariables class is for representing variables of HTTP.

    * *

    URLVariables class allows you to transfer variables between an application and server. * When transfering, URLVariables will be converted to a URI string.

    * *
      *
    • URI: Uniform Resource Identifier
    • *
    * * @reference http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/URLVariables.html * @author Migrated by Jeongho Nam */ class URLVariables extends std.HashMap { /** * Default Constructor. */ constructor(); /** *

    Construct from a URL-encoded string.

    * *

    The {@link decode decode()} method is automatically called to convert the string to properties of the {@link URLVariables} object.

    * * @param str A URL-encoded string containing name/value pairs. */ constructor(str: string); /** * Converts the variable string to properties of the specified URLVariables object. * * @param str A URL-encoded query string containing name/value pairs. */ decode(str: string): void; /** * Returns a string containing all enumerable variables, in the MIME content encoding application/x-www-form-urlencoded. */ toString(): string; } } declare namespace samchon.protocol { /** *

    An interface of entity.

    * *

    Entity is a class for standardization of expression method using on network I/O by XML. If * Invoke is a standard message protocol of Samchon Framework which must be kept, Entity is a * recommended semi-protocol of message for expressing a data class. Following the semi-protocol * Entity is not imposed but encouraged.

    * *

    As we could get advantages from standardization of message for network I/O with Invoke, * we can get additional advantage from standardizing expression method of data class with Entity. * We do not need to know a part of network communication. Thus, with the Entity, we can only * concentrate on entity's own logics and relationships between another entities. Entity does not * need to how network communications are being done.

    * *

    I say repeatedly. Expression method of Entity is recommended, but not imposed. It's a semi * protocol for network I/O but not a essential protocol must be kept. The expression method of * Entity, using on network I/O, is expressed by XML string.

    * *

    If your own network system has a critical performance issue on communication data class, * it would be better to using binary communication (with ByteArray). * Don't worry about the problem! Invoke also provides methods for binary data (ByteArray).

    * * @author Jeongho Nam */ interface IEntity { /** *

    Construct data of the Entity from a XML object.

    * *

    Overrides the construct() method and fetch data of member variables from the XML.

    * *

    By recommended guidance, data representing member variables are contained in properties * of the put XML object.

    * * @param xml An xml used to contruct data of entity. */ construct(xml: library.XML): void; /** *

    Get a key that can identify the Entity uniquely.

    * *

    If identifier of the Entity is not atomic value, returns a paired or tuple object * that can represents the composite identifier.

    * * * class Point extends Entity * { * private x: number; * private y: number; * * public key(): std.Pair * { * return std.make_pair(this.x, this.y); * } * } * */ key(): any; /** *

    A tag name when represented by XML.

    * * */ TAG(): string; /** *

    Get a XML object represents the Entity.

    * *

    A member variable (not object, but atomic value like number, string or date) is categorized * as a property within the framework of entity side. Thus, when overriding a toXML() method and * archiving member variables to an XML object to return, puts each variable to be a property * belongs to only a XML object.

    * *

    Don't archive the member variable of atomic value to XML::value causing enormouse creation * of XML objects to number of member variables. An Entity must be represented by only a XML * instance (tag).

    * *

    Standard Usage.

    * * * * * * * *

    Non-standard usage abusing value.

    * * * jhnam88 * Jeongho Nam * 1988-03-11 * * * master * Administartor * 2011-07-28 * * * * @return An XML object representing the Entity. */ toXML(): library.XML; } /** * @hidden */ namespace IEntity { function construct(entity: IEntity, xml: library.XML, ...prohibited_names: string[]): void; function toXML(entity: IEntity, ...prohibited_names: string[]): library.XML; } /** *

    An entity, a standard data class.

    * *

    Entity is a class for standardization of expression method using on network I/O by XML. If * Invoke is a standard message protocol of Samchon Framework which must be kept, Entity is a * recommended semi-protocol of message for expressing a data class. Following the semi-protocol * Entity is not imposed but encouraged.

    * *

    As we could get advantages from standardization of message for network I/O with Invoke, * we can get additional advantage from standardizing expression method of data class with Entity. * We do not need to know a part of network communication. Thus, with the Entity, we can only * concentrate on entity's own logics and relationships between another entities. Entity does not * need to how network communications are being done.

    * *

    I say repeatedly. Expression method of Entity is recommended, but not imposed. It's a semi * protocol for network I/O but not a essential protocol must be kept. The expression method of * Entity, using on network I/O, is expressed by XML string.

    * *

    If your own network system has a critical performance issue on communication data class, * it would be better to using binary communication (with ByteArray). * Don't worry about the problem! Invoke also provides methods for binary data (ByteArray).

    * * @author Jeongho Nam */ abstract class Entity implements IEntity { /** * Default Constructor. */ constructor(); construct(xml: library.XML): void; /** * @inheritdoc */ key(): any; /** * @inheritdoc */ abstract TAG(): string; /** * @inheritdoc */ toXML(): library.XML; } } declare namespace samchon.protocol { /** *

    An interface taking full charge of network communication.

    * *

    {@link ICommunicator} is an interface for communicator classes who take full charge of network communication * with external system, without reference to whether the external system is a server or a client.

    * *

    Whenever a replied message comes from the external system, the message will be converted to an * {@link Invoke} class and will be shifted to the {@link WebCommunicator.listener listener}'s * {@link IProtocol.replyData replyData()} method.

    * * interface ICommmunicator { private socket: SomeSocketClass; // LISTENER LISTENS INVOKE MESSAGE BY IT'S IProtocol.replyData() METHOD protected listener: IProtocol; // YOU CAN DETECT DISCONNECTION BY ENROLLING FUNCTION POINTER TO HERE. public onClose: Function; public sendData(invoke: Invoke): void { this.socket.write(invoke); } public replyData(invoke: Invoke): void { // WHENEVER COMMUNICATOR GETS MESSAGE, THEN SHIFT IT TO LISTENER'S replyData() METHOD. this.listener.replyData(invoke); } } * * *

    * *

    * * *

    Basic Components

    *

    What Basic Components are

    *

    Basic Components are the smallest unit of network communication in this Samchon Framework. With * Basic Components, you can construct any type of network system, even how the network system is enormously * scaled and complicated, by just combinating the Basic Components.

    * *

    All the system templates in this framework are also being implemented by utilization of the * Basic Compoonents.

    * *
      *
    • {@link service Service} *
    • {@link external External System} *
    • {@link parallel Parallel System} *
    • {@link distributed Distributed System} *
    * *

    Note that, whatever the network system what you've to construct is, just concentrate on role of each system * and attach matched Basic Components to the role, within framework of the Object-Oriented Design. * Then construction of the network system will be much easier.

    * *
      *
    • A system is a server, then use {@link IServer} or {@link IServerBase}.
    • *
    • A server wants to handle a client has connected, then use {@link IClientDriver}.
    • *
    • A system is a client connecting to an external server, then use {@link IServerConnector}.
    • *
    • *
    * *

    Example - System Templates

    *

    Learning and understanding Basic Components of Samchon Framework, reading source codes and design of * System Templates' modules will be very helpful.

    * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
    Name Source API Documents
    Cloud Service protocol/service {@link protocol.service}
    External System protocol/external {@link protocol.external}
    Parallel System protocol/parallel {@link protocol.parallel}
    Distributed System protocol/distributed {@link protocol.distributed}
    Slave System protocol/slave {@link protocol.slave}
    * *

    Example - Projects

    * * * @see {@link IClientDriver}, {@link IServerConnector} * @handbook Basic Components - ICommunicator * @author Jeongho Nam */ interface ICommunicator extends IProtocol { /** * Callback function for connection closed. */ onClose: Function; /** * Close connection. */ close(): void; isConnected(): boolean; sendData(invoke: protocol.Invoke): void; replyData(invoke: protocol.Invoke): void; } } declare namespace samchon.protocol { abstract class CommunicatorBase implements ICommunicator { /** * @hidden */ protected listener_: IProtocol; /** * @inheritdoc */ onClose: Function; protected connected_: boolean; /** * @hidden */ private binary_invoke_; /** * @hidden */ private binary_parameters_; /** * @hidden */ private unhandled_invokes; /** * Default Constructor. */ constructor(); /** * Construct from listener. * * @param listener An {@link IProtocol} object to listen {@link Invoke} messages. */ constructor(listener: IProtocol); /** * @inheritdoc */ abstract close(): void; /** * @inheritdoc */ isConnected(): boolean; protected is_binary_invoke(): boolean; abstract sendData(invoke: Invoke): void; replyData(invoke: Invoke): void; protected handle_string(str: string): void; protected handle_binary(binary: Uint8Array): void; } } declare namespace samchon.protocol { abstract class Communicator extends CommunicatorBase { /** * @hidden */ protected socket_: socket.socket; /** * @hidden */ private header_bytes_; /** * @hidden */ private data_; /** * @hidden */ private data_index_; /** * @hidden */ private listening_; /** * @inheritdoc */ close(): void; /** * @hidden */ protected start_listen(): void; /** * @hidden */ private handle_error(); /** * @hidden */ private handle_close(); /** * @inheritdoc */ sendData(invoke: Invoke): void; /** * @hidden */ private listen_piece(piece); /** * @hidden */ private listen_header(piece, piece_index); /** * @hidden */ private listen_data(piece, piece_index); } } declare namespace samchon.protocol { /** *

    Base class for web-communicator, {@link WebClientDriver} and {@link WebServerConnector}.

    * *

    This class {@link WebCommunicatorBase} subrogates network communication for web-communicator classes, * {@link WebClinetDriver} and {@link WebServerConnector}. The web-communicator and this class * {@link WebCommunicatorBase} share same interface {@link IProtocol} and have a chain of responsibily * relationship.

    * *

    When an {@link Invoke} message was delivered from the connected remote system, then this class calls * web-communicator's {@link WebServerConnector.replyData replyData()} method. Also, when called web-communicator's * {@link WebClientDriver.sendData sendData()}, then {@link sendData sendData()} of this class will be caleed.

    * *
      *
    • this.replyData() -> communicator.replyData()
    • *
    • communicator.sendData() -> this.sendData()
    • *
    * * @author Jeongho Nam */ abstract class WebCommunicator extends CommunicatorBase { /** * Connection driver, a socket for web-socket. */ protected connection_: websocket.connection; /** * Close the connection. */ close(): void; /** * @inheritdoc */ sendData(invoke: Invoke): void; /** *

    Handle raw-data received from the remote system.

    * *

    Queries raw-data received from the remote system. When the raw-data represents an formal {@link Invoke} * message, then it will be sent to the {@link replyData}.

    * * @param message A raw-data received from the remote system. */ protected handle_message(message: websocket.IMessage): void; protected handle_close(): void; } } declare namespace samchon.protocol { abstract class SharedWorkerCommunicator extends CommunicatorBase { protected port_: MessagePort; close(): void; /** * @inheritdoc */ sendData(invoke: Invoke): void; protected handle_message(event: MessageEvent): void; } } declare namespace samchon.protocol { /** *

    An interface for communicator with connected client.

    * *

    {@link IClientDriver} is a type of {@link ICommunicator}, specified for communication with connected client * in a server. It takes full charge of network communication with the connected client.

    * *

    {@link IClientDriver} is created in {@link IServer} and delivered via * {@link IServer.addClient IServer.addClient()}. Those are derived types from this {@link IClientDriver}, being * created by matched {@link IServer} object.

    * * * * * * * * * * * * * * * * * * *
    Derived Type Created By
    {@link ClientDrvier} {@link Server}
    {@link WebClientDrvier} {@link WebServer}
    {@link SharedWorkerClientDrvier} {@link SharedWorkerServer}
    * *

    * *

    * *

    When you've got an {@link IClientDriver} object from the {@link IServer.addClient IServer.addClient()}, then * specify {@link CommunicatorBase.listener listener} with {@link IClient.listen IClient.listen()}. Below codes are * an example specifying and managing the {@link CommunicatorBase.listener listener} objects.

    * * /// /// // IMPORTS import std = require("typescript-stl"); import samchon = require("samchon-framework"); // SHORTCUTS import library = samchon.library; import protocol = samchon.protocol; class CalculatorServer extends protocol.Server { private clients: std.HashSet; // WHEN A CLIENT HAS CONNECTED public addClient(driver: IClientDriver): void { let client: CalculatorClient = new CalculatorClient(this, driver); this.clients.insert(client); } } class CalculatorClient extends protocol.IProtocol { // PARENT SERVER INSTANCE private server: CalculatorServer; // COMMUNICATOR, SENDS AND RECEIVES NETWORK MESSAGE WITH CONNECTED CLIENT private driver: protocol.IClientDriver; ///// // CONSTRUCTORS ///// public constructor(server: CalculatorServer, driver: protocol.IClientDriver) { this.server = server; this.driver = driver; // START LISTENING AND RESPOND CLOSING EVENT this.driver.listen(this); // INVOKE MESSAGE WILL COME TO HERE this.driver.onClose = this.destructor.bind(this); // DISCONNECTED HANDLER } public destructor(): void { // WHEN DISCONNECTED, THEN ERASE THIS OBJECT FROM CalculatorServer.clients. this.server["clients"].erase(this); } ///// // INVOKE MESSAGE CHAIN ///// public sendData(invoke: protocol.Invoke): void { // CALL ICommunicator.sendData(), WHO PHYSICALLY SEND NETWORK MESSAGE this.driver.sendData(invoke); } public replyData(invoke: protocol.Invoke): void { // FIND MATCHED MEMBER FUNCTION NAMED EQUAL TO THE invoke.getListener() invoke.apply(this); } } * * * *

    Basic Components

    *

    What Basic Components are

    *

    Basic Components are the smallest unit of network communication in this Samchon Framework. With * Basic Components, you can construct any type of network system, even how the network system is enormously * scaled and complicated, by just combinating the Basic Components.

    * *

    All the system templates in this framework are also being implemented by utilization of the * Basic Compoonents.

    * *
      *
    • {@link service Service} *
    • {@link external External System} *
    • {@link parallel Parallel System} *
    • {@link distributed Distributed System} *
    * *

    Note that, whatever the network system what you've to construct is, just concentrate on role of each system * and attach matched Basic Components to the role, within framework of the Object-Oriented Design. * Then construction of the network system will be much easier.

    * *
      *
    • A system is a server, then use {@link IServer} or {@link IServerBase}.
    • *
    • A server wants to handle a client has connected, then use {@link IClientDriver}.
    • *
    • A system is a client connecting to an external server, then use {@link IServerConnector}.
    • *
    • *
    * *

    Example - System Templates

    *

    Learning and understanding Basic Components of Samchon Framework, reading source codes and design of * System Templates' modules will be very helpful.

    * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
    Name Source API Documents
    Cloud Service protocol/service {@link protocol.service}
    External System protocol/external {@link protocol.external}
    Parallel System protocol/parallel {@link protocol.parallel}
    Distributed System protocol/distributed {@link protocol.distributed}
    Slave System protocol/slave {@link protocol.slave}
    * *

    Example - Projects

    * * * @see {@link IServer} * @handbook Basic Components - IClientDriver * @author Jeongho Nam */ interface IClientDriver extends ICommunicator { /** *

    Listen message from the newly connected client.

    * *

    Starts listening message from the newly connected client. Replied message from the connected client will * be converted to {@link Invoke} classes and shifted to the listener's * {@link IProtocol.replyData replyData()} method.

    * * @param listener A listener object to listen replied message from newly connected client in * {@link IProtocol.replyData replyData()} as an {@link Invoke} message. */ listen(listener: IProtocol): void; } } declare namespace samchon.protocol { class ClientDriver extends Communicator implements IClientDriver { constructor(socket: socket.socket); /** * @inheritdoc */ listen(listener: IProtocol): void; } } declare namespace samchon.protocol { class WebClientDriver extends WebCommunicator implements IClientDriver { /** * Requested path. */ private path_; /** * Session ID, an identifier of the remote client. */ private session_id_; private listening_; /** * Initialization Constructor. * * @param connection Connection driver, a socket for web-socket. * @param path Requested path. * @param session_id Session ID, an identifier of the remote client. */ constructor(connection: websocket.connection, path: string, session_id: string); /** * @inheritdoc */ listen(listener: IProtocol): void; /** * Get requested path. */ getPath(): string; /** * Get session ID, an identifier of the remote client. */ getSessionID(): string; } } declare namespace samchon.protocol { class SharedWorkerClientDriver extends SharedWorkerCommunicator implements IClientDriver { private listening; constructor(port: MessagePort); /** * @inheritdoc */ listen(listener: IProtocol): void; } } declare namespace samchon.protocol { abstract class DedicatedWorker implements IProtocol { private communicator_; /** * Default Constructor. */ constructor(); abstract replyData(invoke: protocol.Invoke): void; sendData(invoke: Invoke): void; } } declare namespace samchon.protocol { class DedicatedWorkerConnector extends CommunicatorBase implements IServerConnector { private worker; /** * @inheritdoc */ onConnect: Function; /** * @inheritdoc */ onClose: Function; constructor(listener: IProtocol); /** * @inheritdoc */ connect(jsFile: string): void; /** * @inheritdoc */ close(): void; sendData(invoke: Invoke): void; replyData(invoke: Invoke): void; private handle_message(event); } } declare namespace samchon.protocol { /** * A container of entity, and it's a type of entity, too. * * @author Jeongho Nam */ interface IEntityGroup extends IEntity, std.base.IContainer { /** *

    Construct data of the Entity from an XML object.

    * *

    Constructs the EntityArray's own member variables only from the input XML object.

    * *

    Do not consider about constructing children Entity objects' data in EntityArray::construct(). * Those children Entity objects' data will constructed by their own construct() method. Even insertion * of XML objects representing children are done by abstract method of EntityArray::toXML().

    * *

    Constructs only data of EntityArray's own.

    */ construct(xml: library.XML): void; /** *

    Factory method of a child Entity.

    * *

    EntityArray::createChild() is a factory method creating a new child Entity which is belonged * to the EntityArray. This method is called by EntityArray::construct(). The children construction * methods Entity::construct() will be called by abstract method of the EntityArray::construct().

    * * @return A new child Entity belongs to EntityArray. */ createChild(xml: library.XML): T; /** *

    Get iterator to element.

    * *

    Searches the container for an element with a identifier equivalent to key and returns an * iterator to it if found, otherwise it returns an iterator to {@link end end()}.

    * *

    Two keys are considered equivalent if the container's comparison object returns false reflexively * (i.e., no matter the order in which the elements are passed as arguments).

    * *

    Another member functions, {@link has has()} and {@link count count()}, can be used to just check * whether a particular key exists.

    * * @param key Key to be searched for * @return An iterator to the element, if an element with specified key is found, or * {@link end end()} otherwise. */ /** *

    Whether have the item or not.

    * *

    Indicates whether a map has an item having the specified identifier.

    * * @param key Key value of the element whose mapped value is accessed. * * @return Whether the map has an item having the specified identifier. */ has(key: any): boolean; /** *

    Count elements with a specific key.

    * *

    Searches the container for elements whose key is key and returns the number of elements found.

    * * @param key Key value to be searched for. * * @return The number of elements in the container with a key. */ count(key: any): number; /** *

    Get an element

    * *

    Returns a reference to the mapped value of the element identified with key.

    * * @param key Key value of the element whose mapped value is accessed. * * @throw exception out of range * * @return A reference object of the mapped value (_Ty) */ get(key: any): T; /** *

    A tag name of children objects.

    */ CHILD_TAG(): string; /** *

    Get an XML object represents the EntityArray.

    * *

    Archives the EntityArray's own member variables only to the returned XML object.

    * *

    Do not consider about archiving children Entity objects' data in EntityArray::toXML(). * Those children Entity objects will converted to XML object by their own toXML() method. The * insertion of XML objects representing children are done by abstract method of * EntityArray::toXML().

    * *

    Archives only data of EntityArray's own.

    */ toXML(): library.XML; } /** * @hidden */ namespace IEntityGroup { /** * @hidden */ function construct(entityGroup: IEntityGroup, xml: library.XML, ...prohibited_names: string[]): void; /** * @hidden */ function toXML(entityGroup: IEntityGroup, ...prohibited_names: string[]): library.XML; function has(entityGroup: IEntityGroup, key: any): boolean; function count(entityGroup: IEntityGroup, key: any): number; function get(entityGroup: IEntityGroup, key: any): T; } } declare namespace samchon.protocol { /** * @inheritdoc */ abstract class EntityArray extends std.Vector implements IEntityGroup { /** * @inheritdoc */ construct(xml: library.XML): void; /** * @inheritdoc */ abstract createChild(xml: library.XML): T; /** * @inheritdoc */ key(): any; /** * @inheritdoc */ has(key: any): boolean; /** * @inheritdoc */ count(key: any): number; /** * @inheritdoc */ get(key: any): T; /** * @inheritdoc */ abstract TAG(): string; /** * @inheritdoc */ abstract CHILD_TAG(): string; /** * @inheritdoc */ toXML(): library.XML; } } declare namespace samchon.protocol { /** * @inheritdoc */ abstract class EntityList extends std.List implements IEntityGroup { /** * @inheritdoc */ construct(xml: library.XML): void; /** * @inheritdoc */ abstract createChild(xml: library.XML): T; /** * @inheritdoc */ key(): any; /** * @inheritdoc */ has(key: any): boolean; /** * @inheritdoc */ count(key: any): number; /** * @inheritdoc */ get(key: any): T; /** * @inheritdoc */ abstract TAG(): string; /** * @inheritdoc */ abstract CHILD_TAG(): string; /** * @inheritdoc */ toXML(): library.XML; } } declare namespace samchon.protocol { /** * @inheritdoc */ abstract class EntityDeque extends std.Deque implements IEntityGroup { /** * @inheritdoc */ construct(xml: library.XML): void; /** * @inheritdoc */ abstract createChild(xml: library.XML): T; /** * @inheritdoc */ key(): any; /** * @inheritdoc */ has(key: any): boolean; /** * @inheritdoc */ count(key: any): number; /** * @inheritdoc */ get(key: any): T; /** * @inheritdoc */ abstract TAG(): string; /** * @inheritdoc */ abstract CHILD_TAG(): string; /** * @inheritdoc */ toXML(): library.XML; } } declare namespace samchon.protocol { /** * @inheritdoc */ interface IEntityCollection extends IEntityGroup, collection.ICollection { } } declare namespace samchon.protocol { /** * @inheritdoc */ abstract class EntityArrayCollection extends collection.ArrayCollection implements IEntityCollection { /** * @inheritdoc */ construct(xml: library.XML): void; /** * @inheritdoc */ abstract createChild(xml: library.XML): T; /** * @inheritdoc */ key(): any; /** * @inheritdoc */ has(key: any): boolean; /** * @inheritdoc */ count(key: any): number; /** * @inheritdoc */ get(key: any): T; /** * @inheritdoc */ abstract TAG(): string; /** * @inheritdoc */ abstract CHILD_TAG(): string; /** * @inheritdoc */ toXML(): library.XML; } } declare namespace samchon.protocol { /** * @inheritdoc */ abstract class EntityListCollection extends collection.ListCollection implements IEntityCollection { /** * @inheritdoc */ construct(xml: library.XML): void; /** * @inheritdoc */ abstract createChild(xml: library.XML): T; /** * @inheritdoc */ key(): any; /** * @inheritdoc */ has(key: any): boolean; /** * @inheritdoc */ count(key: any): number; /** * @inheritdoc */ get(key: any): T; /** * @inheritdoc */ abstract TAG(): string; /** * @inheritdoc */ abstract CHILD_TAG(): string; /** * @inheritdoc */ toXML(): library.XML; } } declare namespace samchon.protocol { /** * @inheritdoc */ abstract class EntityDequeCollection extends collection.DequeCollection implements IEntityCollection { /** * @inheritdoc */ construct(xml: library.XML): void; /** * @inheritdoc */ abstract createChild(xml: library.XML): T; /** * @inheritdoc */ key(): any; /** * @inheritdoc */ has(key: any): boolean; /** * @inheritdoc */ count(key: any): number; /** * @inheritdoc */ get(key: any): T; /** * @inheritdoc */ abstract TAG(): string; /** * @inheritdoc */ abstract CHILD_TAG(): string; /** * @inheritdoc */ toXML(): library.XML; } } declare namespace samchon.protocol { /** *

    An interface for {@link Invoke} message chain.

    * *

    {@link IProtocol} is an interface for {@link Invoke} message, which is standard message of network I/O in * Samchon Framework, chain. The {@link IProtocol} interface is used to network drivers and some classes * which are in a relationship of Chain of Responsibility Pattern with those network drivers.

    * *

    Implements {@link IProtocol} if the class sends and handles {@link Invoke} message. Looking around source * codes of Samchon Framework, especially System Templates, you can find out that all the classes and * modules handling {@link Invoke} messages are always implementing this {@link IProtocol} . Yes, {@link IProtocol}, * this is the main role you've to follow in this Samchon Framework.

    * *

    * *

    * * *

    Utilization Case

    *

    Below pseudo code and class diagram represents {@link service Service Module}, who can build a cloud server. * All the classes in the pseudo code are implementing the {@link IProtocol} because all of them are handling * {@link Invoke} message.

    * *
      *
    • Server: Represents a server literally
    • *
    • User: Represents an user being identified by its session id. User contains multiple Client objects.
    • *
        *
      • In browser, an user can open multiple windows. *
          *
        • User: A browser (like IE, Chrome and Safari). *
        • Client: An internet browser window *
        *
      • *
      *
    • Client: Represents a browser window and it takes role of network communication with it.
    • *
    • Service: Represents a service, domain logic.
    • *
    * *

    * *

    * * /// /// // IMPORTS import std = require("typescript-stl"); import samchon = require("samchon-framework"); // SHORTCUTS import library = samchon.library; import collection = samchon.collection; import protocol = samchon.protocol; namespace service { export class Server extends protocol.WebServer implements IProtocol { // SERVER HAS MULTIPLE USER OBJECTS private session_map: std.HashMap; //------------------------ // MESSAGE CHAIN //------------------------ public sendData(invoke: protocol.Invoke): void { // SEND INVOKE MESSAGE TO ALL USER OBJECTS for (let it = this.session_map.begin(); !it.equal_to(this.session_map.end()); it = it.next()) it.second.sendData(invoke); } public replyData(invoke: protocol.Invoke): void { invoke.apply(this); // HANDLE INVOKE MESSAGE BY ITSELF } } export class User extends collection.HashMapCollection // USER HAS MULTIPLE CLIENT OBJECTS implements IProtocol { private server: Server; // USER REFRES SERVER //------------------------ // MESSAGE CHAIN //------------------------ public sendData(invoke: protocol.Invoke): void { // SEND INVOKE MESSAGE TO ALL CLIENT OBJECTS for (let it = this.begin(); !it.equal_to(this.end()); it = it.next()) it.second.sendData(invoke); } public replyData(invoke: protocol.Invoke): void { invoke.apply(this); // HANDLE INOVKE MESSAGE BY ITSELF this.server.replyData(invoke); // OR VIA SERVER } } export class Client implements IProtocol { private user: User; // CLIENT REFERS USER private service: Service; // CLIENT HAS A SERVICE OBJECT private driver: WebClientDriver; //------------------------ // MESSAGE CHAIN //------------------------ public sendData(invoke: protocol.Invoke): void { // SEND INVOKE MESSAGE VIA driver: WebClientDriver this.driver.sendData(invoke); } public replyData(invoke: protocol.Invoke): void { invoke.apply(this); // HANDLE INOVKE MEESAGE BY ITSELF this.user.replyData(invoke); // OR VIA USER if (this.service != null) // OR VIA SERVICE this.service.replyData(invoke); } } export class Service implements IProtocol { private client: Client; // SERVICE REFRES CLIENT //------------------------ // MESSAGE CHAIN //------------------------ public sendData(invoke: protocol.Invoke): void { // SEND INVOKE MESSAGE VIA CLIENT return this.client.sendData(invoke); } public replyData(invoke: protocol.Invoke): void { invoke.apply(this); // HANDLE INVOKE MESSAGE BY ITSELF } } } * * * *

    Basic Components

    *

    What Basic Components are

    *

    Basic Components are the smallest unit of network communication in this Samchon Framework. With * Basic Components, you can construct any type of network system, even how the network system is enormously * scaled and complicated, by just combinating the Basic Components.

    * *

    All the system templates in this framework are also being implemented by utilization of the * Basic Compoonents.

    * *
      *
    • {@link service Service} *
    • {@link external External System} *
    • {@link parallel Parallel System} *
    • {@link distributed Distributed System} *
    * *

    Note that, whatever the network system what you've to construct is, just concentrate on role of each system * and attach matched Basic Components to the role, within framework of the Object-Oriented Design. * Then construction of the network system will be much easier.

    * *
      *
    • A system is a server, then use {@link IServer} or {@link IServerBase}.
    • *
    • A server wants to handle a client has connected, then use {@link IClientDriver}.
    • *
    • A system is a client connecting to an external server, then use {@link IServerConnector}.
    • *
    • *
    * *

    Example - System Templates

    *

    Learning and understanding Basic Components of Samchon Framework, reading source codes and design of * System Templates' modules will be very helpful.

    * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
    Name Source API Documents
    Cloud Service protocol/service {@link protocol.service}
    External System protocol/external {@link protocol.external}
    Parallel System protocol/parallel {@link protocol.parallel}
    Distributed System protocol/distributed {@link protocol.distributed}
    Slave System protocol/slave {@link protocol.slave}
    * *

    Example - Projects

    * * * @see {@link Invoke} * @handbook Basic Components - IProtocol * @author Jeongho Nam */ interface IProtocol { /** *

    Sending message.

    *

    Sends message to related system or shifts the responsibility to chain.

    * * @param invoke Invoke message to send */ replyData(invoke: Invoke): void; /** *

    Handling replied message.

    *

    Handles replied message or shifts the responsibility to chain.

    * * @param invoke An {@link Invoke} message has received. */ sendData(invoke: Invoke): void; } } declare namespace samchon.protocol { /** *

    Standard message of network I/O.

    * *

    {@link Invoke} is a class used in network I/O in protocol package of Samchon Framework.

    * *

    The Invoke message has an XML structure like the result screen of provided example in below. * We can enjoy lots of benefits by the normalized and standardized message structure used in * network I/O.

    * *

    The greatest advantage is that we can make any type of network system, even how the system * is enourmously complicated. As network communication message is standardized, we only need to * concentrate on logical relationships between network systems. We can handle each network system * like a object (class) in OOD. And those relationships can be easily designed by using design * pattern.

    * *

    In Samchon Framework, you can make any type of network system with basic componenets * (IProtocol, IServer and ICommunicator) by implemens or inherits them, like designing * classes of S/W architecture.

    * * @see IProtocol * @author Jeongho Nam */ class Invoke extends EntityArray { /** *

    Listener, represent function's name.

    */ private listener; /** * Default Constructor. */ constructor(); constructor(listener: string); /** * Copy Constructor. * * @param invoke */ constructor(invoke: Invoke); /** * Construct from listener and parametric values. * * @param listener * @param parameters */ constructor(listener: string, ...parameters: Array); /** * @inheritdoc */ createChild(xml: library.XML): InvokeParameter; /** * Get listener. */ getListener(): string; /** *

    Get arguments for Function.apply().

    * * @return An array containing values of the contained parameters. */ getArguments(): Array; /** *

    Apply to a matched function.

    */ apply(obj: IProtocol): boolean; /** * @inheritdoc */ TAG(): string; /** * @inheritdoc */ CHILD_TAG(): string; } } declare namespace samchon.protocol { /** * A parameter belongs to an Invoke. * * @author Jeongho Nam */ class InvokeParameter extends Entity { /** *

    Name of the parameter.

    * * @details Optional property, can be omitted. */ protected name: string; /** *

    Type of the parameter.

    */ protected type: string; /** *

    Value of the parameter.

    */ protected value: string | number | library.XML | Uint8Array; /** * Default Constructor. */ constructor(); constructor(val: number); constructor(val: string); constructor(val: library.XML); constructor(val: Uint8Array); /** * Construct from variable name and number value. * * @param name * @param val */ constructor(name: string, val: number); constructor(name: string, val: string); constructor(name: string, val: library.XML); constructor(name: string, val: Uint8Array); /** * @inheritdoc */ construct(xml: library.XML): void; setValue(value: number): void; setValue(value: string): void; setValue(value: library.XML): void; setValue(value: Uint8Array): void; /** * @inheritdoc */ key(): any; /** * Get name. */ getName(): string; /** * Get type. */ getType(): string; /** * Get value. */ getValue(): any; /** * @inheritdoc */ TAG(): string; /** * @inheritdoc */ toXML(): library.XML; } } declare namespace samchon.protocol { class InvokeHistory extends Entity { /** * */ private uid; /** * @see {@link Invoke.listener} */ private listener; /** * */ private start_time_; /** * */ private end_time_; /** * Default Constructor. */ constructor(); constructor(invoke: Invoke); construct(xml: library.XML): void; complete(): void; key(): number; getUID(): number; getListener(): string; getStartTime(): Date; getEndTime(): Date; computeElapsedTime(): number; /** * @inheritdoc */ TAG(): string; /** * @inheritdoc */ toXML(): library.XML; toInvoke(): Invoke; } } declare namespace samchon.protocol { /** *

    An interface for a physical server.

    * *

    {@link IServer} provides methods for opening a server. Extends one of them who are derived from this * {@link IServer} and open the server with method {@link open IServer.open()}. Override * {@link addClient IServer.addClient()} who accepts a newly connected client with {@link IClientDriver}. * If you're embarrased because your class already extended another one, then use {@link IServerBase}.

    * *
      *
    • {@link Server}
    • *
    • {@link WebServer}
    • *
    • {@link SharedWorkerServer}
    • *
    * *

    * *

    * *

    Basic Components

    *

    What Basic Components are

    *

    Basic Components are the smallest unit of network communication in this Samchon Framework. With * Basic Components, you can construct any type of network system, even how the network system is enormously * scaled and complicated, by just combinating the Basic Components.

    * *

    All the system templates in this framework are also being implemented by utilization of the * Basic Compoonents.

    * *
      *
    • {@link service Service} *
    • {@link external External System} *
    • {@link parallel Parallel System} *
    • {@link distributed Distributed System} *
    * *

    Note that, whatever the network system what you've to construct is, just concentrate on role of each system * and attach matched Basic Components to the role, within framework of the Object-Oriented Design. * Then construction of the network system will be much easier.

    * *
      *
    • A system is a server, then use {@link IServer} or {@link IServerBase}.
    • *
    • A server wants to handle a client has connected, then use {@link IClientDriver}.
    • *
    • A system is a client connecting to an external server, then use {@link IServerConnector}.
    • *
    • *
    * *

    Example - System Templates

    *

    Learning and understanding Basic Components of Samchon Framework, reading source codes and design of * System Templates' modules will be very helpful.

    * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
    Name Source API Documents
    Cloud Service protocol/service {@link protocol.service}
    External System protocol/external {@link protocol.external}
    Parallel System protocol/parallel {@link protocol.parallel}
    Distributed System protocol/distributed {@link protocol.distributed}
    Slave System protocol/slave {@link protocol.slave}
    * *

    Example - Projects

    * * * @see {@link IClientDriver} * @handbook Basic Components - IServer * @author Jeongho Nam */ interface IServer { open(port: number): void; close(): void; addClient(clientDriver: IClientDriver): void; } } declare namespace samchon.protocol { abstract class Server implements IServer { private server; /** * @inheritdoc */ abstract addClient(driver: ClientDriver): void; /** * @inheritdoc */ open(port: number): void; /** * @inheritdoc */ close(): void; private handle_connect(socket); } } declare namespace samchon.protocol { abstract class WebServer implements IServer { /** * A server handler. */ private http_server_; /** * Sequence number for issuing session id. */ private sequence_; /** * @hidden */ private my_port_; /** * Default Constructor. */ constructor(); /** * @inheritdoc */ open(port: number): void; /** * @inheritdoc */ close(): void; /** * @inheritdoc */ abstract addClient(driver: WebClientDriver): void; /** *

    Handle request from a client system.

    * *

    This method {@link handle_request} will be called when a client is connected. It will call an abstract * method method {@link addClient addClient()} who handles an accepted client. If the newly connected client * doesn't have its own session id, then a new session id will be issued.

    * * @param request Requested header. */ private handle_request(request); /** *

    Get session id from a newly connected.

    * *

    Queries ordinary session id from cookies of a newly connected client. If the client has not, a new * session id will be issued.

    * * @param cookies Cookies from the remote client. */ private get_session_id(cookies); /** * Issue a new session id. */ private issue_session_id(); } } declare namespace samchon.protocol { abstract class SharedWorkerServer implements IServer { /** * @inheritdoc */ abstract addClient(driver: SharedWorkerClientDriver): void; /** * @inheritdoc */ open(): void; /** * @inheritdoc */ close(): void; private handle_connect(event); } } declare namespace samchon.protocol { /** *

    An interface for substitute server classes.

    * *

    {@link IServerBase} is an interface for substitue server classes who subrogate server's role.

    * *

    The easiest way to defining a server class is to extending one of them, who are derived from the * {@link IServer}.

    * *
      *
    • {@link Server}
    • *
    • {@link WebServer}
    • *
    • {@link SharedWorkerServer}
    • *
    * *

    However, it is impossible (that is, if the class is already extending another class), you can instead implement * the {@link IServer} interface, create an {@link IServerBase} member, and write simple hooks to route calls into the * aggregated {@link IServerBase}.

    * *

    {@link ExternalClientArray} can be a good example using this {@link IServerBase}.

    *
      *
    • https://github.com/samchon/framework/blob/master/ts/src/samchon/protocol/external/ExternalClientArray.ts
    • *
    * * class MyServer extends Something implements IServer { private server_base: IServerBase = new WebServerBase(this); public addClient(driver: IClientDriver): void { // WHAT TO DO WHEN A CLIENT HAS CONNECTED } public open(port: number): void { this.server_base.open(); } public close(): void { this.server_base.close(); } } * * * @see {@link IServer} * @handbook Basic Components - IServerBase * @author Jeongho Nam */ interface IServerBase extends IServer { } } declare namespace samchon.protocol { /** *

    A substitute {@link Server}.

    * *

    {@link ServerBase} is a substitute class who subrogates {@link Server}'s responsibility.

    * *

    The easiest way to defning a server class following normal protocol of Samchon Framework is to extending * {@link Server}. However, it is impossible (that is, if the class is already extending another class), you can * instead implement the {@link IServer} interface, create a {@link ServerBase} member, and write simple hooks * to route calls into the aggregated {@link ServerBase}.

    * *

    {@link ExternalClientArray} can be a good example using this {@link IServerBase}.

    *
      *
    • https://github.com/samchon/framework/blob/master/ts/src/samchon/protocol/external/ExternalClientArray.ts
    • *
    * * class MyServer extends Something implements IServer { private server_base: ServerBase = new ServerBase(this); public addClient(driver: ClientDriver): void { // WHAT TO DO WHEN A CLIENT HAS CONNECTED } public open(port: number): void { this.server_base.open(); } public close(): void { this.server_base.close(); } } * * * @author Jeongho Nam */ class ServerBase extends Server implements IServerBase { private target_; constructor(target: IServer); addClient(driver: IClientDriver): void; } } declare namespace samchon.protocol { /** *

    A substitute {@link WebServer}.

    * *

    {@link WebServerBase} is a substitute class who subrogates {@link WebServer}'s responsibility.

    * *

    The easiest way to defning a server class following normal protocol of Samchon Framework is to extending * {@link WebServer}. However, it is impossible (that is, if the class is already extending another class), you can * instead implement the {@link IServer} interface, create a {@link WebServerBase} member, and write simple hooks to * route calls into the aggregated {@link WebServerBase}.

    * *

    {@link ExternalClientArray} can be a good example using this {@link IServerBase}.

    *
      *
    • https://github.com/samchon/framework/blob/master/ts/src/samchon/protocol/external/ExternalClientArray.ts
    • *
    * * class MyServer extends Something implements IServer { private server_base: WebServerBase = new WebServerBase(this); public addClient(driver: WebClientDriver): void { // WHAT TO DO WHEN A CLIENT HAS CONNECTED } public open(port: number): void { this.server_base.open(); } public close(): void { this.server_base.close(); } } * * * @author Jeongho Nam */ class WebServerBase extends WebServer implements IServerBase { private target_; constructor(target: IServer); addClient(driver: IClientDriver): void; } } declare namespace samchon.protocol { /** *

    A substitute {@link SharedWorkerServer}.

    * *

    {@link SharedWorkerServerBase} is a substitute class who subrogates {@link SharedWorkerServer}'s * responsibility.

    * *

    The easiest way to defning a server class following normal protocol of Samchon Framework is to extending * {@link SharedWorkerServer}. However, it is impossible (that is, if the class is already extending another class), * you can instead implement the {@link IServer} interface, create a {@link SharedWorkerServerBase} member, and write * simple hooks to route calls into the aggregated {@link SharedWorkerServerBase}.

    * *

    {@link ExternalClientArray} can be a good example using this {@link IServerBase}.

    *
      *
    • https://github.com/samchon/framework/blob/master/ts/src/samchon/protocol/external/ExternalClientArray.ts
    • *
    * * class MyServer extends Something implements IServer { private server_base: SharedWorkerServerBase = new SharedWorkerServerBase(this); public addClient(driver: SharedWorkerClientDriver): void { // WHAT TO DO WHEN A CLIENT HAS CONNECTED } public open(port: number): void { this.server_base.open(); } public close(): void { this.server_base.close(); } } * * * @author Jeongho Nam */ class SharedWorkerServerBase extends SharedWorkerServer implements IServerBase { private target_; constructor(target: IServer); addClient(driver: IClientDriver): void; } } declare namespace samchon.protocol { /** *

    An interface for server connector.

    * *

    {@link IServerConnector} is an interface for server connector classes who ca connect to an external server * as a client.

    * *

    Of course, {@link IServerConnector} is extended from the {@link ICommunicator}, thus, it also takes full * charge of network communication and delivers replied message to {@link WebCommunicator.listener listener}'s * {@link IProtocol.replyData replyData()} method.

    * * @handbook Basic Components - IServerConnector * @author Jeongho Nam */ interface IServerConnector extends ICommunicator { /** * Callback function for connection completed. */ onConnect: Function; /** *

    Connect to a server.

    * *

    Connects to a server with specified host address and port number. After the connection has * succeeded, callback function {@link onConnect} is called. Listening data from the connected server also begins. * Replied messages from the connected server will be converted to {@link Invoke} classes and will be shifted to * the {@link WebCommunicator.listener listener}'s {@link IProtocol.replyData replyData()} method.

    * *

    If the connection fails immediately, either an event is dispatched or an exception is thrown: an error * event is dispatched if a host was specified, and an exception is thrown if no host was specified. Otherwise, * the status of the connection is reported by an event. If the socket is already connected, the existing * connection is closed first.

    * * @param ip The name or IP address of the host to connect to. * If no host is specified, the host that is contacted is the host where the calling file resides. * If you do not specify a host, use an event listener to determine whether the connection was * successful. * @param port The port number to connect to. */ connect(ip: string, port: number): void; } } declare namespace samchon.protocol { class ServerConnector extends Communicator implements IServerConnector { /** * @inheritdoc */ onConnect: Function; constructor(listener: IProtocol); /** * @inheritdoc */ connect(ip: string, port: number): void; private handle_connect(...arg); } } declare namespace samchon.protocol { /** *

    A server connector for web-socket protocol.

    * * @author Jeongho Nam */ class WebServerConnector extends WebCommunicator implements IServerConnector { /** *

    A socket for network I/O.

    * *

    Note that, {@link socket} is only used in web-browser environment.

    */ private browser_socket_; /** *

    A driver for server connection.

    * *

    Note that, {@link node_client} is only used in NodeJS environment.

    */ private node_client_; /** * @inheritdoc */ onConnect: Function; constructor(listener: IProtocol); /** * @inheritdoc */ connect(ip: string, port: number, path?: string): void; /** * @inheritdoc */ close(): void; /** * @inheritdoc */ sendData(invoke: Invoke): void; private handle_browser_connect(event); private handle_browser_message(event); private handle_node_connect(connection); } } declare namespace samchon.protocol { class SharedWorkerServerConnector extends SharedWorkerCommunicator implements IServerConnector { /** * @inheritdoc */ onConnect: Function; constructor(listener: IProtocol); connect(jsFile: string): void; } } declare namespace samchon.protocol { /** * @hidden */ namespace socket { type socket = any; type server = any; type http_server = any; } /** * @hidden */ namespace websocket { type connection = any; type request = any; type IMessage = any; type ICookie = any; type client = any; } } declare namespace samchon.protocol.distributed { class DSInvokeHistory extends InvokeHistory { private system_; private role_; /** * Construct from a DistributedSystem. * * @param system */ constructor(system: DistributedSystem); /** * Initilizer Constructor. * * @param system * @param role * @param invoke */ constructor(system: DistributedSystem, role: DistributedSystemRole, invoke: Invoke); /** * @inheritdoc */ construct(xml: library.XML): void; getSystem(): DistributedSystem; getRole(): DistributedSystemRole; /** * @inheritdoc */ toXML(): library.XML; } } declare namespace samchon.protocol.external { /** *

    A role of an external system.

    * *

    The {@link ExternalSystemRole} class represents a role, what to do in an {@link ExternalSystem}. * Extends this class and writes some methods related to the role.

    * *

    * *

    * *

    Proxy Pattern

    *

    The {@link ExternalSystemRole} class can be an logical proxy. In framework within user, which * {@link ExternalSystem external system} is connected with {@link ExternalSystemArray this system}, it's not * important. Only interested in user's perspective is which can be done.

    * *

    By using the logical proxy, user dont't need to know which {@link ExternalSystemRole role} is belonged * to which {@link ExternalSystem system}. Just access to a role directly from {@link ExternalSystemArray.getRole}. * Sends and receives {@link Invoke} message via the {@link ExternalSystemRole role}.

    * *
      *
    • * {@link ExternalSystemRole} can be accessed from {@link ExternalSystemArray} directly, without inteferring * from {@link ExternalSystem}, with {@link ExternalSystemArray.getRole}. *
    • *
    • * When you want to send an {@link Invoke} message to the belonged {@link ExternalSystem system}, just call * {@link ExternalSystemRole.sendData ExternalSystemRole.sendData()}. Then, the message will be sent to the * external system. *
    • *
    • Those strategy is called Proxy Pattern.
    • *
    * * @author Jeongho Nam */ abstract class ExternalSystemRole extends Entity implements IProtocol { /** * An {@link ExternalSystem external system} containing this {@link ExternalSystemRole role}. */ private system; /** *

    A name, represents and identifies this {@link ExternalSystemRole role}.

    * *

    This {@link name} is an identifier represents this {@link ExternalSystemRole role}. This {@link name} is * used in {@link ExternalSystemArray.getRole} and {@link ExternalSystem.get}, as a key elements. Thus, this * {@link name} should be unique in an {@link ExternalSystemArray}. */ protected name: string; /** * Constructor from a system. * * @param system An external system containing this role. */ constructor(system: ExternalSystem); /** * Identifier of {@link ExternalSystemRole} is its {@link name}. */ key(): string; /** * Get external system, this role is belonged to. */ getSystem(): ExternalSystem; /** * Get name, who represents and identifies this role. */ getName(): string; /** * Send an {@link Invoke} message to the external system via {@link system}. * * @param invoke An {@link Invoke} message to send to the external system. */ sendData(invoke: Invoke): void; /** *

    Handle replied {@link Invoke message} from the {@link system external system} belonged to.

    * *

    This {@link replyData replyData()} will call a member method named following {@link Invoke.listener}. * in the invoke.

    * * @param invoke An {@link Invoke} message received from the {@link system external system}. */ replyData(invoke: Invoke): void; /** * Tag name of the {@link ExternalSytemRole} in {@link XML}. * * @return role. */ TAG(): string; } } declare namespace samchon.protocol.distributed { abstract class DistributedSystemRole extends external.ExternalSystemRole { private system_array_; private progress_list_; private history_list_; protected performance: number; constructor(systemArray: DistributedSystemArray); getSystemArray(): DistributedSystemArray; getPerformance(): number; sendData(invoke: protocol.Invoke): void; _Report_history(history: DSInvokeHistory): void; } } /** * [[include: https://raw.githubusercontent.com/samchon/framework/master/handbook/TypeScript-Protocol-External_System.md]] */ declare namespace samchon.protocol.external { /** *

    An array and manager of {@link ExternalSystem external systems}.

    * *

    {@link ExternalSystemArray} is an abstract class contains and manages external system drivers, * {@link ExternalSystem} objects. You can specify this {@link ExternalSystemArray} to be a server accepting * {@link ExternalSystem external clients} or a client connecting to {@link IExternalServer external servers}. Even * both of them is also possible.

    * *
      *
    • A server accepting external clients: {@link IExternalClientArray}
    • *
    • A client connecting to external servers: {@link IExternalServerArray}
    • *
    • * Accepts external clients & Connects to external servers at the same time: * {@link IExternalServerClientArray} *
    • *
    * *

    * *

    * *

    Proxy Pattern

    *

    The {@link ExternalSystemArray} class can use Proxy Pattern. In framework within user, which * {@link ExternalSystem external system} is connected with {@link ExternalSystemArray this system}, it's not * important. Only interested in user's perspective is which can be done.

    * *

    By using the logical proxy, user dont't need to know which {@link ExternalSystemRole role} is belonged * to which {@link ExternalSystem system}. Just access to a role directly from {@link ExternalSystemArray.getRole}. * Sends and receives {@link Invoke} message via the {@link ExternalSystemRole role}.

    * *
      *
    • * {@link ExternalSystemRole} can be accessed from {@link ExternalSystemArray} directly, without inteferring * from {@link ExternalSystem}, with {@link ExternalSystemArray.getRole}. *
    • *
    • * When you want to send an {@link Invoke} message to the belonged {@link ExternalSystem system}, just call * {@link ExternalSystemRole.sendData ExternalSystemRole.sendData()}. Then, the message will be sent to the * external system. *
    • *
    • Those strategy is called Proxy Pattern.
    • *
    * * @author Jeongho Nam */ abstract class ExternalSystemArray extends EntityDequeCollection implements IProtocol { /** * Default Constructor. */ constructor(); /** * @hidden */ private handle_system_erase(event); /** * Test whether this system array has the role. * * @param name Name, identifier of target {@link ExternalSystemRole role}. * * @return Whether the role has or not. */ hasRole(name: string): boolean; /** * Get a role. * * @param name Name, identifier of target {@link ExternalSystemRole role}. * * @return The specified role. */ getRole(name: string): ExternalSystemRole; /** *

    Send an {@link Invoke} message.

    * * @param invoke An {@link Invoke} message to send. */ sendData(invoke: Invoke): void; /** *

    Handle an {@Invoke} message have received.

    * * @param invoke An {@link Invoke} message have received. */ replyData(invoke: Invoke): void; /** * Tag name of the {@link ExternalSytemArray} in {@link XML}. * * @return systemArray. */ TAG(): string; /** * Tag name of {@link ExternalSystem children elements} belonged to the {@link ExternalSytemArray} in {@link XML}. * * @return system. */ CHILD_TAG(): string; } } declare namespace samchon.protocol.parallel { /** *

    A manager containing {@link ParallelSystem} objects.

    * * * * @author Jeongho Nam */ abstract class ParallelSystemArray extends external.ExternalSystemArray { /** * @hidden */ private history_sequence_; /** * Default Constructor. */ constructor(); /** * @inheritdoc */ at(index: number): ParallelSystem; /** * @hidden */ _Fetch_history_sequence(): number; /** * @hidden */ _Set_history_sequence(val: number): void; /** * * @param invoke An invoke message requesting parallel process. * @param size Number of pieces. */ sendSegmentData(invoke: Invoke, size: number): void; /** * * * @param invoke An invoke message requesting parallel process. * @param first Initial piece's index in a section. * @param last Final piece's index in a section. The ranged used is [first, last), which contains * all the pieces' indices between first and last, including the piece pointed by index * first, but not the piece pointed by the index last. */ sendPieceData(invoke: Invoke, first: number, last: number): void; /** * * @param history * * @return Whether the processes with same uid are all fininsed. */ _Complete_history(history: InvokeHistory): boolean; /** * @hidden */ private normalize_performance(); } } declare namespace samchon.protocol.distributed { abstract class DistributedSystemArray extends parallel.ParallelSystemArray { /** * @hidden */ private role_map_; /** * Default Constructor. */ constructor(); construct(xml: library.XML): void; abstract createRole(xml: library.XML): DistributedSystemRole; /** * @inheritdoc */ at(index: number): DistributedSystem; getRoleMap(): std.HashMap; /** * @inheritdoc */ hasRole(name: string): boolean; /** * @inheritdoc */ getRole(name: string): DistributedSystemRole; insertRole(role: DistributedSystemRole): void; eraseRole(name: string): void; toXML(): library.XML; } } declare namespace samchon.protocol.distributed { abstract class DistributedClientArray extends DistributedSystemArray implements external.IExternalClientArray { /** * A subrogator of {@link IServer server}'s role instead of this {@link ExternalClientArray}. */ private server_base_; /** * Default Constructor. */ constructor(); /** *

    Factory method creating {@link IServerBase} object.

    * *

    This method {@link createServerBase createServerBase()} determines which protocol is used in this server, * {@link ExternalClientArray}. If the protocol is determined, then {@link ExternalSystem external clients} who * may connect to {@link ExternalClientArray this server} must follow the specified protocol.

    * *

    Creates and returns one of them:

    *
      *
    • {@link ServerBase}
    • *
    • {@link WebServerBase}
    • *
    • {@link SharedWorkerServerBase}
    • *
    * * @return A new {@link IServerBase} object. */ protected abstract createServerBase(): IServerBase; addClient(driver: IClientDriver): void; createChild(xml: library.XML): DistributedSystem; protected abstract createExternalClient(driver: IClientDriver): DistributedSystem; /** * @inheritdoc */ open(port: number): void; /** * @inheritdoc */ close(): void; } } declare namespace samchon.protocol.distributed { abstract class DistributedSystemArrayMediator extends DistributedSystemArray { private mediator_; /** * Default Constructor. */ constructor(); protected abstract createMediator(): parallel.MediatorSystem; protected startMediator(): void; getMediator(): parallel.MediatorSystem; _Complete_history(history: parallel.PRInvokeHistory): boolean; } } declare namespace samchon.protocol.distributed { abstract class DistributedClientArrayMediator extends DistributedSystemArrayMediator implements external.IExternalClientArray { /** * A subrogator of {@link IServer server}'s role instead of this {@link ExternalClientArray}. */ private server_base_; /** * Default Constructor. */ constructor(); /** *

    Factory method creating {@link IServerBase} object.

    * *

    This method {@link createServerBase createServerBase()} determines which protocol is used in this server, * {@link ExternalClientArray}. If the protocol is determined, then {@link ExternalSystem external clients} who * may connect to {@link ExternalClientArray this server} must follow the specified protocol.

    * *

    Creates and returns one of them:

    *
      *
    • {@link ServerBase}
    • *
    • {@link WebServerBase}
    • *
    • {@link SharedWorkerServerBase}
    • *
    * * @return A new {@link IServerBase} object. */ protected abstract createServerBase(): IServerBase; addClient(driver: IClientDriver): void; createChild(xml: library.XML): DistributedSystem; protected abstract createExternalClient(driver: IClientDriver): DistributedSystem; /** * @inheritdoc */ open(port: number): void; /** * @inheritdoc */ close(): void; } } declare namespace samchon.protocol.external { /** *

    An external system driver.

    * *

    The {@link ExternalSystem} class represents an external system, connected and interact with this system. * {@link ExternalSystem} takes full charge of network communication with external system have connected. * Replied {@link Invoke messages} from the external system is shifted to and processed in, children elements of this * class, {@link ExternalSystemRole} objects.

    * *

    * *

    * *

    Bridge & Proxy Pattern

    *

    The {@link ExternalSystem} class can be a bridge for logical proxy. In framework within user, * which {@link ExternalSystem external system} is connected with {@link ExternalSystemArray this system}, it's not * important. Only interested in user's perspective is which can be done.

    * *

    By using the logical proxy, user dont't need to know which {@link ExternalSystemRole role} is belonged * to which {@link ExternalSystem system}. Just access to a role directly from {@link ExternalSystemArray.getRole}. * Sends and receives {@link Invoke} message via the {@link ExternalSystemRole role}.

    * *
      *
    • * {@link ExternalSystemRole} can be accessed from {@link ExternalSystemArray} directly, without inteferring * from {@link ExternalSystem}, with {@link ExternalSystemArray.getRole}. *
    • *
    • * When you want to send an {@link Invoke} message to the belonged {@link ExternalSystem system}, just call * {@link ExternalSystemRole.sendData ExternalSystemRole.sendData()}. Then, the message will be sent to the * external system. *
    • *
    • Those strategy is called Bridge Pattern and Proxy Pattern.
    • *
    * * @author Jeongho Nam */ abstract class ExternalSystem extends EntityDequeCollection implements IProtocol { /** * The name represents external system have connected. */ protected name: string; /** * @hidden */ private system_array_; /** * @hidden */ private communicator_; constructor(systemArray: ExternalSystemArray); constructor(systemArray: ExternalSystemArray, communicator: IClientDriver); /** * Default Destructor. */ destructor(): void; /** * @hidden */ private handle_close(); getSystemArray(): ExternalSystemArray; /** * Identifier of {@link ExternalSystem} is its {@link name}. */ key(): string; /** * Get {@link name}. */ getName(): string; protected communicator: protocol.ICommunicator; close(): void; /** * Send {@link Invoke} message to external system. * * @param invoke An {@link Invoke} message to send. */ sendData(invoke: Invoke): void; /** * Handle an {@Invoke} message has received. * * @param invoke An {@link Invoke} message have received. */ replyData(invoke: Invoke): void; /** * Tag name of the {@link ExternalSytem} in {@link XML}. * * @return system. */ TAG(): string; /** * Tag name of {@link ExternalSystemRole children elements} belonged to the {@link ExternalSytem} in {@link XML}. * * @return role. */ CHILD_TAG(): string; } } declare namespace samchon.protocol.parallel { /** *

    An external parallel system driver.

    * * * * @author Jeongho Nam */ abstract class ParallelSystem extends external.ExternalSystem { /** * @hidden */ private progress_list_; /** * @hidden */ private history_list_; /** *

    Performance index.

    * *

    A performance index that indicates how much fast the connected parallel system is.

    * *

    If this {@link ParallelSystem parallel system} hasn't any {@link Invoke} message had handled, then the * {@link performance performance index} will be 1, which means default and average value between all * {@link ParallelSystem} instances (belonged to a same {@link ParallelSystemArray} object).

    * *

    You can specify this {@link performance} by yourself, but notice that, if the * {@link performance performance index} is higher then other {@link ParallelSystem} objects, then this * {@link ParallelSystem parallel system} will ordered to handle more processes than other * {@link ParallelSystem} objects. Otherwise, the {@link performance performance index) is lower than others, * of course, less processes will be delivered.

    * *

    This {@link performance index} is always re-calculated whenever {@link ParallelSystemArray} calls one of * them below.

    * *
      *
    • {@link ParallelSystemArray.sendSegmentData ParallelSystemArray.sendSegmentData()}
    • *
    • {@link ParallelSystemArray.sendPieceData ParallelSystemArray.sendPieceData()}
    • *
    * *

    If this class is a type of {@link DistributedSystem} derived class from the {@link ParallelSystem}, * then {@link DistributedSystemRole.sendData DistributedSystemRole.sendData()} also cause the re-calculation. *

    */ protected performance: number; constructor(systemArray: ParallelSystemArray); constructor(systemArray: ParallelSystemArray, communicator: IClientDriver); destructor(): void; /** * Get manager of this object, {@link systemArray}. * * @return A manager containing this {@link ParallelSystem} object. */ getSystemArray(): ParallelSystemArray; /** * Get {@link performant performance index}. * * A performance index that indicates how much fast the connected parallel system is. */ getPerformance(): number; _Get_progress_list(): std.HashMap>; _Get_history_list(): std.HashMap; _Set_performance(val: number): void; /** * @hidden */ _Send_piece_data(invoke: Invoke, first: number, last: number): void; /** * @hidden */ private _replyData(invoke); /** * * * @param xml * * @see {@link ParallelSystemArray.notify_complete} */ protected _Report_history(xml: library.XML): void; } } declare namespace samchon.protocol.distributed { abstract class DistributedSystem extends parallel.ParallelSystem { destructor(): void; createChild(xml: library.XML): external.ExternalSystemRole; /** * Get manager of this object. * * @return A manager containing this {@link DistributedSystem} objects. */ getSystemArray(): DistributedSystemArray; /** * @inheritdoc */ has(key: string): boolean; /** * @inheritdoc */ get(key: string): DistributedSystemRole; replyData(invoke: protocol.Invoke): void; protected _Report_history(xml: library.XML): void; } } declare namespace samchon.protocol.distributed { interface IDistributedServer extends DistributedSystem, external.IExternalServer { /** * @inheritdoc */ getSystemArray(): DistributedSystemArray; /** * @inheritdoc */ has(key: string): boolean; /** * @inheritdoc */ get(key: string): DistributedSystemRole; } abstract class DistributedServer extends DistributedSystem implements external.IExternalServer { protected ip: string; protected port: number; constructor(systemArray: DistributedSystemArray); protected abstract createServerConnector(): IServerConnector; connect(): void; getIP(): string; getPort(): number; } } declare namespace samchon.protocol.distributed { abstract class DistributedServerArray extends DistributedSystemArray implements external.IExternalServerArray { /** * Default Constructor. */ constructor(); /** * @inheritdoc */ connect(): void; } } declare namespace samchon.protocol.distributed { abstract class DistributedServerArrayMediator extends DistributedSystemArrayMediator implements external.IExternalServerArray { /** * Default Constructor. */ constructor(); /** * @inheritdoc */ connect(): void; } } declare namespace samchon.protocol.distributed { abstract class DistributedServerClientArray extends DistributedClientArray implements external.IExternalServerClientArray { /** * Default Constructor. */ constructor(); createChild(xml: library.XML): DistributedSystem; protected abstract createExternalServer(xml: library.XML): IDistributedServer; /** * @inheritdoc */ connect(): void; } } declare namespace samchon.protocol.distributed { abstract class DistributedServerClientArrayMediator extends DistributedClientArrayMediator implements external.IExternalServerClientArray { /** * Default Constructor. */ constructor(); createChild(xml: library.XML): DistributedSystem; protected abstract createExternalServer(xml: library.XML): IDistributedServer; /** * @inheritdoc */ connect(): void; } } declare namespace samchon.protocol.external { /** *

    An interface for an {@link ExternalSystemArray} accepts {@link ExternalSystem external clients} as a * {@link IServer server}.

    * *

    The easiest way to defining an {@link ExternalSystemArray} who opens server and accepts * {@link ExternalSystem external clients} is to extending one of below, who are derived from this interface * {@link IExternalClientArray}. However, if you can't specify an {@link ExternalSystemArray} to be whether server or * client, then make a class (let's name it as BaseSystemArray) extending {@link ExternalSystemArray} and make * a new class (now, I name it BaseClientArray) extending BaseSystemArray and implementing this * interface {@link IExternalClientArray}. Define the BaseClientArray following those codes on below: * *

    * * @author Jeongho Nam */ interface IExternalClientArray extends ExternalSystemArray, IServer { } /** *

    An {@link ExternalSystemArray} acceepts {@link ExternalSystem external clients} as a {@link IServer server}.

    * *

    {@link ExternalServerArray} is an abstract class contains, manages and accepts external server drivers, * {@link IExternalServer} objects, as a {@link IServer server}.

    * *

    * *

    * *

    Proxy Pattern

    *

    The {@link ExternalSystemArray} class can use Proxy Pattern. In framework within user, which * {@link ExternalSystem external system} is connected with {@link ExternalSystemArray this system}, it's not * important. Only interested in user's perspective is which can be done.

    * *

    By using the logical proxy, user dont't need to know which {@link ExternalSystemRole role} is belonged * to which {@link ExternalSystem system}. Just access to a role directly from {@link ExternalSystemArray.getRole}. * Sends and receives {@link Invoke} message via the {@link ExternalSystemRole role}.

    * *
      *
    • * {@link ExternalSystemRole} can be accessed from {@link ExternalSystemArray} directly, without inteferring * from {@link ExternalSystem}, with {@link ExternalSystemArray.getRole}. *
    • *
    • * When you want to send an {@link Invoke} message to the belonged {@link ExternalSystem system}, just call * {@link ExternalSystemRole.sendData ExternalSystemRole.sendData()}. Then, the message will be sent to the * external system. *
    • *
    • Those strategy is called Proxy Pattern.
    • *
    * * @author Jeongho Nam */ abstract class ExternalClientArray extends ExternalSystemArray implements IExternalClientArray { /** * A subrogator of {@link IServer server}'s role instead of this {@link ExternalClientArray}. */ private server_base_; /** * Default Constructor. */ constructor(); /** *

    Factory method creating {@link IServerBase} object.

    * *

    This method {@link createServerBase createServerBase()} determines which protocol is used in this server, * {@link ExternalClientArray}. If the protocol is determined, then {@link ExternalSystem external clients} who * may connect to {@link ExternalClientArray this server} must follow the specified protocol.

    * *

    Creates and returns one of them:

    *
      *
    • {@link ServerBase}
    • *
    • {@link WebServerBase}
    • *
    • {@link SharedWorkerServerBase}
    • *
    * * @return A new {@link IServerBase} object. */ protected abstract createServerBase(): IServerBase; addClient(driver: IClientDriver): void; /** * This method is deprecated. Don't use and override this. * * @return null. */ createChild(xml: library.XML): ExternalSystem; /** * Factory method creating {@link ExternalSystem} object. * * @param driver A communicator with connected client. * @return A newly created {@link ExternalSystem} object. */ protected abstract createExternalClient(driver: IClientDriver): ExternalSystem; /** * @inheritdoc */ open(port: number): void; /** * @inheritdoc */ close(): void; } } declare namespace samchon.protocol.external { /** *

    An interface for an external server driver.

    * *

    The easiest way to defining an external server driver is to extending one of below, who are derived from this * interface {@link IExternalServer}. However, if you've to interact with an external system who can be both server * and client, then make a class (let's name it as BaseSystem) extending {@link ExternalSystem} and make a * new class (now, I name it BaseServer) extending BaseSystem and implementing this interface * {@link IExternalServer}. Define the BaseServer following those codes on below: * *

    * * @author Jeongho Nam */ interface IExternalServer extends ExternalSystem { connect(): void; } /** *

    An external server driver.

    * *

    The {@link ExternalServer} class represents an external server, connected and interact with this system. * {@link ExternalServer} takes full charge of network communication with external server have connected. * Replied {@link Invoke messages} from the external system is shifted to and processed in, children elements of this * class, {@link ExternalSystemRole} objects.

    * *

    * *

    * *

    Bridge & Proxy Pattern

    *

    The {@link ExternalSystem} class can be a bridge for logical proxy. In framework within user, * which {@link ExternalSystem external system} is connected with {@link ExternalSystemArray this system}, it's not * important. Only interested in user's perspective is which can be done.

    * *

    By using the logical proxy, user dont't need to know which {@link ExternalSystemRole role} is belonged * to which {@link ExternalSystem system}. Just access to a role directly from {@link ExternalSystemArray.getRole}. * Sends and receives {@link Invoke} message via the {@link ExternalSystemRole role}.

    * *
      *
    • * {@link ExternalSystemRole} can be accessed from {@link ExternalSystemArray} directly, without inteferring * from {@link ExternalSystem}, with {@link ExternalSystemArray.getRole}. *
    • *
    • * When you want to send an {@link Invoke} message to the belonged {@link ExternalSystem system}, just call * {@link ExternalSystemRole.sendData ExternalSystemRole.sendData()}. Then, the message will be sent to the * external system. *
    • *
    • Those strategy is called Bridge Pattern and Proxy Pattern.
    • *
    * * @author Jeongho Nam */ abstract class ExternalServer extends ExternalSystem implements IExternalServer { /** * IP address of target external system to connect. */ protected ip: string; /** * Port number of target external system to connect. */ protected port: number; /** * Default Constructor. */ constructor(systemArray: ExternalSystemArray); /** * Factory method creating server connector. */ protected abstract createServerConnector(): IServerConnector; /** * @inheritdoc */ connect(): void; /** * @inheritdoc */ getIP(): string; /** * @inheritdoc */ getPort(): number; } } declare namespace samchon.protocol.external { /** *

    An interface for an {@link ExternalSystemArray} connects to {@link IExternalServer external servers} as a * client.

    * *

    The easiest way to defining an {@link ExternalSystemArray} who connects to * {@link IExternalServer external servers} is to extending one of below, who are derived from this interface * {@link IExternalServerArray}. However, if you can't specify an {@link ExternalSystemArray} to be whether server or * client, then make a class (let's name it as BaseSystemArray) extending {@link ExternalSystemArray} and make * a new class (now, I name it BaseServerArray) extending BaseSystemArray and implementing this * interface {@link IExternalServerArray}. Define the BaseServerArray following those codes on below: * *

    * * @author Jeongho Nam */ interface IExternalServerArray extends ExternalSystemArray { /** *

    Connect to {@link IExternalServer external servers}.

    * *

    This method calls children elements' method {@link IExternalServer.connect} gradually.

    */ connect(): void; } /** *

    An {@link ExternalSystemArray} connecting to {@link IExternalServer external servers} as a client.

    * *

    {@link ExternalServerArray} is an abstract class contains, manages and connects to external server drivers, * {@link IExternalServer} objects, as a client.

    * *

    * *

    * *

    Proxy Pattern

    *

    The {@link ExternalSystemArray} class can use Proxy Pattern. In framework within user, which * {@link ExternalSystem external system} is connected with {@link ExternalSystemArray this system}, it's not * important. Only interested in user's perspective is which can be done.

    * *

    By using the logical proxy, user dont't need to know which {@link ExternalSystemRole role} is belonged * to which {@link ExternalSystem system}. Just access to a role directly from {@link ExternalSystemArray.getRole}. * Sends and receives {@link Invoke} message via the {@link ExternalSystemRole role}.

    * *
      *
    • * {@link ExternalSystemRole} can be accessed from {@link ExternalSystemArray} directly, without inteferring * from {@link ExternalSystem}, with {@link ExternalSystemArray.getRole}. *
    • *
    • * When you want to send an {@link Invoke} message to the belonged {@link ExternalSystem system}, just call * {@link ExternalSystemRole.sendData ExternalSystemRole.sendData()}. Then, the message will be sent to the * external system. *
    • *
    • Those strategy is called Proxy Pattern.
    • *
    * * @author Jeongho Nam */ abstract class ExternalServerArray extends ExternalSystemArray { /** * Default Constructor. */ constructor(); /** * @inheritdoc */ connect(): void; } } declare namespace samchon.protocol.external { /** *

    An interface for an {@link ExternalSystemArray} accepts {@link ExternalSystem external clients} as a * {@link IServer server} and connects to {@link IExternalServer} as client, at the same time.

    * *

    The easiest way to defining an {@link IExternalServerClientArray} who opens server, accepts * {@link ExternalSystem external clients} and connects to {@link IExternalServer external servers} is to extending * one of below, who are derived from this interface {@link IExternalServerClientArray}. However, if you can't * specify an {@link ExternalSystemArray} to be whether server or client or even can both them, then make a class * (let's name it as BaseSystemArray) extending {@link ExternalSystemArray} and make a new class (now, I name * it BaseServerClientArray) extending BaseSystemArray and implementing this interface * {@link IExternalServerClientArray}. Define the BaseServerClientArray following those codes on below: * *

    * * @author Jeongho Nam */ interface IExternalServerClientArray extends IExternalServerArray, IExternalClientArray { } /** *

    An {@link ExternalSystemArray} connecting to {@link IExternalServer external servers} as a client and * accepts {@link ExternalSystem external clients} as a {@link IServer server}.

    * *

    {@link ExternalServerArray} is an abstract class contains, manages and connects to external server drivers, * {@link IExternalServer} objects and accepts external client drivers {@link ExternalSyste} obejcts as a * client and a {@link IServer server} at the same time.

    * *

    * *

    * *

    Proxy Pattern

    *

    The {@link ExternalSystemArray} class can use Proxy Pattern. In framework within user, which * {@link ExternalSystem external system} is connected with {@link ExternalSystemArray this system}, it's not * important. Only interested in user's perspective is which can be done.

    * *

    By using the logical proxy, user dont't need to know which {@link ExternalSystemRole role} is belonged * to which {@link ExternalSystem system}. Just access to a role directly from {@link ExternalSystemArray.getRole}. * Sends and receives {@link Invoke} message via the {@link ExternalSystemRole role}.

    * *
      *
    • * {@link ExternalSystemRole} can be accessed from {@link ExternalSystemArray} directly, without inteferring * from {@link ExternalSystem}, with {@link ExternalSystemArray.getRole}. *
    • *
    • * When you want to send an {@link Invoke} message to the belonged {@link ExternalSystem system}, just call * {@link ExternalSystemRole.sendData ExternalSystemRole.sendData()}. Then, the message will be sent to the * external system. *
    • *
    • Those strategy is called Proxy Pattern.
    • *
    * * @author Jeongho Nam */ abstract class ExternalServerClientArray extends ExternalClientArray implements IExternalServerClientArray { /** * Default Constructor. */ constructor(); /** *

    Factory method of a child Entity.

    * *

    This method is migrated to {@link createExternalServer createExternalServer()}. Override the * {@link createExternalServer createExternalServer()}.

    * * @param xml An {@link XML} object represents child element, so that can identify the type of child to create. * * @return A new child Entity via {@link createExternalServer createExternalServer()}. */ createChild(xml: library.XML): ExternalSystem; /** * Factory method creating an {@link IExternalServer} object. * * @param xml An {@link XML} object represents child element, so that can identify the type of child to create. * * @return A newly created {@link IExternalServer} object. */ protected abstract createExternalServer(xml: library.XML): IExternalServer; /** * @inheritdoc */ connect(): void; } } declare namespace samchon.protocol.slave { abstract class SlaveSystem implements protocol.IProtocol { protected communicator_: ICommunicator; /** * Default Constructor. */ constructor(); sendData(invoke: Invoke): void; protected _replyData(invoke: Invoke): void; replyData(invoke: Invoke): void; } } declare namespace samchon.protocol.parallel { abstract class MediatorSystem extends slave.SlaveSystem { private mediator_; private progress_list_; constructor(systemArray: ParallelSystemArrayMediator | distributed.DistributedSystemArrayMediator); abstract start(): void; getMediator(): ParallelSystemArrayMediator | distributed.DistributedSystemArrayMediator; _Complete_history(uid: number): void; protected _replyData(invoke: Invoke): void; replyData(invoke: protocol.Invoke): void; } } declare namespace samchon.protocol.parallel { class MediatorServer extends MediatorSystem implements slave.ISlaveServer { private server_base_; private port; constructor(systemArray: ParallelSystemArrayMediator, port: number); protected createServerBase(): IServerBase; addClient(driver: IClientDriver): void; start(): void; open(port: number): void; close(): void; } class MediatorWebServer extends MediatorServer { /** * @inheritdoc */ protected createServerBase(): IServerBase; } class MediatorSharedWorkerServer extends MediatorServer { /** * @inheritdoc */ protected createServerBase(): IServerBase; } } declare namespace samchon.protocol.parallel { class MediatorClient extends MediatorSystem implements slave.ISlaveClient { protected ip: string; protected port: number; constructor(systemArray: ParallelSystemArrayMediator, ip: string, port: number); protected createServerConnector(): IServerConnector; getIP(): string; getPort(): number; start(): void; connect(): void; } class MediatorWebClient extends MediatorClient { /** * @inheritdoc */ protected createServerConnector(): IServerConnector; } class MediatorSharedWorkerClient extends MediatorClient { /** * @inheritdoc */ protected createServerConnector(): IServerConnector; } } declare namespace samchon.protocol.parallel { class PRInvokeHistory extends InvokeHistory { /** * Index number of initial piece. */ private first; /** * Index number of final piece. */ private last; /** * Default Constructor. */ constructor(); /** * Construct from an Invoke message. * * @param invoke */ constructor(invoke: Invoke); getFirst(): number; getLast(): number; _Set_first(val: number): void; _Set_last(val: number): void; /** * Compute number of allocated pieces. */ computeSize(): number; } } declare namespace samchon.protocol.parallel { abstract class ParallelClientArray extends ParallelSystemArray implements external.IExternalClientArray { /** * A subrogator of {@link IServer server}'s role instead of this {@link ExternalClientArray}. */ private server_base_; /** * Default Constructor. */ constructor(); /** *

    Factory method creating {@link IServerBase} object.

    * *

    This method {@link createServerBase createServerBase()} determines which protocol is used in this server, * {@link ExternalClientArray}. If the protocol is determined, then {@link ExternalSystem external clients} who * may connect to {@link ExternalClientArray this server} must follow the specified protocol.

    * *

    Creates and returns one of them:

    *
      *
    • {@link ServerBase}
    • *
    • {@link WebServerBase}
    • *
    • {@link SharedWorkerServerBase}
    • *
    * * @return A new {@link IServerBase} object. */ protected abstract createServerBase(): IServerBase; addClient(driver: IClientDriver): void; createChild(xml: library.XML): ParallelSystem; protected abstract createExternalClient(driver: IClientDriver): ParallelSystem; /** * @inheritdoc */ open(port: number): void; /** * @inheritdoc */ close(): void; } } declare namespace samchon.protocol.parallel { abstract class ParallelSystemArrayMediator extends ParallelSystemArray { private mediator_; /** * Default Constructor. */ constructor(); protected abstract createMediator(): MediatorSystem; protected start_mediator(): void; getMediator(): MediatorSystem; _Complete_history(history: PRInvokeHistory): boolean; } } declare namespace samchon.protocol.parallel { abstract class ParallelClientArrayMediator extends ParallelSystemArrayMediator implements external.IExternalClientArray { /** * A subrogator of {@link IServer server}'s role instead of this {@link ExternalClientArray}. */ private server_base_; /** * Default Constructor. */ constructor(); /** *

    Factory method creating {@link IServerBase} object.

    * *

    This method {@link createServerBase createServerBase()} determines which protocol is used in this server, * {@link ExternalClientArray}. If the protocol is determined, then {@link ExternalSystem external clients} who * may connect to {@link ExternalClientArray this server} must follow the specified protocol.

    * *

    Creates and returns one of them:

    *
      *
    • {@link ServerBase}
    • *
    • {@link WebServerBase}
    • *
    • {@link SharedWorkerServerBase}
    • *
    * * @return A new {@link IServerBase} object. */ protected abstract createServerBase(): IServerBase; addClient(driver: IClientDriver): void; createChild(xml: library.XML): ParallelSystem; protected abstract createExternalClient(driver: IClientDriver): ParallelSystem; /** * @inheritdoc */ open(port: number): void; /** * @inheritdoc */ close(): void; } } declare namespace samchon.protocol.parallel { interface IParallelServer extends external.IExternalServer, ParallelSystem { /** * @inheritdoc */ getSystemArray(): ParallelSystemArray; } abstract class ParallelServer extends ParallelSystem implements external.IExternalServer { protected ip: string; protected port: number; constructor(systemArray: ParallelSystemArray); protected abstract createServerConnector(): IServerConnector; connect(): void; getIP(): string; getPort(): number; } } declare namespace samchon.protocol.parallel { abstract class ParallelServerArray extends ParallelSystemArray implements external.IExternalServerArray { constructor(); connect(): void; } } declare namespace samchon.protocol.parallel { abstract class ParallelServerArrayMediator extends ParallelSystemArrayMediator implements external.IExternalServerArray { constructor(); /** * @inheritdoc */ connect(): void; } } declare namespace samchon.protocol.parallel { abstract class ParallelServerClientArray extends ParallelClientArray implements external.IExternalServerClientArray { /** * Default Constructor. */ constructor(); createChild(xml: library.XML): ParallelSystem; protected abstract createExternalServer(xml: library.XML): IParallelServer; connect(): void; } } declare namespace samchon.protocol.parallel { abstract class ParallelServerClientArrayMediator extends ParallelClientArrayMediator implements external.IExternalServerClientArray { /** * Default Constructor. */ constructor(); createChild(xml: library.XML): ParallelSystem; protected abstract createExternalServer(xml: library.XML): IParallelServer; /** * @inheritdoc */ connect(): void; } } declare namespace samchon.protocol.service { abstract class Client implements protocol.IProtocol { private user_; private service_; private communicator_; private no_; /** * Construct from an User and WebClientDriver. */ constructor(user: User, driver: WebClientDriver); protected abstract createService(path: string): Service; close(): void; getUser(): User; getService(): Service; getNo(): number; _Set_no(val: number): void; sendData(invoke: protocol.Invoke): void; replyData(invoke: protocol.Invoke): void; protected changeService(path: string): void; } } declare namespace samchon.protocol.service { abstract class Server extends protocol.WebServer implements IProtocol { private session_map_; private account_map_; /** * Default Constructor. */ constructor(); /** * Factory method creating {@link User} object. * * @return A newly created {@link User} object. */ protected abstract createUser(): User; has(account: string): boolean; get(account: string): User; /** * @hidden */ _Get_account_map(): std.HashMap; sendData(invoke: protocol.Invoke): void; replyData(invoke: protocol.Invoke): void; addClient(driver: WebClientDriver): void; _Erase_user(user: User): void; } } declare namespace samchon.protocol.service { abstract class Service implements protocol.IProtocol { private client_; private path_; /** * Default Constructor. */ constructor(client: Client, path: string); destructor(): void; /** * Get client. */ getClient(): Client; /** * Get path. */ getPath(): string; sendData(invoke: protocol.Invoke): void; replyData(invoke: protocol.Invoke): void; } } declare namespace samchon.protocol.service { abstract class User extends collection.HashMapCollection implements protocol.IProtocol { private server_; private session_id_; private sequence_; private account_id_; private authority_; /** * Construct from a Server. */ constructor(server: Server); protected abstract createClient(driver: WebClientDriver): Client; /** * @hidden */ _Create_child(driver: WebClientDriver): Client; /** * @hidden */ private handle_erase_client(event); getServer(): Server; getAccountID(): string; getAuthority(): number; setAccount(id: string, authority: number): void; /** * @hidden */ _Get_session_id(): string; /** * @hidden */ _Fetch_sequence(): number; /** * @hidden */ _Set_session_id(val: string): void; sendData(invoke: protocol.Invoke): void; replyData(invoke: protocol.Invoke): void; } } declare namespace samchon.protocol.slave { interface ISlaveClient extends SlaveSystem { connect(ip: string, port: number): void; } abstract class SlaveClient extends SlaveSystem implements ISlaveClient { /** * Default Constructor. */ constructor(); /** * @inheritdoc */ protected abstract createServerConnector(): IServerConnector; /** * @inheritdoc */ connect(ip: string, port: number): void; } } declare namespace samchon.protocol.slave { interface ISlaveServer extends SlaveSystem, IServer { } abstract class SlaveServer extends SlaveSystem implements ISlaveServer { private server_base_; constructor(); protected abstract createServerBase(): IServerBase; open(port: number): void; close(): void; addClient(driver: IClientDriver): void; } } declare namespace samchon.test { function test_collection(): void; }