Ferreteria/v0.6/clade/IO/Aspect/Connx/Plug: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
mNo edit summary |
||
| (One intermediate revision by the same user not shown) | |||
| Line 1: | Line 1: | ||
{{page/clade/v2 | {{page/clade/v2 | ||
|fam= | |fam= | ||
{{!}} {{l/ver/clade|IO\Aspect|Connx}} | {{!}} align=right {{!}} {{l/ver/clade|IO\Aspect|Connx}} | ||
{{!}} → {{l/ver/clade|IO\Aspect\Connx|Plug}} | {{!}} align=center {{!}} → {{l/ver/clade|IO\Aspect\Connx|Plug}} | ||
{{!}} | {{!}} align=left {{!}} | ||
→ {{l/ver/clade|IO\Aspect\Connx\Plug|Chain}}<br> | → {{l/ver/clade|IO\Aspect\Connx\Plug|Chain}}<br> | ||
→ {{l/ver/clade|IO\Aspect\Connx\Plug|Shell}} | → {{l/ver/clade|IO\Aspect\Connx\Plug|Shell}} | ||
|alia= | |alia= | ||
{{!}}- | {{!}}- | ||
{{!}} '''Base'''* [ca,i] {{!}}{{!}} {{l/ver/clade|IO\Aspect|Connx}} | {{!}} '''Base'''* [ca,i] {{!}}{{!}} {{l/ver/clade/full|p=ferreteria|IO\Aspect|Connx}} | ||
}} | |||
==About== | |||
* PURPOSE: a connection that expects access to a socket | |||
==History== | |||
* '''{{fmt/date|2025|06|04}}''' created | |||
==Code== | |||
''as of 2025-10-21'' | |||
{{fmt/php/block|1= | |||
interface iPlug extends BaseIface { | |||
// CONFIG | |||
function ActionClass(string $sc=NULL) : string; | |||
// SETUP | |||
static function FromSocket(SockIface $oSock) : self; | |||
static function ForSocket() : self; | |||
// SETUP: dynamic | |||
function DefaultSocket(SockIface $o) : void; | |||
// I/O | |||
function DoCommand(string{{!}}array $sCmd, BufferIface $oBuff, ?CommOpIface $oAct=NULL) : CommOpIface; | |||
} | |||
abstract class caPlug extends BaseClass implements SelfIface { | |||
// ++ CONFIG ++ // | |||
private $scAct = CommOpClass::class; | |||
// PUBLIC so it can be changed externally | |||
public function ActionClass(string $sc=NULL) : string { return is_string($sc) ? ($this->scAct = $sc) : $this->scAct; } | |||
// -- CONFIG -- // | |||
// ++ SETUP ++ // | |||
protected function __construct(){} | |||
// ++ SETUP: dynamic ++ // | |||
static public function FromSocket(SockIface $oSock) : SelfIface { | |||
$oThis = new static; | |||
$oThis->WithSocket($oSock); | |||
return $oThis; | |||
} | |||
static public function ForSocket() : SelfIface { return new static; } | |||
private $oSock=NULL; | |||
protected function WithSocket(SockIface $o) : void { $this->oSock = $o; } | |||
public function DefaultSocket(SockIface $o) : void { if (is_null($this->oSock)) $this->oSock = $o; } | |||
protected function OSock() : SockIface { return $this->oSock; } | |||
// -- SETUP -- // | |||
} | |||
}} | }} | ||
Latest revision as of 12:54, 22 October 2025
| ||||||||||||||
About
- PURPOSE: a connection that expects access to a socket
History
Code
as of 2025-10-21
interface iPlug extends BaseIface {
// CONFIG
function ActionClass(string $sc=NULL) : string;
// SETUP
static function FromSocket(SockIface $oSock) : self;
static function ForSocket() : self;
// SETUP: dynamic
function DefaultSocket(SockIface $o) : void;
// I/O
function DoCommand(string|array $sCmd, BufferIface $oBuff, ?CommOpIface $oAct=NULL) : CommOpIface;
}
abstract class caPlug extends BaseClass implements SelfIface {
// ++ CONFIG ++ //
private $scAct = CommOpClass::class;
// PUBLIC so it can be changed externally
public function ActionClass(string $sc=NULL) : string { return is_string($sc) ? ($this->scAct = $sc) : $this->scAct; }
// -- CONFIG -- //
// ++ SETUP ++ //
protected function __construct(){}
// ++ SETUP: dynamic ++ //
static public function FromSocket(SockIface $oSock) : SelfIface {
$oThis = new static;
$oThis->WithSocket($oSock);
return $oThis;
}
static public function ForSocket() : SelfIface { return new static; }
private $oSock=NULL;
protected function WithSocket(SockIface $o) : void { $this->oSock = $o; }
public function DefaultSocket(SockIface $o) : void { if (is_null($this->oSock)) $this->oSock = $o; }
protected function OSock() : SockIface { return $this->oSock; }
// -- SETUP -- //
}