Ferreteria/v0.6/clade/Sys/Data/aux/MetaPair
Jump to navigation
Jump to search
| ||||||||||||||||||||||
About
Auxiliary clades are in metaPair.
Code
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 -- //
}