.\" Automatically generated by Pod::Man 4.10 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "TM 3pm" .TH TM 3pm "2019-09-07" "perl v5.28.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" TM \- Topic Maps, Base Class .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& my $tm = new TM (baseuri => \*(Aqtm://whatever/\*(Aq); # empty map \& \& # add a toplet (= minimal topic, only identification, no characteristics) \& # by specifying an internal ID \& $tm\->internalize (\*(Aqaaa\*(Aq); # only internal identifier \& $tm\->internalize (\*(Aqbbb\*(Aq => \*(Aqhttp://bbb/\*(Aq); # with a subject address \& $tm\->internalize (\*(Aqccc\*(Aq => \e \*(Aqhttp://ccc/\*(Aq); # with a subject indicator \& \& # without specifying an internal ID (will be auto\-generated) \& $tm\->internalize (undef => \*(Aqhttp://ccc/\*(Aq); # with a subject address \& $tm\->internalize (undef => \e \*(Aqhttp://ccc/\*(Aq); # with a subject indicator \& \& # get rid of toplet(s) \& $tm\->externalize (\*(Aqtm://whatever/aaa\*(Aq, ...); \& \& # find full URI of a toplet \& my $tid = $tm\->tids (\*(Aqperson\*(Aq); # returns tm://whatever/person \& my @tids = $tm\->tids (\*(Aqperson\*(Aq, ...) # for a whole list \& \& my $tid = $tm\->tids ( \*(Aqhttp://bbb/\*(Aq); # with subject address \& my $tid = $tm\->tids (\e \*(Aqhttp://ccc/\*(Aq); # with subject indicator \& \& my @ts = $tm\->toplets; # get all toplets \& my @ts = $tm\->toplets (\e \*(Aq+all \-infrastructure\*(Aq); # only those you added \& \& my @as = $tm\->asserts (\e \*(Aq+all \-infrastructure\*(Aq); # only those you added \& \& my @as = $tm\->retrieve; # all assertions \& my $a = $tm\->retrieve (\*(Aq23ac4637....345\*(Aq); # returns only that one assertion \& my @as = $tm\->retrieve (\*(Aq23ac4637....345\*(Aq, \*(Aq...\*(Aq); # returns all these assertions \& \& # create standalone assertion \& my $a = Assertion\->new (type => \*(Aqis\-subclass\-of\*(Aq, \& roles => [ \*(Aqsubclass\*(Aq, \*(Aqsuperclass\*(Aq ], \& players => [ \*(Aqrumsti\*(Aq, \*(Aqramsti\*(Aq ]); \& $tm\->assert ($a); # add that to map \& \& # create a name \& my $n = Assertion\->new (kind => TM\->NAME, \& type => \*(Aqname\*(Aq, \& scope => \*(Aqus\*(Aq, \& roles => [ \*(Aqthing\*(Aq, \*(Aqvalue\*(Aq ], \& players => [ \*(Aqrumsti\*(Aq, new TM::Literal (\*(AqAAA\*(Aq) ]) \& # create an occurrence \& my $o = Assertion\->new (kind => TM\->OCC, \& type => \*(Aqoccurrence\*(Aq, \& scope => \*(Aqus\*(Aq, \& roles => [ \*(Aqthing\*(Aq, \*(Aqvalue\*(Aq ], \& players => [ \*(Aqrumsti\*(Aq, new TM::Literal (\*(Aqhttp://whatever/\*(Aq) ]) \& \& $tm\->assert ($n, $o); # throw them in \& \& $tm\->retract ($a\->[TM\->LID], ...); # get rid of assertion(s) \& \& my @as = $tm\->retrieve (\*(Aqid..of...assertion\*(Aq); # extract particular assertions \& \& # find particular assertions \& # generic search patterns \& my @as = $tm\->match_forall (scope => \*(Aqtm://whatever/sss\*(Aq); \& \& my @bs = $tm\->match_forall (type => \*(Aqtm://whatever/ttt\*(Aq, \& roles => [ \*(Aqtm://whatever/aaa\*(Aq, \*(Aqtm://whatever/bbb\*(Aq ]); \& \& # specialized search patterns (see TM::Axes) \& my @cs = $tm\->match_forall (type => \*(Aqis\-subclass\-of\*(Aq, \& arole => \*(Aqsuperclass\*(Aq, \& aplayer => \*(Aqtm://whatever/rumsti\*(Aq, \& brole => \*(Aqsubclass\*(Aq); \& \& my @ds = $tm\->match_forall (type => \*(Aqisa\*(Aq, \& class => \*(Aqtm://whatever/person\*(Aq); \& \& # perform merging, cleanup, etc. \& $tm\->consolidate; \& \& # check internal consistency of the data structure \& die "panic" if $tm\->insane; \& \& # taxonomy stuff \& warn "what a subtle joke" if $tm\->is_a ($tm\->tids (\*(Aqgw_bush\*(Aq, \*(Aqmoron\*(Aq)); \& \& die "what a subtle joke" \& unless $tm\->is_subclass ($tm\->tids (\*(Aqpolitician\*(Aq, \*(Aqmoron\*(Aq)); \& \& # returns Mr. Spock if Volcans are subclassing Aliens \& warn "my best friends: ". Dumper [ $tm\->instancesT ($tm\->tids (\*(Aqalien\*(Aq)) ]; .Ve .SH "ABSTRACT" .IX Header "ABSTRACT" This class provides read/write access to a data structure according to the Topic Maps paradigm. As it stands, this class implements directly so-called \fImaterialized\fR maps, i.e. those maps which completely reside in memory. Implementations for non-materialized maps can be derived from it. .SH "DESCRIPTION" .IX Header "DESCRIPTION" This class implements directly so-called \fImaterialized\fR topic maps, i.e. those maps which completely reside in memory. Non-materialized and non-materializable maps can be implemented by deriving from this class by overloading one or all of the sub-interfaces. If this is done cleverly, then any application, even a \s-1TMQL\s0 query processor can operate on non-materialized (virtual) maps in the same way as on materialized ones. .SS "Data Structures" .IX Subsection "Data Structures" The Topic Maps paradigm knows two abstractions .IP "\fI\s-1TMDM\s0\fR, Topic Maps Data Model" 4 .IX Item "TMDM, Topic Maps Data Model" .IP "\fI\s-1TMRM\s0\fR, Topic Maps Reference Model" 4 .IX Item "TMRM, Topic Maps Reference Model" .PP For historical reasons, this package adopts an abstraction which is in between these two. Accordingly, there are only following types of data structures .IP "Toplets:" 4 .IX Item "Toplets:" These are like \s-1TMDM\s0 topics, but only contain addressing information (subject identifiers and subject addresses) along with an internal identifier. .IP "Assertions:" 4 .IX Item "Assertions:" These are like \s-1TMDM\s0 associations, but are generalized to host also occurrences and names. Also associations using predefined association types, such as \f(CW\*(C`isa\*(C'\fR (\fIinstance-class\fR) and \f(CW\*(C`iko\*(C'\fR (\fIsubtype-supertype\fR) are represented as assertions. .IP "Variants:" 4 .IX Item "Variants:" No idea what they are good for. They can be probably safely ignored. .PP The data manipulation interface is very low-level and \fBdirectly\fR exposes internal data structures. As long as you do not mess with the information you get and you follow the \s-1API\s0 rules, this can provide a convenient, fast, albeit not overly comfortable interface. If you prefer more a TMDM-like style of accessing a map then have a look at \s-1TM::DM\s0. .SS "Identifiers" .IX Subsection "Identifiers" Of course, \s-1TM\s0 supports the subject locator and the subject indicator mechanism as mandated by the Topic Maps standards. .PP Additionally, this package also uses \fIinternal\fR identifiers to address everything which looks and smells like a topic, also associations, names and occurrences. For topics the application (or author) of the topic map will most likely provide these internal identifiers. For the others the identifiers are generated. .PP Since v1.31 this package distinguishes between 3 kinds of internal identifiers: .IP "\fIcanonicalized\fR toplet identifiers" 4 .IX Item "canonicalized toplet identifiers" These identifiers are always interpreted local to a map, in that the \f(CW\*(C`baseuri\*(C'\fR of the map is used as prefix. So, a local identifier .Sp .Vb 1 \& chinese\-working\-conditions .Ve .Sp will become .Sp .Vb 1 \& tm://nirvana/chinese\-working\-conditions .Ve .Sp if the base \s-1URI\s0 of the map were .Sp .Vb 1 \& tm://nirvana/ .Ve .Sp So if you want to use identifiers such as these, then you should either use the absolut version (including the base \s-1URI\s0) or use the method \f(CW\*(C`tids\*(C'\fR to find the absolute version. .IP "\fIsacrosanct\fR toplet identifiers" 4 .IX Item "sacrosanct toplet identifiers" All toplets from the infrastructure are declared \fIsacrosanct\fR, i.e. untouchable. Examples are \&\f(CW\*(C`isa\*(C'\fR, \f(CW\*(C`class\*(C'\fR or \f(CW\*(C`us\*(C'\fR (universal scope). .Sp These identifiers are always the same in all maps this package system manages. That implies that if you use such an identifier, then you cannot attach a local meaning to it. And it implies that at merging time, toplets with these identifiers will merge. Even if there were no subject indicators or addresses involved. .Sp It is probably a good idea to leave such toplets alone as the software is relying on the stability of the sacrosanct identifiers. .IP "assertion identifiers" 4 .IX Item "assertion identifiers" Each assertion also has an (internal) identifier. It is a function from the content, so it is characteristic for the assertion. .SS "Consistency" .IX Subsection "Consistency" An application using a map may expect that a map is \fIconsolidated\fR, i.e. that the following consistency conditions are met: .IP "\fBA1\fR (fixed on)" 4 .IX Item "A1 (fixed on)" Every identifier appearing in some assertion as type, scope, role or player is also registered as toplet. .IP "\fBIndicator_based_Merging\fR (default: on)" 4 .IX Item "Indicator_based_Merging (default: on)" Two (or more) toplets sharing the same \fIsubject identifier\fR are treated as one toplet. .IP "\fBSubject_based_Merging\fR (default: on)" 4 .IX Item "Subject_based_Merging (default: on)" Two (or more) toplets sharing the same \fIsubject locator\fR are treated as one toplet. .IP "\fBTNC_based_Merging\fR (default: off)" 4 .IX Item "TNC_based_Merging (default: off)" Two (or more) toplet sharing the same name in the same scope are treated as one toplet. .PP While A1 is related with the internal consistency of the data structure (see \f(CW\*(C`insane\*(C'\fR), the others are a choice the application can make (see \f(CW\*(C`consistency\*(C'\fR). .PP \&\fIConsistency\fR is not automatically provided when a map is modified by the application. It is the applications responsibility to trigger the process to consolidate the map. As that may be potentially expensive, the control remains at the application. .PP When an \s-1IO\s0 driver is consuming a map from a resource, say, loading from an \s-1XTM\s0 file, then that driver will ensure that the map is consolidated according to the current settings before it hands it to the application. The application is then in full control of the map as it can change, add and delete toplets and assertions. The map can become unconsolidated in this process. The method \&\f(CW\*(C`consolidate\*(C'\fR reinstates consistency again. .PP You can change these defaults by (a) providing an additional option to the constructor .PP .Vb 3 \& new TM (...., \& consistency => [ TM\->Subject_based_Merging, \& TM\->Indicator_based_Merging ]); .Ve .PP or (b) by later using the accessor \f(CW\*(C`consistency\*(C'\fR (see below). .SH "MAP INTERFACE" .IX Header "MAP INTERFACE" .SS "Constructor" .IX Subsection "Constructor" \&\fI\f(CI$tm\fI\fR = new \s-1TM\s0 (...) .PP The constructor will create an empty map, or, to be more exact, it will fill the map with the taxonomy from \s-1TM::PSI\s0 which covers basic Topic Maps concepts such as \fItopic\fR or \fIassociations\fR. .PP The constructor understands a number of key/value pair parameters: .ie n .IP """baseuri"" (default: ""tm://nirvana/"")" 4 .el .IP "\f(CWbaseuri\fR (default: \f(CWtm://nirvana/\fR)" 4 .IX Item "baseuri (default: tm://nirvana/)" Every toplet in the map has an unique local identifier (e.g. \f(CW\*(C`shoesize\*(C'\fR). The \f(CW\*(C`baseuri\*(C'\fR parameter controls how an absolute \s-1URI\s0 is built from this identifier. .ie n .IP """consistency"" (default: [ Subject_based_Merging, Indicator_based_Merging ])" 4 .el .IP "\f(CWconsistency\fR (default: [ Subject_based_Merging, Indicator_based_Merging ])" 4 .IX Item "consistency (default: [ Subject_based_Merging, Indicator_based_Merging ])" This controls the consistency settings. They can be changed later with the \f(CW\*(C`consistency\*(C'\fR method. .SS "Methods" .IX Subsection "Methods" .IP "\fBbaseuri\fR" 4 .IX Item "baseuri" \&\fI\f(CI$bu\fI\fR = \fI\f(CI$tm\fI\fR\->baseuri .Sp This methods retrieves the base \s-1URI\s0 component of the map. This is a read-only method. The base \s-1URI\s0 is \fBalways\fR defined. .IP "\fBconsistency\fR" 4 .IX Item "consistency" \&\fI\f(CI@merging_constraints\fI\fR = \fI\f(CI$tm\fI\fR\->consistency .Sp \&\fI\f(CI$tm\fI\fR\->consistency (\fI\f(CI@list_of_consistency_constants\fI\fR) .Sp This method provides read/write access to the consistency settings. .Sp If no parameters are provided, then the current list of consistency settings is returned. If parameters are provided, that list must consist of the constants defined under \*(L"Consistency\*(R". .Sp \&\fB\s-1NOTE\s0\fR: Changing the consistency does \fB\s-1NOT\s0\fR automatically trigger \f(CW\*(C`consolidate\*(C'\fR. .IP "\fBlast_mod\fR" 4 .IX Item "last_mod" Returns the Time::HiRes date of last time the map has been modified (content-wise). .IP "\fBconsolidate\fR" 4 .IX Item "consolidate" \&\fI\f(CI$tm\fI\fR\->consolidate .Sp \&\fI\f(CI$tm\fI\fR\->consolidate (\fI\f(CI@list_of_consistency_constants\fI\fR) .Sp This method \fIconsolidates\fR a map by performing the following actions: .RS 4 .IP "\(bu" 4 perform merging based on subject address (see \s-1TMDM\s0 section 5.3.2) .IP "\(bu" 4 perform merging based on subject indicators (see \s-1TMDM\s0 section 5.3.2) .IP "\(bu" 4 remove all superfluous toplets (those which do not take part in any assertion) .Sp \&\fB\s-1NOTE\s0\fR: Not implemented yet! .RE .RS 4 .Sp This method will normally use the map's consistency settings. These settings can be overridden by adding consistency settings as parameters (see \*(L"Consistency\*(R"). In that case the map's settings are \&\fBnot\fR modified, so use this carefully. .Sp \&\fB\s-1NOTE\s0\fR: In all cases the map will be modified. .Sp \&\fB\s-1NOTE\s0\fR: After merging some of the \fIlids\fR might not be reliably point to a topic. .RE .IP "\fBclear\fR" 4 .IX Item "clear" \&\fI\f(CI$tm\fI\fR\->clear .Sp This method removes all toplets and assertions (except the infrastructure). Everything else remains. .IP "\fBadd\fR" 4 .IX Item "add" \&\fI\f(CI$tm\fI\fR\->add (\fI\f(CI$tm2\fI\fR, ...) .Sp This method accepts a list of \s-1TM\s0 objects and adds all content from these maps to the current object. .Sp \&\fB\s-1NOTE\s0\fR: There is \fB\s-1NO\s0\fR merging done for user-supplied toplets. Use explicitly method \f(CW\*(C`consolidate\*(C'\fR for it. Merging is done for all sacrosanct toplets, i.e. those from the infrastructure. .Sp From v1.31 onwards this method tries to favour the \fIinternal\fR identifiers (LIDs) of \fBthis\fR map over LIDs of the added maps. This means, firstly, that internal identifiers of \fBthis\fR map are \&\fBnot\fR touched (or re-generated) in any way and that any shorthands (without a baseuri prefix) will remain valid when using \f(CW\*(C`tids\*(C'\fR. Secondly, LIDs in the added map will be attempted to blend into \&\fBthis\fR map by changing simply their prefix. If that newly generated \s-1LID\s0 is already taken by something in \fBthis\fR map, then the original \s-1LID\s0 will be used. That allows many added LIDs be used together with \f(CW\*(C`tids\*(C'\fR without (much) change in code. Of course, the only reliable way to reach a topic is a subject locator or an indicator. This is all about convenience. .Sp \&\fB\s-1NOTE\s0\fR: This procedure implies that some assertions are recomputed, so that also their \s-1LID\s0 will change! .IP "\fBdiff\fR" 4 .IX Item "diff" \&\fI\f(CI$diff\fI\fR = \fI\f(CI$new_tm\fI\fR\->diff (\fI\f(CI$old_tm\fI\fR) .Sp \&\fI\f(CI$diff\fI\fR = TM::diff (\fI\f(CI$new_tm\fI\fR, \fI\f(CI$old_tm\fI\fR) .Sp \&\fI\f(CI$diff\fI\fR = TM::diff (\fI\f(CI$new_tm\fI\fR, \fI\f(CI$old_tm\fI\fR, {consistency => \e \f(CW@list_of_consistency_consts\fR, include_changes => 1}) .Sp \&\f(CW\*(C`diff\*(C'\fR compares two topic maps and returns their differences as a hash reference. While it works on any two maps, it is most useful after one map (the \fIold map\fR) is modified into a \fInew map\fR. .Sp If \f(CW\*(C`diff\*(C'\fR is used in OO-style, the current map is interpreted as the \fInew\fR map and the map in the arguments as \fIthe old one\fR. .Sp By default, the toplet and assertion identifiers for any changes are returned; the option \&\f(CW\*(C`include_changes\*(C'\fR causes the return of the actual toplets and assertions themselves. This option makes \f(CW\*(C`diff\*(C'\fR's output more self-contained: enabled, one can fully (re)create the new map from the old one using the diff (or vice versa). .Sp The \f(CW\*(C`consistency\*(C'\fR option uses the same format as the \s-1TM\s0 constructor (see \*(L"Constructor\*(R") and describes how corresponding toplets in the two maps are to be identified. Toplets with the same internal ids are always considered equal. If \fIsubject based consistency\fR is active, toplets with the same \fIsubject locator\fR are considered equal (overriding the topic identities). If \fIindicator based consistency\fR is active, toplets with a matching \fIsubject indicator\fR are considered equal (overriding the previous identities). .Sp \&\fB\s-1NOTE\s0\fR: This overriding of previous conditions for identity is necessary to keep the equality relationship unique and one-to-one. As an example, consider the following scenario: a toplet \fIa\fR in the old map is split into multiple new toplets \fIa\fR and \fIb\fR in the new map. If \fIa\fR had a locator or identifier that is moved to \fIb\fR (and if consistency options were active), then the identity detector will consider \fIb\fR to be equal to \fIa\fR, and \fBnot\fR \fIa\fR in the new map to correspond to \fIa\fR in the old map. However, this will never lead to loss of information: \fIa\fR in the new map is flagged as completely new toplet. .Sp The differences between old and new map are returned underneath the keys \fIplus\fR, \fIminus\fR, \&\fIidentities\fR and \fImodified\fR. If \f(CW\*(C`include_changes\*(C'\fR is on, the extra keys \fIplus_midlets\fR, \&\fIminus_midlets\fR and \fIassertions\fR are populated. The values of all these keys are hash references themselves. .RS 4 .IP "\fIplus\fR, \fIminus\fR" 4 .IX Item "plus, minus" The \f(CW\*(C`plus\*(C'\fR and \f(CW\*(C`minus\*(C'\fR hashes list new or removed toplets, respectively (with their identifiers as keys). For each toplet, the value of the hash is an array of associated assertion ids. The array is empty but defined if there are no associated assertions. .Sp For toplets the attached assertions are the usual ones (names, occurrences) and class-instance relationships (attached to the instance toplet). .Sp For associations, the assertions are attached to the \fItype\fR toplet. .IP "\fIidentities\fR" 4 .IX Item "identities" This hash consists of the non-trivial toplet identities that were found. If neither Subject\- nor Indicator-based merging is active and if neither map object was created with a \s-1TM\s0 version before 1.31, then this hash is empty. Otherwise, the keys are toplet identifiers in the old map, with the corresponding topic identifier in the new map as value. This includes standalone topics as well as assertions and associations that were renamed due to changed player or role identities. .Sp For diff operations between maps where one map was created with a \s-1TM\s0 version before 1.31 (which can happen with frozen/thawed or MLDBM-based maps) extra identifying steps are performed (because the identifier format for assertions and infrastructure toplets and the stored format of toplets have changed). This situation is detected automatically, and if so the identities hash will also include all map elements that were identical but have different names due to the version incompatibility. .IP "\fImodified\fR" 4 .IX Item "modified" The \fImodified\fR hash contains the changes for matched toplets. The key is the toplet identifier in the old map (which is potentially different from the one in the new map; see the note about identities above). The value is a hash with three keys: \fIplus\fR, \fIminus\fR and \fIidentities\fR. The value for the \f(CW\*(C`identities\*(C'\fR key is defined if and only if the toplet associated with this toplet has changed (i.e. Subject Locator or Indicators have changed). The values for the \f(CW\*(C`plus\*(C'\fR and \f(CW\*(C`minus\*(C'\fR keys are arrays with the new or removed assertions that are attached to this toplet. These arrays are defined but empty where no applicable information is present. .IP "\fIplus_midlets\fR, \fIminus_midlets\fR" 4 .IX Item "plus_midlets, minus_midlets" These hashes hold the actual new or removed toplets if the option \f(CW\*(C`include_changes\*(C'\fR is active. Keys are the toplet ids, values are references to the actual toplet data structures. .IP "\fIassertions\fR" 4 .IX Item "assertions" This hash holds the actual assertions where the maps differ; it exists only if the option \&\f(CW\*(C`include_changes\*(C'\fR is active. Keys are the assertion identifiers, values the references to the actual assertion data structure. Note that assertion ids uniquely identify the assertion contents, therefore this hash can hold assertions from both new and old map. .RE .RS 4 .RE .IP "\fBmelt\fR (\s-1DEPRECATED\s0)" 4 .IX Item "melt (DEPRECATED)" \&\fI\f(CI$tm\fI\fR\->melt (\fI\f(CI$tm2\fI\fR) .Sp This \- probably more auxiliary \- function copies relevant aspect of a second map into the object. .IP "\fBinsane\fR" 4 .IX Item "insane" warn \*(L"topic map broken\*(R" if \fI\f(CI$tm\fI\fR\->insane .Sp This method tests invariant conditions inside the \s-1TM\s0 structure of that map. Specifically, .RS 4 .IP "\(bu" 4 each toplet has a \s-1LID\s0 which points to a toplet with the same address .RE .RS 4 .Sp It returns a string with a message or \f(CW\*(C`undef\*(C'\fR if everything seems fine. .Sp \&\s-1TODO:\s0 add test whether all variant entries have a proper \s-1LID\s0 (and toplet) .RE .SH "TOPLET INTERFACE" .IX Header "TOPLET INTERFACE" \&\fIToplets\fR are light-weight versions of \s-1TMDM\s0 topics. They only carry addressing information and are represented by an array (struct) with the following fields: .ie n .IP """lid"" (index: ""LID"")" 4 .el .IP "\f(CWlid\fR (index: \f(CWLID\fR)" 4 .IX Item "lid (index: LID)" The internal identifier. Mostly it repeats the key in the toplet hash, but also aliased identifiers may exist. .ie n .IP """saddr"" (index: ""ADDRESS"")" 4 .el .IP "\f(CWsaddr\fR (index: \f(CWADDRESS\fR)" 4 .IX Item "saddr (index: ADDRESS)" It contains the \fBsubject locator\fR (address) \s-1URI,\s0 if known. Otherwise \f(CW\*(C`undef\*(C'\fR. .ie n .IP """sinds"" (index: ""INDICATORS"")" 4 .el .IP "\f(CWsinds\fR (index: \f(CWINDICATORS\fR)" 4 .IX Item "sinds (index: INDICATORS)" This is a reference to a list containing \fBsubject identifiers\fR (indicators). The list can be empty, no duplicate removal is attempted at this stage. .PP You can create this structure manually, but mostly you would leave it to \f(CW\*(C`internalize\*(C'\fR to do the work. .PP Example: .PP .Vb 4 \& # dogmatic way to produce it \& my $to = Toplet\->new (lid => $baseuri . \*(Aqmy\-lovely\-cat\*(Aq, \& saddr => \*(Aqhttp://subject\-address.com/\*(Aq, \& sinds => []); \& \& # also good and well \& my $to = [ $baseuri . \*(Aqmy\-lovely\-cat\*(Aq, \& \*(Aqhttp://subject\-address.com/\*(Aq, \& [] ]; \& \& # better \& my $to = $tm\->internalize (\*(Aqmy\-lovely\-cat\*(Aq => \*(Aqhttp://subject\-address.com/\*(Aq); .Ve .PP To access the individual fields, you can either use the struct accessors \f(CW\*(C`saddr\*(C'\fR and \f(CW\*(C`sinds\*(C'\fR, or use the constants defined above for indices into the array: .PP Example: .PP .Vb 1 \& warn "indicators: ", join (", ", @{$to\->sinds}); \& \& warn "locator: ", $to\->[TM\->ADDRESS]; .Ve .SS "Methods" .IX Subsection "Methods" .IP "\fBinternalize\fR" 4 .IX Item "internalize" \&\fI\f(CI$iid\fI\fR = \fI\f(CI$tm\fI\fR\->internalize (\fI\f(CI$some_id\fI\fR) .Sp \&\fI\f(CI$iid\fI\fR = \fI\f(CI$tm\fI\fR\->internalize (\fI\f(CI$some_id\fI\fR => \fI\f(CI$some_id\fI\fR) .Sp \&\fI\f(CI@iids\fI\fR = \fI\f(CI$tm\fI\fR\->internalize (\fI\f(CI$some_id\fI\fR => \fI\f(CI$some_id\fI\fR, ...) .Sp This method does some trickery when a new toplet should be added to the map, depending on how parameters are passed into it. The general scheme is that pairs of identifiers are passed in. The first is usually the internal identifier, the second a subject identifier or the subject locator. The convention is that subject identifier URIs are passed in as string references, whereas subject locator URIs are passed in as strings. .Sp The following cases are covered: .RS 4 .ie n .IP """ID => undef""" 4 .el .IP "\f(CWID => undef\fR" 4 .IX Item "ID => undef" If the \s-1ID\s0 is already an absolute \s-1URI\s0 and contains the \f(CW\*(C`baseuri\*(C'\fR of the map as prefix, then this \s-1URI\s0 is used as internal toplet identifier. If the \s-1ID\s0 is some other \s-1URI,\s0 then a toplet with that \s-1URI\s0 as subject locator is searched in the map. If such a toplet already exists, then nothing special needs to happen. If no such toplet existed, a new \s-1URI,\s0 based on the \f(CW\*(C`baseuri\*(C'\fR and a random number will be created for the internal identifier and the original \s-1URI\s0 is used as subject address. .Sp \&\fB\s-1NOTE\s0\fR: Using \f(CW\*(C`URI => URI\*(C'\fR implies that you use two different URIs as subject addresses. This will result in an error. .ie n .IP """ID => URI""" 4 .el .IP "\f(CWID => URI\fR" 4 .IX Item "ID => URI" Like above, only that the \s-1URI\s0 is directly interpreted as subject address. .ie n .IP """ID => \e URI"" (reference to string)" 4 .el .IP "\f(CWID => \e URI\fR (reference to string)" 4 .IX Item "ID => URI (reference to string)" Like above, only that the \s-1URI\s0 is interpreted as another subject identifier. If the toplet already existed, then this subject identifier is simply added. Duplicates are suppressed (since v1.31). .ie n .IP """undef => URI""" 4 .el .IP "\f(CWundef => URI\fR" 4 .IX Item "undef => URI" Like above, only that the internal identifier is auto-created if there is no toplet with the \s-1URI\s0 as subject address. .Sp Attention: If you call internalize like this .Sp .Vb 1 \& $tm\->internalize(undef => $whatever) .Ve .Sp then perl will (un)helpfully replace the required undef with the string \*(L"undef\*(R" and wreck the operation. Using either a variable to hold the undef or replacing the (syntactic sugar) arrow with a comma works around this issue. .Sp Attention: If you call internalize like this .Sp .Vb 1 \& $tm\->internalize(undef => $whatever) .Ve .Sp then perl will (un)helpfully replace the required undef with the string \*(L"undef\*(R" and wreck the operation. Using either a variable to hold the undef or replacing the (syntactic sugar) arrow with a comma works around this issue. .ie n .IP """undef => \e URI""" 4 .el .IP "\f(CWundef => \e URI\fR" 4 .IX Item "undef => URI" Like above, only that the \s-1URI\s0 us used as subject identifier. .ie n .IP """undef => undef""" 4 .el .IP "\f(CWundef => undef\fR" 4 .IX Item "undef => undef" A toplet with an auto-generated \s-1ID\s0 will be inserted. .RE .RS 4 .Sp In any case, the internal identifier(s) of all inserted (or existing) toplets are returned for convenience. .RE .IP "\fBtoplet\fR (old name \fBmidlet\fR)" 4 .IX Item "toplet (old name midlet)" \&\fI\f(CI$t\fI\fR = \fI\f(CI$tm\fI\fR\->toplet (\fI\f(CI$mid\fI\fR) .Sp \&\fI\f(CI@ts\fI\fR = \fI\f(CI$tm\fI\fR\->toplet (\fI\f(CI$mid\fI\fR, ....) .Sp This function returns a reference to a toplet structure. It can be used in scalar and list context. .IP "\fBtoplets\fR (old name \fBmidlets\fR)" 4 .IX Item "toplets (old name midlets)" \&\fI\f(CI@mids\fI\fR = \fI\f(CI$tm\fI\fR\->toplets .Sp \&\fI\f(CI@mids\fI\fR = \fI\f(CI$tm\fI\fR\->toplets (\fI\f(CI@list_of_ids\fI\fR) .Sp \&\fI\f(CI@mids\fI\fR = \fI\f(CI$tm\fI\fR\->toplets (\fI\f(CI$selection_spec\fI\fR) .Sp This function returns toplet structures from the map. \fB\s-1NOTE\s0\fR: This has changed from v 1.13. Before you got ids. .Sp If no parameter is provided, all toplets are returned. This includes really everything also infrastructure toplets. If an explicit list is provided as parameter, then all toplets with these identifiers are returned. .Sp If a search specification is used, it has to be passed in as string reference. That string contains the selection specification using the following simple language (curly brackets mean repetition, round bracket grouping, vertical bar alternatives): .Sp .Vb 1 \& specification \-> { ( \*(Aq+\*(Aq | \*(Aq\-\*(Aq ) group } .Ve .Sp whereby \fIgroup\fR is one of the following: .RS 4 .ie n .IP """all""" 4 .el .IP "\f(CWall\fR" 4 .IX Item "all" refers to \fBall\fR toplets in the map. This includes those supplied by the application. The list also includes all infrastructure topics which the software maintains for completeness. .ie n .IP """infrastructure""" 4 .el .IP "\f(CWinfrastructure\fR" 4 .IX Item "infrastructure" refers to all toplets the infrastructure has provided. This implies that .Sp .Vb 1 \& all \- infrastructure .Ve .Sp is everything the user (application) has supplied. .RE .RS 4 .Sp Examples: .Sp .Vb 2 \& # all toplets except those from TM::PSI \& $tm\->toplets (\e \*(Aq+all \-infrastructure\*(Aq) .Ve .Sp \&\fB\s-1NOTE\s0\fR: No attempt is made to make this list unique. .Sp \&\fB\s-1NOTE\s0\fR: The specifications are not commutative, but are interpreted from left-to-right. So \f(CW\*(C`all \&\-infrastructure +infrastructure\*(C'\fR is not the same as \f(CW\*(C`all +infrastructure \-infrastructure\*(C'\fR. In the latter case the infrastructure toplets have been added twice, and are then deducted completely with \&\f(CW\*(C`\-infrastructure\*(C'\fR. .RE .IP "\fBtids\fR (old name \fBmids\fR)" 4 .IX Item "tids (old name mids)" \&\fI\f(CI$mid\fI\fR = \fI\f(CI$tm\fI\fR\->tids (\fI\f(CI$some_id\fI\fR) .Sp \&\fI\f(CI@mids\fI\fR = \fI\f(CI$tm\fI\fR\->tids (\fI\f(CI$some_id\fI\fR, ...) .Sp This function tries to build absolute versions of the identifiers passed in. \f(CW\*(C`undef\*(C'\fR will be returned if no such can be constructed. Can be used in scalar and list context. .RS 4 .IP "\(bu" 4 If the passed-in identifier is a relative \s-1URI,\s0 so it is made absolute by prefixing it with the map \&\f(CW\*(C`baseuri\*(C'\fR and then we look for a toplet with that internal identifier. .IP "\(bu" 4 If the passed-in identifier is an absolute \s-1URI,\s0 where the \f(CW\*(C`baseuri\*(C'\fR is a prefix, then that \s-1URI\s0 will be used as internal identifier to look for a toplet. .IP "\(bu" 4 If the passed-in identifier is an absolute \s-1URI,\s0 where the \f(CW\*(C`baseuri\*(C'\fR is \fB\s-1NOT\s0\fR a prefix, then that \&\s-1URI\s0 will be used as subject locator and such a toplet will be looked for. .IP "\(bu" 4 If the passed-in identifier is a reference to an absolute \s-1URI,\s0 then that \s-1URI\s0 will be used as subject identifier and such a toplet will be looked for. .RE .RS 4 .RE .IP "\fBexternalize\fR" 4 .IX Item "externalize" \&\fI\f(CI$tm\fI\fR\->externalize (\fI\f(CI$some_id\fI\fR, ...) .Sp This function simply deletes the toplet entry for the given internal identifier(s). The function returns all deleted toplet entries. .Sp \&\fB\s-1NOTE\s0\fR: Assertions in which this topic is involved will \fBnot\fR be removed. Use \f(CW\*(C`consolidate\*(C'\fR to clean up all assertion where non-existing toplets still exist. .SH "ASSERTIONS INTERFACE" .IX Header "ASSERTIONS INTERFACE" One assertion is a record containing its own identifier, the scope, the type of the assocation, an field whether this is an association, an occurrence or a name and then all roles and all players, both in separate lists. .PP Assertions consist of the following components: .ie n .IP "\fIlid\fR (index ""LID""):" 4 .el .IP "\fIlid\fR (index \f(CWLID\fR):" 4 .IX Item "lid (index LID):" Every assertion has an identifier. It is a unique identifier generated from a canonicalized form of the assertion itself. .ie n .IP "\fIscope\fR (index: ""SCOPE"")" 4 .el .IP "\fIscope\fR (index: \f(CWSCOPE\fR)" 4 .IX Item "scope (index: SCOPE)" This component holds the scope of the assertion. .ie n .IP "\fIkind\fR (index: ""KIND"", redundant information):" 4 .el .IP "\fIkind\fR (index: \f(CWKIND\fR, redundant information):" 4 .IX Item "kind (index: KIND, redundant information):" For technical reasons (read: it is faster) we distinguish between full associations (\f(CW\*(C`ASSOC\*(C'\fR), names (\f(CW\*(C`NAME\*(C'\fR) and occurrences (\f(CW\*(C`OCC\*(C'\fR). .ie n .IP "\fItype\fR (index: ""TYPE""):" 4 .el .IP "\fItype\fR (index: \f(CWTYPE\fR):" 4 .IX Item "type (index: TYPE):" The toplet id of the type of this assertion. .ie n .IP "\fIroles\fR (index: ""ROLES""):" 4 .el .IP "\fIroles\fR (index: \f(CWROLES\fR):" 4 .IX Item "roles (index: ROLES):" A list reference which holds a list of toplet ids for the roles. .ie n .IP "\fIplayers\fR (index: ""PLAYERS""):" 4 .el .IP "\fIplayers\fR (index: \f(CWPLAYERS\fR):" 4 .IX Item "players (index: PLAYERS):" A list reference which holds a list of toplet IDs for the players. .ie n .IP "\fIcanon\fR (index: ""CANON""):" 4 .el .IP "\fIcanon\fR (index: \f(CWCANON\fR):" 4 .IX Item "canon (index: CANON):" Either \f(CW1\fR or \f(CW\*(C`undef\*(C'\fR to signal whether this assertion has been (already) canonicalized (see \&\*(L"canonicalize\*(R"). If an assertion is canonicalized, then the players and roles lists are sorted (somehow), so that assertions can be easily compared. .PP Obviously the lists for roles and players \fBalways\fR have the same length, so that every player corresponds to exactly one role. If one role is played by several players, the role appears multiple times. .PP As a special case, names and occurrences are mapped into assertions, by .IP "\(bu" 4 setting the \fIroles\fR to \f(CW\*(C`thing\*(C'\fR and \f(CW\*(C`value\*(C'\fR, .IP "\(bu" 4 setting the \fIplayers\fR to the toplet id in question and using a TM::Literal as the player for \&\f(CW\*(C`value\*(C'\fR, .IP "\(bu" 4 using the \fItype\fR component to store the name/occurrence type, .IP "\(bu" 4 using as \fIkind\fR either \f(CW\*(C`NAME\*(C'\fR or \f(CW\*(C`OCC\*(C'\fR .PP Example: .PP .Vb 4 \& # general association \& $a = Assertion\->new (type => \*(Aqis\-subclass\-of\*(Aq, \& roles => [ \*(Aqsubclass\*(Aq, \*(Aqsuperclass\*(Aq ], \& players => [ \*(Aqrumsti\*(Aq, \*(Aqramsti\*(Aq ]) \& \& \& warn $a\->scope . " is the same as " . $a\->[TM\->SCOPE]; \& \& # create a name \& use TM::Literal; \& $n = Assertion\->new (kind => TM\->NAME, \& type => \*(Aqname\*(Aq, \& scope => \*(Aqus\*(Aq, \& roles => [ \*(Aqthing\*(Aq, \*(Aqvalue\*(Aq ], \& players => [ \*(Aqrumsti\*(Aq, \& new TM::Literal (\*(AqAAA\*(Aq) ]); \& \& # create an occurrence \& use TM::Literal; \& $n = Assertion\->new (kind => TM\->OCC, \& type => \*(Aqoccurrence\*(Aq, \& scope => \*(Aqus\*(Aq, \& roles => [ \*(Aqthing\*(Aq, \*(Aqvalue\*(Aq ], \& players => [ \*(Aqrumsti\*(Aq, \& new TM::Literal (\*(Aqhttp://whatever/\*(Aq) ]); .Ve .SS "Special Assertions" .IX Subsection "Special Assertions" This package adopts the following conventions to store certain assertions: .ie n .IP """is\-subclass\-of""" 4 .el .IP "\f(CWis\-subclass\-of\fR" 4 .IX Item "is-subclass-of" Associations of this type should have one role \f(CW\*(C`subclass\*(C'\fR and another \f(CW\*(C`superclass\*(C'\fR. The scope should always be \f(CW\*(C`us\*(C'\fR. .ie n .IP """isa""" 4 .el .IP "\f(CWisa\fR" 4 .IX Item "isa" Associations of this type should have one role \f(CW\*(C`instance\*(C'\fR and another \f(CW\*(C`class\*(C'\fR. The scope should always be \f(CW\*(C`us\*(C'\fR. .ie n .IP """NAME""" 4 .el .IP "\f(CWNAME\fR" 4 .IX Item "NAME" Assertions for names should have the \f(CW\*(C`KIND\*(C'\fR component set to it and use the \f(CW\*(C`TYPE\*(C'\fR component to store the name type. The two roles to use are \f(CW\*(C`value\*(C'\fR for the value and \f(CW\*(C`thing\*(C'\fR for the toplet carrying the name. .ie n .IP """OCC""" 4 .el .IP "\f(CWOCC\fR" 4 .IX Item "OCC" Assertions for occurrences should have the \f(CW\*(C`KIND\*(C'\fR component set to it and use the \f(CW\*(C`TYPE\*(C'\fR component to store the occurrence type. The two roles to use are \f(CW\*(C`value\*(C'\fR for the value and \f(CW\*(C`thing\*(C'\fR for the toplet carrying the name. .SS "Methods" .IX Subsection "Methods" .IP "\fBassert\fR" 4 .IX Item "assert" \&\fI\f(CI@as\fI\fR = \fI\f(CI$tm\fI\fR\->assert (\fI\f(CI@list\fI\-of\-assertions\fR) .Sp This method takes a list of assertions, canonicalizes them and then injects them into the map. If one of the newly added assertions already existed in the map, it will be ignored. .Sp In this process, all assertions will be completed (if fields are missing). .RS 4 .ie n .IP "If an assertion does not have a type, it will default to $TM::PSI::THING." 4 .el .IP "If an assertion does not have a type, it will default to \f(CW$TM::PSI::THING\fR." 4 .IX Item "If an assertion does not have a type, it will default to $TM::PSI::THING." .PD 0 .ie n .IP "If an assertion does not have a scope, it defaults to $TM::PSI::US." 4 .el .IP "If an assertion does not have a scope, it defaults to \f(CW$TM::PSI::US\fR." 4 .IX Item "If an assertion does not have a scope, it defaults to $TM::PSI::US." .RE .RS 4 .PD .Sp Then the assertion will be canonicalized (unless it already was). This implies that non-canonicalized assertions will be modified, in that the role/player lists change. Any assertion not having an \s-1LID\s0 will get one. .Sp The method returns a list of all asserted assertions. .Sp Example: .Sp .Vb 2 \& my $a = Assertion\->new (type => \*(Aqrumsti\*(Aq); \& $tm\->assert ($a); .Ve .Sp \&\fB\s-1NOTE\s0\fR: Maybe the type will default to \fIassociation\fR in the future. .RE .IP "\fBretrieve\fR" 4 .IX Item "retrieve" \&\fI\f(CI$assertion\fI\fR = \fI\f(CI$tm\fI\fR\->retrieve (\fI\f(CI$some_assertion_id\fI\fR) .Sp \&\fI\f(CI@assertions\fI\fR = \fI\f(CI$tm\fI\fR\->retrieve (\fI\f(CI$some_assertion_id\fI\fR, ...) .Sp This method takes a list of assertion IDs and returns the assertion(s) with the given (subject) \&\s-1ID\s0(s). If the assertion is not identifiable, \f(CW\*(C`undef\*(C'\fR will be returned in its place. Called in list context, it will return a list of assertion references. .IP "\fBasserts\fR" 4 .IX Item "asserts" \&\fI\f(CI@assertions\fI\fR = \fI\f(CI$tm\fI\fR\->asserts (\fI\f(CI$selection_spec\fI\fR) .Sp If a search specification is used, it has to be passed in as string reference. That string contains the selection specification using the following simple language (curly brackets mean repetition, round bracket grouping, vertical bar alternatives): .Sp .Vb 1 \& specification \-> { ( \*(Aq+\*(Aq | \*(Aq\-\*(Aq ) group } .Ve .Sp whereby \fIgroup\fR is one of the following: .RS 4 .ie n .IP """all""" 4 .el .IP "\f(CWall\fR" 4 .IX Item "all" refers to \fBall\fR assertions in the map. This includes those supplied by the application, but also all predefined associations, names and occurrences. .ie n .IP """associations""" 4 .el .IP "\f(CWassociations\fR" 4 .IX Item "associations" refers to all assertions which are actually associations .ie n .IP """names""" 4 .el .IP "\f(CWnames\fR" 4 .IX Item "names" refers to all assertions which are actually name characteristics .ie n .IP """occurrences""" 4 .el .IP "\f(CWoccurrences\fR" 4 .IX Item "occurrences" refers to all assertions which are actually occurrences .ie n .IP """infrastructure""" 4 .el .IP "\f(CWinfrastructure\fR" 4 .IX Item "infrastructure" refers to all assertions the infrastructure has provided. This implies that .Sp .Vb 1 \& all \- infrastructure .Ve .Sp is everything the user (application) has supplied. .RE .RS 4 .Sp Examples: .Sp .Vb 2 \& # all toplets except those from TM::PSI \& $tm\->asserts (\e \*(Aq+all \-infrastructure\*(Aq) \& \& # like above, without assocs, so with names and occurrences \& $tm\->asserts (\e \*(Aq+all \-associations\*(Aq) .Ve .Sp \&\fB\s-1NOTE\s0\fR: No attempt is made to make this list unique. .Sp \&\fB\s-1NOTE\s0\fR: The specifications are not commutative, but are interpreted from left-to-right. So \f(CW\*(C`all \&\-associations +associations\*(C'\fR is not the same as \f(CW\*(C`all +associations \-associations\*(C'\fR. \&\f(CW\*(C`\-infrastructure\*(C'\fR. .RE .IP "\fBis_asserted\fR" 4 .IX Item "is_asserted" \&\fI\f(CI$bool\fI\fR = \fI\f(CI$tm\fI\fR\->is_asserted (\fI\f(CI$a\fI\fR) .Sp This method will return \f(CW1\fR if the passed-in assertion exists in the store. The assertion will be canonicalized before checking, but no defaults will be added if parts are missing. .IP "\fBretract\fR" 4 .IX Item "retract" \&\fI\f(CI$tm\fI\fR\->retract (\fI\f(CI@list_of_assertion_ids\fI\fR) .Sp This methods expects a list of assertion IDs and will remove the assertions from the map. If an \s-1ID\s0 is bogus, it will be ignored. .Sp \&\fB\s-1NOTE\s0\fR: Only these particular assertions will be deleted. Any toplets mentioned in these assertions will remain. Use \f(CW\*(C`consolidate\*(C'\fR to remove unnecessary toplets. .IP "\fBmatch\fR, \fBmatch_forall\fR, \fBmatch_exists\fR" 4 .IX Item "match, match_forall, match_exists" \&\fI\f(CI@assertions\fI\fR = \fI\f(CI$tm\fI\fR\->match (\s-1TM\-\s0>\s-1FORALL\s0 [ , \fIsearch-spec\fR ] ); .Sp \&\fI\f(CI@assertions\fI\fR = \fI\f(CI$tm\fI\fR\->match (\s-1TM\-\s0>\s-1EXISTS\s0 [ , \fIsearch-spec\fR ] ); .Sp \&\fI\f(CI@assertions\fI\fR = \fI\f(CI$tm\fI\fR\->match_forall ( [ \fIsearch-spec\fR ] ); .Sp \&\fI\f(CI@assertions\fI\fR = \fI\f(CI$tm\fI\fR\->match_exists ( [ \fIsearch-spec\fR ] ); .Sp These methods take a search specification and return matching assertions. The result list contains references to the assertions themselves, not to copies. You can change the assertions themselves on your own risk (read: better not do it). .Sp For \f(CW\*(C`match\*(C'\fR, if the constant \f(CW\*(C`FORALL\*(C'\fR is used as first parameter, this method returns a list of \&\fBall\fR assertions in the store following the search specification. If the constant \f(CW\*(C`EXISTS\*(C'\fR is used, the method will return a non-empty value if \fBat least one\fR can be found. Calling the more specific \f(CW\*(C`match_forall\*(C'\fR is the same as calling \f(CW\*(C`match\*(C'\fR with \f(CW\*(C`FORALL\*(C'\fR. Similar for \&\f(CW\*(C`match_exists\*(C'\fR. .Sp \&\fB\s-1NOTE\s0\fR: \f(CW\*(C`EXISTS\*(C'\fR is not yet implemented. .Sp For \fIsearch specifications\fR there are two alternatives: .RS 4 .IP "Generic Search" 4 .IX Item "Generic Search" Here the search specification is a hash with the same fields as for the constructor of an assertion: .Sp Example: .Sp .Vb 4 \& $tm\->match (TM\->FORALL, type => \*(Aq...\*(Aq, \& scope => \*(Aq..., \& roles => [ ...., ....], \& players => [ ...., ....]); .Ve .Sp Any combination of assertion components can be used, all are optional, with the only constraint that the number of roles must match that for the players. All involved IDs should be absolutized before matching. If you use \f(CW\*(C`undef\*(C'\fR for a role or a player, then this is interpreted as \fIdont-care\fR (wildcard). .IP "Specialized Search" 4 .IX Item "Specialized Search" The implementation also understands a number of specialized search specifications. These are listed in TM::Axes. .RE .RS 4 .Sp \&\fB\s-1NOTE\s0\fR: Some combinations will be very fast, while others quite slow. If you experience problems, then it might be time to think about indexing (see TM::Index). .Sp \&\fB\s-1NOTE\s0\fR: For the assertion type and the role subclassing is honored. .RE .SS "Role Retrieval" .IX Subsection "Role Retrieval" .IP "\fBis_player\fR, \fBis_x_player\fR" 4 .IX Item "is_player, is_x_player" \&\fI\f(CI$bool\fI\fR = is_player (\fI\f(CI$tm\fI\fR, \fI\f(CI$assertion\fI\fR, \fI\f(CI$player_id\fI\fR, [ \fI\f(CI$role_id\fI\fR ]) .Sp \&\fI\f(CI$bool\fI\fR = is_x_player (\fI\f(CI$tm\fI\fR, \fI\f(CI$assertion\fI\fR, \fI\f(CI$player_id\fI\fR, [ \fI\f(CI$role_id\fI\fR ]) .Sp This function returns \f(CW1\fR if the identifier specified by the \f(CW\*(C`player_id\*(C'\fR parameter plays any role in the assertion provided as \f(CW\*(C`assertion\*(C'\fR parameter. .Sp If the \f(CW\*(C`role_id\*(C'\fR is provided as third parameter then it must be exactly this role (or any subclass thereof) that is played. The 'x'\-version is using equality instead of 'subclassing' ('x' for \&\*(L"exact\*(R"). .IP "\fBget_players\fR, \fBget_x_players\fR" 4 .IX Item "get_players, get_x_players" \&\fI\f(CI@player_ids\fI\fR = get_players (\fI\f(CI$tm\fI\fR, \fI\f(CI$assertion\fI\fR, [ \fI\f(CI$role_id\fI\fR ]) .Sp \&\fI\f(CI@player_ids\fI\fR = get_x_players (\fI\f(CI$tm\fI\fR, \fI\f(CI$assertion\fI\fR, \fI\f(CI$role_id\fI\fR) .Sp This function returns the player(s) for the given role. If the role is not provided all players are returned. .Sp The \*(L"x\*(R" version does not honor subclassing. .IP "\fBis_role\fR, \fBis_x_role\fR" 4 .IX Item "is_role, is_x_role" \&\fI\f(CI$bool\fI\fR = is_role (\fI\f(CI$tm\fI\fR, \fI\f(CI$assertion\fI\fR, \fI\f(CI$role_id\fI\fR) .Sp \&\fI\f(CI$bool\fI\fR = is_x_role (\fI\f(CI$tm\fI\fR, \fI\f(CI$assertion\fI\fR, \fI\f(CI$role_id\fI\fR) .Sp This function returns \f(CW1\fR if the \f(CW\*(C`role_id\*(C'\fR is a role in the assertion provided. The \*(L"x\*(R" version of this function does not honor subclassing. .IP "\fBget_roles\fR" 4 .IX Item "get_roles" \&\fI\f(CI@role_ids\fI\fR = get_roles (\fI\f(CI$tm\fI\fR, \fI\f(CI$assertion\fI\fR, \fI\f(CI$player\fI\fR) .Sp This function returns a list of roles a particular player plays in a given assertion. .IP "\fBget_role_s\fR" 4 .IX Item "get_role_s" \&\fI\f(CI@role_ids\fI\fR = @{ get_role_s (\fI\f(CI$tm\fI\fR, \fI\f(CI$assertion\fI\fR) } .Sp This function extracts a reference to the list of role identifiers. .SS "Auxiliary Functions" .IX Subsection "Auxiliary Functions" .IP "\fBabsolutize\fR" 4 .IX Item "absolutize" \&\fI\f(CI$assertion\fI\fR = absolutize (\fI\f(CI$tm\fI\fR, \fI\f(CI$assertion\fI\fR) .Sp This method takes one assertion and makes sure that all identifiers in it (for the type, the scope and all the role and players) are made absolute for the context map. It returns this very assertion. It will not touch canonicalized assertions. .IP "\fBcanonicalize\fR" 4 .IX Item "canonicalize" \&\fI\f(CI$assertion\fI\fR = canonicalize (\fI\f(CI$tm\fI\fR, \fI\f(CI$assertion\fI\fR) .Sp This method takes an assertion and reorders the roles (together with their respective players) in a consistent way. It also makes sure that the \s-1KIND\s0 is defined (defaults to \f(CW\*(C`ASSOC\*(C'\fR), that the type is defined (defaults to \f(CW\*(C`THING\*(C'\fR) and that all references are made absolute LIDs. Finally, the field \&\f(CW\*(C`CANON\*(C'\fR is set to 1 to indicate that the assertion is canonicalized. .Sp The function will not do anything if the assertion is already canonicalized. The component \f(CW\*(C`CANON\*(C'\fR is set to \f(CW1\fR if the assertion has been canonicalized. .Sp Conveniently, the function returns the same assertion, albeit a maybe modified one. .Sp \&\s-1TODO:\s0 remove map parameter, it is no longer necessary .SH "TAXONOMICS AND SUBSUMPTION" .IX Header "TAXONOMICS AND SUBSUMPTION" The following methods provide useful basic, ontological functionality around transitive subclassing between classes and instance/type relationships. .PP \&\fB\s-1NOTE\s0\fR: Everything is a subclass of \f(CW\*(C`thing\*(C'\fR (changed in v1.35). .PP \&\fB\s-1NOTE\s0\fR: Everything is an instance of \f(CW\*(C`thing\*(C'\fR. .PP \&\fB\s-1NOTE\s0\fR: See \s-1TM::PSI\s0 for predefined things. .SS "Boolean Methods" .IX Subsection "Boolean Methods" .IP "\fBis_subclass\fR" 4 .IX Item "is_subclass" \&\fI\f(CI$bool\fI\fR = \fI\f(CI$tm\fI\fR\->is_subclass (\fI\f(CI$superclass_id\fI\fR, \fI\f(CI$subclass_id\fI\fR) .Sp This function returns \f(CW1\fR if the first parameter is a (transitive) superclass of the second, i.e. there is an assertion of type \fIis-subclass-of\fR in the context map. It also returns \f(CW1\fR if the superclass is a \f(CW$TM::PSI::THING\fR or if subclass and superclass are the same (reflexive). .IP "\fBis_a\fR" 4 .IX Item "is_a" \&\fI\f(CI$bool\fI\fR = \fI\f(CI$tm\fI\fR\->is_a (\fI\f(CI$something_lid\fI\fR, \fI\f(CI$class_lid\fI\fR) .Sp This method returns \f(CW1\fR if the thing referenced by the first parameter is an instance of the class referenced by the second. The method honors transitive subclassing. .SS "List Methods" .IX Subsection "List Methods" .IP "\fBsubclasses\fR, \fBsubclassesT\fR" 4 .IX Item "subclasses, subclassesT" \&\fI\f(CI@lids\fI\fR = \fI\f(CI$tm\fI\fR\->subclasses (\fI\f(CI$lid\fI\fR, ...) .Sp \&\fI\f(CI@lids\fI\fR = \fI\f(CI$tm\fI\fR\->subclassesT (\fI\f(CI$lid\fI\fR, ...) .Sp \&\f(CW\*(C`subclasses\*(C'\fR returns all \fBdirect\fR subclasses of the toplet identified by \f(CW$lid\fR. If the toplet does not exist, the list will be empty. \f(CW\*(C`subclassesT\*(C'\fR is a variant which honors the transitive subclassing (so if A is a subclass of B and B is a subclass of C, then A is also a subclass of C). .Sp Duplicates are suppressed. .IP "\fBsuperclasses\fR, \fBsuperclassesT\fR" 4 .IX Item "superclasses, superclassesT" \&\fI\f(CI@lids\fI\fR = \fI\f(CI$tm\fI\fR\->superclasses (\fI\f(CI$lid\fI\fR, ...) .Sp \&\fI\f(CI@lids\fI\fR = \fI\f(CI$tm\fI\fR\->superclassesT (\fI\f(CI$lid\fI\fR, ...) .Sp The method \f(CW\*(C`superclasses\*(C'\fR returns all direct superclasses of the toplet identified by \f(CW$lid\fR. If the toplet does not exist, the list will be empty. \f(CW\*(C`superclassesT\*(C'\fR is a variant which honors transitive subclassing. .Sp Duplicates are suppressed. .IP "\fBtypes\fR, \fBtypesT\fR" 4 .IX Item "types, typesT" \&\fI\f(CI@lids\fI\fR = \fI\f(CI$tm\fI\fR\->types (\fI\f(CI$lid\fI\fR, ...) .Sp \&\fI\f(CI@lids\fI\fR = \fI\f(CI$tm\fI\fR\->typesT (\fI\f(CI$lid\fI\fR, ...) .Sp The method \f(CW\*(C`types\*(C'\fR returns all direct classes of the toplet identified by \f(CW$lid\fR. If the toplet does not exist, the list will be empty. \f(CW\*(C`typesT\*(C'\fR is a variant which honors transitive subclassing (so if \&\fIa\fR is an instance of type \fIA\fR and \fIA\fR is a subclass of \fIB\fR, then \fIa\fR is also an instance of \&\fIB\fR). .Sp Duplicates will be suppressed. .IP "\fBinstances\fR, \fBinstancesT\fR" 4 .IX Item "instances, instancesT" \&\fI\f(CI@lids\fI\fR = \fI\f(CI$tm\fI\fR\->instances (\fI\f(CI$lid\fI\fR, ...) .Sp \&\fI\f(CI@lids\fI\fR = \fI\f(CI$tm\fI\fR\->instancesT (\fI\f(CI$lid\fI\fR, ...) .Sp These methods return the direct (\f(CW\*(C`instances\*(C'\fR) and also indirect (\f(CW\*(C`instancesT\*(C'\fR) instances of the toplet identified by \f(CW$lid\fR. .Sp Duplicates are suppressed. .SS "Filters" .IX Subsection "Filters" Quite often one needs to walk through a list of things to determine whether they are instances (or types, subtypes or supertypes) of some concept. This list of functions lets you do that: you pass in a list (reference) and the function behaves as filter, returning a list reference. .IP "\fBare_instances\fR" 4 .IX Item "are_instances" \&\fI\f(CI@id\fI\fR = \fI\f(CI$tm\fI\fR\->are_instances (\fI\f(CI$class_id\fI\fR, \fI\f(CI@list_of_ids\fI\fR) .Sp Returns all those ids where the topic is an instance of the class provided. .IP "\fBare_types\fR (Warning: placeholder only)" 4 .IX Item "are_types (Warning: placeholder only)" \&\fI\f(CI@ids\fI\fR = \fI\f(CI$tm\fI\fR\->are_types (\fI\f(CI$instance_id\fI\fR, \fI\f(CI@list_of_ids\fI\fR) .Sp Returns all those ids where the topic is a type of the instance provided. .IP "\fBare_supertypes\fR (Warning: placeholder only)" 4 .IX Item "are_supertypes (Warning: placeholder only)" \&\fI\f(CI@ids\fI\fR = \fI\f(CI$tm\fI\fR\->are_supertypes (\fI\f(CI$class_id\fI\fR, \fI\f(CI@list_of_ids\fI\fR) .Sp Returns all those ids where the topic is a supertype of the class provided. .IP "\fBare_subtypes\fR (Warning: placeholder only)" 4 .IX Item "are_subtypes (Warning: placeholder only)" \&\fI\f(CI@ids\fI\fR = \fI\f(CI$tm\fI\fR\->are_subtypes (\fI\f(CI$class_id\fI\fR, \fI\f(CI@list_of_ids\fI\fR) .Sp Returns all those ids where the topic is a subtype of the class provided. .SH "REIFICATION" .IX Header "REIFICATION" .IP "\fBis_reified\fR" 4 .IX Item "is_reified" (\fI\f(CI$tid\fI\fR) = \fI\f(CI$tm\fI\fR\->is_reified (\fI\f(CI$assertion\fI\fR) .Sp (\fI\f(CI$tid\fI\fR) = \fI\f(CI$tm\fI\fR\->is_reified (\fI\f(CI$url\fI\fR) .Sp In the case that the handed-in assertion is internally reified in the map, this method will return the internal identifier of the reifying toplet. Or \f(CW\*(C`undef\*(C'\fR if there is none. .Sp In the case that the handed-in \s-1URL\s0 is used as subject address of a toplet, this method will return the internal identifier of the reifying toplet. Or \f(CW\*(C`undef\*(C'\fR if there is none. .IP "\fBreifies\fR" 4 .IX Item "reifies" \&\fI\f(CI$url\fI\fR = \fI\f(CI$tm\fI\fR\->reifies (\fI\f(CI$tid\fI\fR) .Sp \&\fI\f(CI$assertion\fI\fR = \fI\f(CI$tm\fI\fR\->reifies (\fI\f(CI$tid\fI\fR) .Sp Given a toplet identifier, this method returns either the internally reified assertion, an externally reified object via its \s-1URL,\s0 or \f(CW\*(C`undef\*(C'\fR if that toplet does not reify at all. .ie n .SH "VARIANTS (aka ""The Warts"")" .el .SH "VARIANTS (aka ``The Warts'')" .IX Header "VARIANTS (aka The Warts)" No comment. .IP "\fBvariants\fR" 4 .IX Item "variants" \&\fI\f(CI$tm\fI\fR\->variants (\fI\f(CI$id\fI\fR, \fI\f(CI$variant\fI\fR) .Sp \&\fI\f(CI$tm\fI\fR\->variants (\fI\f(CI$id\fI\fR) .Sp With this method you can get/set a variant tree for \fBany\fR topic. According to the standard only basenames (aka topic names) can have variants, but, hey, this is such an ugly beast (I am digressing). According to this data model you can have variants for \fBall\fR toplets/maplets. You only need their id. .Sp The structure is like this: .Sp .Vb 10 \& $VAR1 = { \& \*(Aqtm:param1\*(Aq => { \& \*(Aqvariants\*(Aq => { \& \*(Aqtm:param3\*(Aq => { \& \*(Aqvariants\*(Aq => undef, \& \*(Aqvalue\*(Aq => \*(Aqname for param3\*(Aq \& } \& }, \& \*(Aqvalue\*(Aq => \*(Aqname for param1\*(Aq \& }, \& \*(Aqtm:param2\*(Aq => { \& \*(Aqvariants\*(Aq => undef, \& \*(Aqvalue\*(Aq => \*(Aqname for param2\*(Aq \& } \& }; .Ve .Sp The parameters are the keys (there can only be one, which is a useful, cough, restriction of the standard) and the data is the value. Obviously, one key value (i.e. parameter) can only exists once. .Sp Caveat: This is not very well tested (read: not tested at all). .SH "LOGGING" .IX Header "LOGGING" The \s-1TM\s0 module hosts (since 1.29) the Log4Perl object \f(CW$TM::log\fR. It is initialized with some reasonable defaults, but an using application can access it, tweak it, or overwrite it completely. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\s-1TM::PSI\s0, Log::Log4perl .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" Copyright 200[1\-8] by Robert Barta, .PP This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.