NAME
TM::MapSphere - Interface for a TM Repository
SYNOPSIS
use TM::MapSphere;
# yet empty repository
my $ms = new TM::MapSphere;
# mount something at /
$ms->mount ('/' => new TM);
# mount something else
$ms->mount ('/abc/' => new TM);
# any subclass of TM can be here
$ms->mount ('/def/' => new TM::Materialized::AsTMa);
# check a mount point
print "damn" if $ms->is_mounted ('/xxx/');
# do some sync stuff on any resource-connected map
$ms->is_mounted ('/def/')->sync_in;
# get rid of some mount point
$ms->umount ('/abc/');
# map spheres behave as maps!
# find all child maps
@maps = $ms->instances (\ TM::PSI->TOPICMAP);
print $ms->mids ('def'); # this topic exists and should be a map
DESCRIPTION
This package serves as a container to hold topic maps (and other objects), all organized as a topic map itself. Obviously, this provides a hierarchical topic map database. On the top level, addressed as /
is the root map. The child maps have addresses such as <C/abc/> and /internet/web/browsers
.
The individual maps can be of different provenience. Any subclass of TM will do, consequently also any subclass of TM::Resource. This implies that this database can be heterogenic, in that different maps can be stored differently, or can even be kept remotely. And it implies that you can decide whether the whole repository is ephemeral (using a memory-only map) or whether it is persistent by using a subclass of TM::Resource.
Tau Objects
Map spheres can only store Tau objects. At the moment, these are only maps. See TM::PSI for predefined things.
Namespace
To address a particular object in a repository we follow a convention similar to file system paths: Every object has a path like
/something/complete/else/
Note, that all paths for maps should start and end with a /
, so that maps can be seen as directories. All other objects (constraints, queries, ...) are represented as topics.
The namespace cannot have holes, so that the following will result in an error:
$ms->mount ('/something/', ...);
$ms->mount ('/something/completely/else/', ....); # we will die here
Map Meta Data
Since a map sphere behaves like a map, any meta data about child maps should be modelled according to the TM paradigm.
INTERFACE
This interface allows to mount and unmount other maps into another.
The idea is that a map can contain other maps, simply by having topics which stand for these child maps. In that sense, a map is always a tree of maps (Map Sphere). These trees are not necessarily static. At any point, a new map can be hooked in, or removed. This process is quite similar to mounting devices into a UNIX file system, hence the naming.
Constructor
The constructor does not expect any parameters.
Methods
- mount
-
$ms->mount ($path => $tm2)
This mounts a map
$tm2
into the map sphere at the given path. Only maps can be mounted, everything else results in an error. If the mount point is already taken, this is an error too.A topic of type
topicmap
(see TM::PSI) is created in the map above the mount point. The base URI of the map is used as subject address. If the mounted map has a resource URL that is used as subject indicator. - umount
-
$ms->umount ($path)
This unmounts a map from the object map. Obviously, the path must point to an existing topic. All maps beyond this mount point are removed.
- is_mounted
-
$tm = $ms->is_mounted ($path)
Simply returns a map on that given mount point.
undef
if there is none. - sync_in
-
$ms->sync_in ($path)
A whole subtree of the repository can be sync'ed in, i.e. synchronized with contents in an associated resource. If this method is triggered with a particular path, then the map there will be (a) synced in, (b) queried for sub-maps and (c) these sub-maps will be instantiated. Recursively, these submaps will be sync'ed in, etc. All these sub maps will be mounted under this branch of the tree.
When a map is instantiated, its implementation package will be extracted from the parent map using a
implementation
characteristic. The resource URL will be determined from one of the subject indicators, the base URI will be determined from the subject address of the map topic. If any of these are missing, this particular sub-map is ignored.
AUTHOR
Robert Barta, <drrho@cpan.org>
COPYRIGHT AND LICENSE
Copyright (C) 200[4-6] by Robert Barta
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.4 or, at your option, any later version of Perl 5 you may have available.