Ferreteria/v0.6/clade/IO/Aspect/Connx/Plug/@revision/2026/01/31

From Woozle Writes Code
< Ferreteria‎ | v0.6‎ | clade‎ | IO‎ | Aspect‎ | Connx‎ | Plug
Jump to navigation Jump to search
The item documented here has been removed and is no longer in use.
This is the entire file just before removal on 2026-01-31, but un-commented-out.
<?php namespace Woozalia\Ferret\IO\Aspect\Connx;
// DOCS: https://wooz.dev/Ferreteria/v0.6/clade/IO/Aspect/Connx/Plug

/* Base*  [ca,i] */ use Woozalia\Ferret\IO\Aspect\{ caConnx as BaseClass, iConnx as BaseIface };
/* CLineIface    */ use Woozalia\Ferret\Sys\Data\Codec\aux\iCmdLine as CLineIface;
/* CommOp* [c,i] */ use Woozalia\Ferret\Sys\Events\ItWent\{ /* cCommOp as CommOpClass, */ iCommOp as CommOpIface };
/* ProcIface     */ use Woozalia\Ferret\IO\Aspect\Connx\iProcess as ProcIface;
/* Result* [c,i] */ use Woozalia\Ferret\IO\Aspect\Connx\aux\itWent\{ cProcOp as ResultClass, iProcOp as ResultIface };
/* SelfIface     */ use Woozalia\Ferret\IO\Aspect\Connx\iPlug as SelfIface;
/* SockIface     */ use Woozalia\Ferret\IO\Aspect\iSocket as SockIface;

//* 2026-01-21 Checking to see what parts of this are actually needed
interface iPlug extends BaseIface {
    // SETUP
    static function FromSocket(SockIface $oSock) : self;
    static function ForSocket() : self;
    // SETUP: dynamic
    function DefaultSocket(SockIface $o) : void;
    // I/O
    function DoCommand(CLineIface $oCmd) : ResultIface;
    // OBJECTS
    function OEndpoint() : self;
    #function OProcess() : ProcIface;
    function OSock(?SockIface $o=NULL) : SockIface;
    function WrapAction(CommOpIface $oActIn) : CommOpIface;
}
abstract class caPlug extends BaseClass implements SelfIface {

    // ++ 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; }

    // -- SETUP -- //
    // ++ OBJECTS ++ //

    public function OEndpoint() : self {
        $oNext = $this->OSock()->OJack();
        return ($oNext === $this) ? $this : $oNext->OEndpoint();
    }

    //* 2026-01-20 This just does not work.
    public function OProcess() : ProcIface {
        $oPlug = $this->OSock()->OJack();
        // 2026-01-20 This is a kluge. TODO: figure out why we need to do this, and fix it.
        if ($oPlug === $this) {
            return $this;
        } else {
            return $oPlug->OProcess();
        }
    }
    //*/

    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; }
    public function OSock(?SockIface $o=NULL) : SockIface { return is_null($o) ? $this->oSock : ($this->oSock = $o); }

    // 2025-12-04 TODO: Maybe this should just *always* CopyFrom()?
    public function WrapAction(CommOpIface $oActIn) : CommOpIface {
        if (is_a($oActIn,$this->StatusClass())) {
            $oActOut = $oActIn;
        } else {
            $oActOut = $this->HowItWent();
            $oActOut->CopyFrom($oActIn);
        }
        return $oActOut;
    }

    // -- OBJECTS -- //
}
//*/