Ferreteria/v0.6/clade/Sys/Data/Engine/Conn: Difference between revisions

From Woozle Writes Code
< Ferreteria‎ | v0.6‎ | clade‎ | Sys‎ | Data‎ | Engine
Jump to navigation Jump to search
No edit summary
No edit summary
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{page/clade/v2
{{page/clade/v2
|fam=
|fam=
{{!}} align=right {{!}}
{{!}} align=right {{!}}
{{l/ver/clade|IO/Aspect/Connx|Plug}}<br>
<poem>
{{l/ver/clade|Config/Roster/for|AnObject}}
<code>{{l/ver/clade|IO/Aspect/Connx|Plug}}</code>
{{!}} &rarr; {{l/ver/clade|Sys/Data/Engine|Conn}}
<code>{{l/ver/clade|Config/Roster/for|AnObject}}</code>
{{!}} &rarr; {{l/ver/clade|Sys/Data/Engine/Conn|MyMar}}
</poem>
{{!}} align=center {{!}} &rArr; <code>{{l/ver/clade|Sys/Data/Engine|Conn}}</code>
{{!}} align=left  {{!}} &rArr; <code>{{l/ver/clade|Sys/Data/Engine/Conn|MyMar}}</code>
 
|alia=
|alia=
{{!}}-
{{!-!}} '''Base'''*       [c,i] {{!!}} <code>{{l/ver/clade/full|IO\Aspect\Connx|Plug}}</code>
{{!}} '''Base'''* [c,i] {{!}}{{!}} {{l/ver/clade|IO\Aspect\Connx|Plug}}
{{!-!}} '''CredsIface'''        {{!!}} <code>{{l/ver/clade/full|IO\Aspect|Creds}}</code>
{{!}}-
{{!-!}} '''HasClsRost'''* [i,t] {{!!}} <code>{{l/ver/clade/full|Config\Roster\for|AClass}}</code>
{{!}} '''Creds'''* [i] {{!}}{{!}} {{l/ver/clade|IO\Aspect|Creds}}
{{!-!}} '''HasObjRost'''* [i,t] {{!!}} <code>{{l/ver/clade/full|Config\Roster\for|AnObject}}</code>
{{!}}-
{{!-!}} '''OperIface'''        {{!!}} <code>{{l/ver/clade/full|Sys/Data/Engine|Ops}}</code>
{{!}} '''HasRost'''* [i,t] {{!}}{{!}} {{l/ver/clade|Config\Roster\for|AnObject}}
{{!-!}} '''RostClass'''         {{!!}} <code>{{l/ver/clade/full|Sys\Data\Engine\aux|DbList}}</code>
{{!}}-
{{!-!}} '''SelfIface'''        {{!!}} <code>{{l/ver/clade/full|Sys\Data\Engine|Conn}}</code>
{{!}} '''Player'''* [i] {{!}}{{!}} {{l/ver/clade|Data\Base\Result|Player}}
{{!-!}} '''SockIface'''         {{!!}} <code>{{l/ver/clade/full|IO\Aspect|Socket}}</code>
{{!}}-
{{!-!}} '''ViewIface'''         {{!!}} <code>{{l/ver/clade/full|IO\O|View}}</code>
{{!}} '''Sock'''* [i] {{!}}{{!}} {{l/ver/clade|IO\Aspect|Socket}}
{{!}}-
{{!}} '''View'''* [i] {{!}}{{!}} {{l/ver/clade|IO\O|View}}
}}
}}
==About==
* PURPOSE: base class for talking to a database engine
** This ''is'' a connection (to the DB engine), but it also ''contains'' a connection (to the shell endpoint).
==Pages==
* {{l/sub|@history}}
* {{l/sub|@removed}}
* clade subspace:
** [[/MyMar/]]
* auxiliary subspace:
** [[/view/]]
==Code==
==Code==
''as of 2025-10-01''
''as of {{fmt/date|2025|10|21}}:''
{{fmt/php/block|1=
{{fmt/php/block|1=
interface iConn extends BaseIface, HasRostIface {
interface iConn extends BaseIface, HasClsRostIface, HasObjRostIface {
    // INVOCATION
    //#[BaseIface] function Open() : ActionIface;
    //#[BaseIface] function Shut() : ActionIface;
     // OBJECTS
     // OBJECTS
     function OOper() : OperIface;
     function OOper() : OperIface;
     function OSock() : SockIface;  // code-to-cmd-endpoint
     function OSock() : SockIface;  // code-to-cmd-endpoint
    // UI
    //#[\Woozalia\Ferret\IO\iAspect] function DescribeInline() : string;
}
}
abstract class caConn extends BaseClass implements SelfIface {
abstract class caConn extends BaseClass implements SelfIface {
     use HasRostTrait;
     use HasClsRostTrait;
    use HasObjRostTrait;


     // ++ CONFIG ++ //
     // ++ CONFIG ++ //


     // #[Oper]
     // #[Oper]
     abstract protected function OperType() : string;
     abstract protected function OperClass() : string;
    static protected function RosterClass() : string { return RostClass::class; }  // OVERRIDE


     // -- CONFIG -- //
     // -- CONFIG -- //
     // ++ SETUP ++ //
     // ++ SETUP ++ //


    // $sSlug is the name for this Connection
     public function __construct(string $sSlug, private SockIface $oSock) {
     public function __construct(string $sSlug, private SockIface $oSock) {
         $this->WithSlug($sSlug);
         $this->WithSlug($sSlug);
Line 60: Line 68:
     // #[Oper]
     // #[Oper]
     private $oOper=NULL;
     private $oOper=NULL;
    #public function HoldOper(OperIface $o) : void { $this->oOper = $o; }
     // #[Oper]
     // #[Oper]
     public function OOper() : OperIface { return $this->oOper ?? ($this->oOper = $this->OOperNew()); }
     public function OOper() : OperIface { return $this->oOper ?? ($this->oOper = $this->OOperNew()); }
     // #[Oper]
     // #[Oper]
     protected function OOperNew() : OperIface {
     protected function OOperNew() : OperIface {
         $sType = $this->OperType();
         $scOper = $this->OperClass();
         $osOper = OperAdmin::FromClassSlug($sType);
         $this->AmHere("Making NEW $scOper");
        if ($osOper->HasIt()) {
        $oOper = $scOper::FromConn($this);
            $scOper = $osOper->GetIt();
            #$echo $this->ReflectThis()->Report();
            #echo $scOper::ReflectSelf()->Report();
            #$oOper = new ($scOper);
            $oOper = $scOper::AccessSelf();
            $oOper->WithConn($this); // give new Oper a pointer to its Conn
        } else {
            echo self::CodingPrompt("This Connection expects an engine of type '$sType' to be defined.");
            $oOper = NULL;
        }
         return $oOper;
         return $oOper;
     }
     }

Latest revision as of 02:32, 4 December 2025

clade: Sys\Data\Engine\Conn
Clade Family
Conn MyMar
Clade Aliases
Alias Clade
Base* [c,i] IO\Aspect\Connx\Plug
CredsIface IO\Aspect\Creds
HasClsRost* [i,t] Config\Roster\for\AClass
HasObjRost* [i,t] Config\Roster\for\AnObject
OperIface Sys\Data\Engine\Ops
RostClass Sys\Data\Engine\aux\DbList
SelfIface Sys\Data\Engine\Conn
SockIface IO\Aspect\Socket
ViewIface IO\O\View
Subpages

About

  • PURPOSE: base class for talking to a database engine
    • This is a connection (to the DB engine), but it also contains a connection (to the shell endpoint).

Pages

Code

as of 2025-10-21:

interface iConn extends BaseIface, HasClsRostIface, HasObjRostIface {
    // OBJECTS
    function OOper() : OperIface;
    function OSock() : SockIface;  // code-to-cmd-endpoint
}
abstract class caConn extends BaseClass implements SelfIface {
    use HasClsRostTrait;
    use HasObjRostTrait;

    // ++ CONFIG ++ //

    // #[Oper]
    abstract protected function OperClass() : string;
    static protected function RosterClass() : string { return RostClass::class; }  // OVERRIDE

    // -- CONFIG -- //
    // ++ SETUP ++ //

    // $sSlug is the name for this Connection
    public function __construct(string $sSlug, private SockIface $oSock) {
        $this->WithSlug($sSlug);
    }
    public function OSock() : SockIface { return $this->oSock; }

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

    public function Inspect() : ViewIface { return new ($this->InspectorClass())($this,$this->OSock(),$this->OCred(),$this); }

    // SHORTCUT
    protected function OCred() : CredsIface { return $this->OSock()->OCred(); }

    // #[Oper]
    private $oOper=NULL;
    // #[Oper]
    public function OOper() : OperIface { return $this->oOper ?? ($this->oOper = $this->OOperNew()); }
    // #[Oper]
    protected function OOperNew() : OperIface {
        $scOper = $this->OperClass();
        $this->AmHere("Making NEW $scOper");
        $oOper = $scOper::FromConn($this);
        return $oOper;
    }

    // -- OBJECTS -- //
}