Ferreteria/v0.6/clade/Sys/Data/aux/MetaPair

From Woozle Writes Code
< Ferreteria‎ | v0.6‎ | clade‎ | Sys‎ | Data‎ | aux
Revision as of 15:08, 9 November 2025 by Woozle (talk | contribs) (Created page with "{{page/clade/v2 |fam= {{!}} align=right {{!}} {{l/ver/clade|Aux|StandardBase}} {{!}} align=center {{!}} ⇒ {{l/ver/clade|Sys\Data\aux|MetaPair}} ⇒ {{!}} align=left {{!}} ''(none)'' |alia= {{!-!}} '''Base'''* [c,i] {{!!}} {{l/ver/clade/full|p=ferreteria|Aux|StandardBase}} {{!-!}} '''DataNode'''* [c,i] {{!!}} {{l/ver/clade/full|p=ferreteria|Sys\Data\aux\metaPair|Data}} {{!-!}} '''InfoNode'''* [c,i] {{!!}} {{l/ver/clade/full|p=ferreteria|Sys\Data\aux\metaPair|Info...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
clade: Sys\Data\aux\MetaPair
Clade Family
StandardBase MetaPair (none)
Clade Aliases
Alias Clade
Base* [c,i] Aux\StandardBase
DataNode* [c,i] Sys\Data\aux\metaPair\Data
InfoNode* [c,i] Sys\Data\aux\metaPair\Info
SchemaIface Sys\Data\Engine\Schema
SelfIface Sys\Data\aux\MetaPair
Subpages

About

Auxiliary clades are in metaPair.

Code

as of 2025-11-09

interface iMetaPair extends BaseIface {
    // SETUP
    static function FromDataSpec(string $fs) : SelfIface;
    static function FromInfoSpec(string $fs) : SelfIface;
    static function FromDataSpec_wSchema(SchemaIface $o,string $fs) : self;
    // OBJECTS
    function DataFile() : DataNodeIface;
    function MetaFile() : InfoNodeIface;
}
class cMetaPair extends BaseClass implements SelfIface {

    // ++ CONFIG ++ //

    protected function DataNodeClass() : string { return DataNodeClass::class; }
    protected function InfoNodeClass() : string { return InfoNodeClass::class; }

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

    public static function FromDataSpec(string $fs) : SelfIface {
        $oThis = new static;
        $oThis->WithDataSpec($fs);
        return $oThis;
    }
    public static function FromInfoSpec(string $fs) : SelfIface {
        $oThis = new static;
        $oThis->WithInfoSpec($fs);
        return $oThis;
    }

    public static function FromDataSpec_wSchema(SchemaIface $o,string $fsData) : SelfIface {
        $oThis = static::FromDataSpec($fsData);
        $oThis->oSchema = $o;
        return $oThis;
    }

    // ++ SETUP: dynamic ++ //

    protected function WithDataSpec(string $fsData) : void {
        // $fsData is the data file we're documenting -- add an extension for the metadata
        $fsMeta = $fsData.'.json';

        $ofData = $this->DataNodeClass()::FromSpec($fsData);
        $ofMeta = $this->InfoNodeClass()::FromSpec($fsMeta);

        $oDataSpec = $ofData->Ident();
        #$oDataFile = $ofData->InOut();

        #$oDataSpec = FileSpecClass::FromSpec($fsData);

        // remember/store just the filename -- the meta-file should be portable; this is not a log file
        $fnData = $oDataSpec->SpecNameExt();
        echo $ofMeta->ReflectThis()->Report();
        // in the metadata, save the name of the datafile:
        $ofMeta->Ident()->OSpec()->QOLeaf()->GetIt()->SetIt($fnData);
    }
    protected function WithInfoSpec(string $fsMeta) : void {
        $ofMeta = $this->InfoNodeClass()::FromSpec($fsMeta);
        $fnData = $ofMeta->TargetFileName();

        // in progress
        echo $this->DataNodeClass()::ReflectSelf()->Report();
    }

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

    private $oFiData;
    public function DataFile() : DataNodeIface { return $this->oFiData; }

    private $oFiMeta;
    public function MetaFile() : InfoNodeIface { return $this->oFiMeta; }


    // -- OBJECTS -- //
}