1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301
|
#############################################################################
##
#W tmdbatt2.g GAP 4 package `browse' Thomas Breuer
##
## This file contains
## - the global record `TomLibData',
## whose components are used to define the database id enumerator
## `TomLibData.IdEnumerator' and its database attributes
## (see the GAP package `Browse' for technical details) and
## - the Browse application `BrowseTomLibInfo',
## showing an overview of the GAP library of tables of marks.
##
#############################################################################
##
#V TomLibData
##
## We introduce a new global variable for ``database aspects''.
##
BindGlobal( "TomLibData", rec() );
#############################################################################
##
## Provide utilities for the computation of database attribute values.
## They allow one to access table data without actually creating the tables.
##
TomLibData.MyIdFunc:= function( arg ); end;
TomLibData.TABLE_ACCESS_FUNCTIONS:= [
rec(),
rec( # These global variables are used in the data files.
LIBTOMKNOWN := rec( LOADSTATUS := rec(), UNLOAD := false,
MAX := infinity ),
SetActualLibFileName := TomLibData.MyIdFunc,
AFLT := TomLibData.MyIdFunc,
ACLT := TomLibData.MyIdFunc,
LIBTOM := TomLibData.MyIdFunc,
) ];
TomLibData.SaveTableAccessFunctions := function()
local name;
if TomLibData.TABLE_ACCESS_FUNCTIONS[1] <> rec() then
Info( InfoTom, 2, "access functions were already saved" );
return;
fi;
for name in RecNames( TomLibData.TABLE_ACCESS_FUNCTIONS[2] ) do
TomLibData.TABLE_ACCESS_FUNCTIONS[1].( name ):= [ ValueGlobal( name ) ];
if IsReadOnlyGlobal( name ) then
Add( TomLibData.TABLE_ACCESS_FUNCTIONS[1].( name ), "readonly" );
MakeReadWriteGlobal( name );
fi;
UnbindGlobal( name );
ASS_GVAR( name, TomLibData.TABLE_ACCESS_FUNCTIONS[2].( name ) );
od;
end;
TomLibData.RestoreTableAccessFunctions := function()
local name;
if TomLibData.TABLE_ACCESS_FUNCTIONS[1] = rec() then
Info( InfoTom, 2, "access functions were not saved" );
return;
fi;
for name in RecNames( TomLibData.TABLE_ACCESS_FUNCTIONS[2] ) do
UnbindGlobal( name );
ASS_GVAR( name, TomLibData.TABLE_ACCESS_FUNCTIONS[1].( name )[1] );
if Length( TomLibData.TABLE_ACCESS_FUNCTIONS[1].( name ) ) = 2 then
MakeReadOnlyGlobal( name );
fi;
Unbind( TomLibData.TABLE_ACCESS_FUNCTIONS[1].( name ) );
od;
end;
#############################################################################
##
#F TomLibData.ComputeTableInfoByScanningLibraryFiles( <pairs> )
##
## The argument <A>pairs</A> must be a list of pairs
## <C>[ <A>nam</A>, <A>fun</A> ]</C>
## where <A>nam</A> is the name of a function to be reassigned during the
## reread process (such as <C>"LIBTOM"</C>),
## and <A>fun</A> is the intended value.
##
TomLibData.ComputeTableInfoByScanningLibraryFiles :=
function( pairs )
local pair, name;
# Disable the table library access.
TomLibData.SaveTableAccessFunctions();
# Define appropriate access functions.
for pair in pairs do
ASS_GVAR( pair[1], pair[2] );
od;
# Clear the cache.
TomLibData.TableInfo:= rec();
# Loop over the library files.
for name in LIBTOMLIST.files do
ReadPackage( "tomlib", Concatenation( "data/", name, ".tom" ) );
od;
# Restore the ordinary table library access.
TomLibData.RestoreTableAccessFunctions();
end;
#############################################################################
##
#F TomLibData.PrepareAttributeComputation()
##
TomLibData.PrepareAttributeComputation:= function()
if not IsBound( TomLibData.TableInfo ) then
TomLibData.ComputeTableInfoByScanningLibraryFiles( [
[ "LIBTOM", function( arg )
TomLibData.TableInfo.( arg[1] ):= rec(
SubsTom:= arg[2],
MarksTom:= arg[3],
OrdersTom:= arg[5] );
end ] ] );
fi;
end;
#############################################################################
##
## Create the database id enumerator to which the database attributes refer.
##
TomLibData.IdEnumerator:= DatabaseIdEnumerator( rec(
identifiers:= Set( AllLibTomNames() ),
entry:= function( idenum, id ) return TableOfMarks( id ); end,
isSorted:= true,
viewLabel:= "G",
viewSort:= function( nam1, nam2 )
return BrowseData.SplitStringIntoNumbersAndNonnumbers( nam1 )
<= BrowseData.SplitStringIntoNumbersAndNonnumbers( nam2 );
end,
align:= "tl",
) );;
#############################################################################
##
#V TomLibData.IdEnumerator.attributes.Size
##
DatabaseAttributeAdd( TomLibData.IdEnumerator, rec(
identifier:= "Size",
description:= "group orders of GAP library tables of marks",
type:= "values",
viewLabel:= "|G|",
align:= "tr",
create:= function( attr, id )
local r, i;
TomLibData.PrepareAttributeComputation();
if IsBound( TomLibData.TableInfo.( id ) ) then
r:= TomLibData.TableInfo.( id );
if IsList( r.OrdersTom ) then
return r.OrdersTom[ Length( r.OrdersTom ) ];
elif IsList( r.SubsTom ) and IsList( r.MarksTom ) then
i:= Length( r.SubsTom );
return r.MarksTom[1][1] /
r.MarksTom[i][ Position( r.SubsTom[i], 1 ) ];
fi;
fi;
return fail;
end,
viewSort:= BrowseData.CompareAsNumbersAndNonnumbers,
sortParameters:= [ "add counter on categorizing", "yes" ],
) );
#############################################################################
##
#V TomLibData.IdEnumerator.attributes.NrClasses
##
DatabaseAttributeAdd( TomLibData.IdEnumerator, rec(
identifier:= "NrClasses",
description:= "numbers of classes of GAP library tables of marks",
type:= "values",
viewLabel:= "# classes",
align:= "tr",
create:= function( attr, id )
local r;
TomLibData.PrepareAttributeComputation();
if IsBound( TomLibData.TableInfo.( id ) ) then
r:= TomLibData.TableInfo.( id );
if IsList( r.SubsTom ) then
return Length( r.SubsTom );
fi;
fi;
return fail;
end,
viewSort:= BrowseData.CompareAsNumbersAndNonnumbers,
sortParameters:= [ "add counter on categorizing", "yes" ],
) );
#############################################################################
##
#V TomLibData.IdEnumerator.attributes.Filename
##
DatabaseAttributeAdd( TomLibData.IdEnumerator, rec(
identifier:= "Filename",
description:= "filenames of GAP library tables of marks",
type:= "values",
align:= "tl",
create:= function( attr, id )
local pos;
pos:= Position( LIBTOMLIST.names, LowercaseString( id ) );
if pos = fail then
return fail;
fi;
return Concatenation( LIBTOMLIST.files[ LIBTOMLIST.positions[ pos ][1] ],
".tom" );
end,
sortParameters:= [ "add counter on categorizing", "yes" ],
) );
#############################################################################
##
#V TomLibData.IdEnumerator.attributes.FusionsFrom
##
DatabaseAttributeAdd( TomLibData.IdEnumerator, rec(
identifier:= "FusionsFrom",
description:= "fusions from other tables of marks to the given one",
type:= "values",
align:= "tl",
categoryValue:= function( val )
if IsEmpty( val ) then
return "(no fusions to these tables)";
fi;
return List( val, x -> Concatenation( "fusions from ", x ) );
end,
create:= function( attr, id )
# Make sure that no tables of marks are constructed here!
return DuplicateFreeList( List( NotifiedFusionsToLibTom( id ),
x -> x[1] ) );
end,
viewValue:= x -> rec( rows:= x, align:= "tl" ),
viewLabel:= "fusions -> G",
sortParameters:= [ "add counter on categorizing", "yes",
"split rows on categorizing", "yes" ],
) );
#############################################################################
##
#V TomLibData.IdEnumerator.attributes.FusionsTo
##
DatabaseAttributeAdd( TomLibData.IdEnumerator, rec(
identifier:= "FusionsTo",
description:= "fusions from the given table of marks to other ones",
type:= "values",
align:= "tl",
categoryValue:= function( val )
if IsEmpty( val ) then
return "(no fusions from these tables)";
fi;
return List( val, x -> Concatenation( "fusions to ", x ) );
end,
create:= function( attr, id )
# Make sure that no tables of marks are constructed here!
return DuplicateFreeList( List( NotifiedFusionsOfLibTom( id ),
x -> x[1] ) );
end,
viewValue:= x -> rec( rows:= x, align:= "tl" ),
viewLabel:= "fusions G ->",
sortParameters:= [ "add counter on categorizing", "yes",
"split rows on categorizing", "yes" ],
) );
#############################################################################
##
#F BrowseTomLibInfo()
##
#T Admit an argument, as in BrowseTransitiveGroupsInfo?
##
BindGlobal( "BrowseTomLibInfo", function()
NCurses.BrowseGeneric(
BrowseTableFromDatabaseIdEnumerator( TomLibData.IdEnumerator,
[ "self" ],
[ "Size", "NrClasses", "FusionsFrom", "FusionsTo", "Filename" ],
t -> BrowseData.HeaderWithRowCounter( t,
"GAP Tables of Marks Library Overview", t.work.m ) ) );
end );
#############################################################################
##
#E
|