kresources
KRES::IdMapper Class Reference
Keeps a map of paths and identifiers. More...
#include <idmapper.h>
Public Member Functions | |
IdMapper (const QString &path, const QString &identifier=QString()) | |
IdMapper () | |
~IdMapper () | |
QString | asString () const |
void | clear () |
QString | fingerprint (const QString &localId) const |
QString | identifier () const |
bool | load () |
QString | localId (const QString &remoteId) const |
QString | path () const |
QString | remoteId (const QString &localId) const |
QMap< QString, QString > | remoteIdMap () const |
void | removeRemoteId (const QString &remoteId) |
bool | save () |
void | setFingerprint (const QString &localId, const QString &fingerprint) |
void | setIdentifier (const QString &identifier) |
void | setPath (const QString &path) |
void | setRemoteId (const QString &localId, const QString &remoteId) |
Protected Member Functions | |
QString | filename () |
Detailed Description
Keeps a map of paths and identifiers.
An Id Mapper maps Ids. What to or what for is not entirely clear, but maps have categories. This is probably an adjoint functor, since adjoint functors are everywhere.
Definition at line 51 of file idmapper.h.
Constructor & Destructor Documentation
KRES::IdMapper::IdMapper | ( | ) |
Create Id mapper.
You have to set path and identifier before you can call load() or save().
Definition at line 47 of file idmapper.cpp.
KRES::IdMapper::IdMapper | ( | const QString & | path, | |
const QString & | identifier = QString() | |||
) | [explicit] |
Create Id mapper.
The path specifies the category of mapping, the identifier the concrete object.
If you don't pass an identifier you have to set it before calling load() or save().
The current implementation stores the data at /share/apps/<path>/<identifier>.
- Parameters:
-
path Category of mapping (path into the mapping namespace) identifier The concrete mapping object (filename in namespace)
Definition at line 52 of file idmapper.cpp.
KRES::IdMapper::~IdMapper | ( | ) |
Destructor.
Definition at line 59 of file idmapper.cpp.
Member Function Documentation
QString KRES::IdMapper::asString | ( | ) | const |
Returns a string representation of the id pairs, that's useful for debugging.
Definition at line 202 of file idmapper.cpp.
void KRES::IdMapper::clear | ( | ) |
Clears the map.
Definition at line 148 of file idmapper.cpp.
QString KRES::IdMapper::filename | ( | ) | [protected] |
Filename of the map when stored on disk.
Definition at line 84 of file idmapper.cpp.
QString KRES::IdMapper::fingerprint | ( | const QString & | localId | ) | const |
Returns the fingerprint for the map.
- Parameters:
-
localId Local Id to get the fingerprint for.
- Todo:
- Figure out if this returns the last fingerprint set by setFingerprint() only or if anything else can change it.
Definition at line 225 of file idmapper.cpp.
QString KRES::IdMapper::identifier | ( | ) | const |
Return id map identifier.
Definition at line 79 of file idmapper.cpp.
bool KRES::IdMapper::load | ( | ) |
Loads the map.
Definition at line 95 of file idmapper.cpp.
QString KRES::IdMapper::localId | ( | const QString & | remoteId | ) | const |
Returns the local id for the given remote id.
- Parameters:
-
remoteId Remote Id to get the local Id for.
Definition at line 190 of file idmapper.cpp.
QString KRES::IdMapper::path | ( | ) | const |
Return id map path.
Definition at line 69 of file idmapper.cpp.
QString KRES::IdMapper::remoteId | ( | const QString & | localId | ) | const |
Returns the remote id of the given local id.
- Parameters:
-
localId Local Id to get the remote Id from.
- See also:
- setRemoteId()
- removeRemoteId()
Definition at line 178 of file idmapper.cpp.
QMap< QString, QString > KRES::IdMapper::remoteIdMap | ( | ) | const |
Returns the entire map of local-to-remote Ids.
Definition at line 234 of file idmapper.cpp.
void KRES::IdMapper::removeRemoteId | ( | const QString & | remoteId | ) |
Removes the remote id.
- Parameters:
-
remoteId remote Id to remove.
- Todo:
- So what does that do? Remove local Ids with only that one remote Id? Remove the remote Id from all local Ids that have it?
- See also:
- setRemoteId()
Definition at line 161 of file idmapper.cpp.
bool KRES::IdMapper::save | ( | ) |
Saves the map.
Definition at line 123 of file idmapper.cpp.
void KRES::IdMapper::setFingerprint | ( | const QString & | localId, | |
const QString & | fingerprint | |||
) |
Stores a fingerprint for an id which can be used to detect if the locally held version differs from what is on the server.
This can be a sequence number of an md5 hash depending on what the server provides.
- Parameters:
-
localId Local Id to set the fingerprint on. fingerprint Fingerprint (any string will do, though an md5 hash is probably a good idea) of the Id.
Definition at line 218 of file idmapper.cpp.
void KRES::IdMapper::setIdentifier | ( | const QString & | identifier | ) |
Set id map identifier.
- Parameters:
-
identifier the identifier (filename) within the mapping namespace
Definition at line 74 of file idmapper.cpp.
void KRES::IdMapper::setPath | ( | const QString & | path | ) |
Set id map path.
- Parameters:
-
path Path to use into mapping namespace.
- See also:
- IdMapper()
Definition at line 64 of file idmapper.cpp.
void KRES::IdMapper::setRemoteId | ( | const QString & | localId, | |
const QString & | remoteId | |||
) |
Stores the remote id for the given local id.
- Parameters:
-
localId Local Id to set remote for. remoteId Remote Id to associate with this local Id.
- See also:
- remoteId()
- localId()
- Todo:
- What happens when you set the same remote Id for more than one localId?
Definition at line 154 of file idmapper.cpp.
The documentation for this class was generated from the following files: