kresources
#include <idmapper.h>
Public Member Functions | |
IdMapper () | |
IdMapper (const QString &path, const QString &identifier=QString()) | |
~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 55 of file idmapper.cpp.
|
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 60 of file idmapper.cpp.
KRES::IdMapper::~IdMapper | ( | ) |
Destructor.
Definition at line 67 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 210 of file idmapper.cpp.
void KRES::IdMapper::clear | ( | ) |
Clears the map.
Definition at line 156 of file idmapper.cpp.
|
protected |
Filename of the map when stored on disk.
Definition at line 92 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 233 of file idmapper.cpp.
QString KRES::IdMapper::identifier | ( | ) | const |
Return id map identifier.
Definition at line 87 of file idmapper.cpp.
bool KRES::IdMapper::load | ( | ) |
Loads the map.
Definition at line 103 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 198 of file idmapper.cpp.
QString KRES::IdMapper::path | ( | ) | const |
Return id map path.
Definition at line 77 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 186 of file idmapper.cpp.
QMap< QString, QString > KRES::IdMapper::remoteIdMap | ( | ) | const |
Returns the entire map of local-to-remote Ids.
Definition at line 242 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 169 of file idmapper.cpp.
bool KRES::IdMapper::save | ( | ) |
Saves the map.
Definition at line 131 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 226 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 82 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 72 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 162 of file idmapper.cpp.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:00:19 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.