Base classes for IDs for various objects. The idea is to use them to uniquely
identify the respective objects without actually holding a pointer to them. They will eventually also become persistable which will allow e.g. to associate (and store) settings with the objects. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31630 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
72e9c66b4d
commit
d26889cca5
36
src/apps/debugger/ids/FunctionID.cpp
Normal file
36
src/apps/debugger/ids/FunctionID.cpp
Normal file
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#include "FunctionID.h"
|
||||
|
||||
#include "StringUtils.h"
|
||||
|
||||
|
||||
FunctionID::FunctionID(const BString& idString)
|
||||
:
|
||||
fIDString(idString)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
FunctionID::~FunctionID()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
FunctionID::operator==(const ObjectID& other) const
|
||||
{
|
||||
const FunctionID* functionID = dynamic_cast<const FunctionID*>(&other);
|
||||
return functionID != NULL && fIDString == functionID->fIDString;
|
||||
}
|
||||
|
||||
|
||||
uint32
|
||||
FunctionID::ComputeHashValue() const
|
||||
{
|
||||
return StringUtils::HashValue(fIDString);
|
||||
}
|
29
src/apps/debugger/ids/FunctionID.h
Normal file
29
src/apps/debugger/ids/FunctionID.h
Normal file
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef FUNCTION_ID_H
|
||||
#define FUNCTION_ID_H
|
||||
|
||||
|
||||
#include <String.h>
|
||||
|
||||
#include "ObjectID.h"
|
||||
|
||||
|
||||
class FunctionID : public ObjectID {
|
||||
public:
|
||||
FunctionID(const BString& idString);
|
||||
virtual ~FunctionID();
|
||||
|
||||
virtual bool operator==(const ObjectID& other) const;
|
||||
|
||||
protected:
|
||||
virtual uint32 ComputeHashValue() const;
|
||||
|
||||
private:
|
||||
const BString fIDString;
|
||||
};
|
||||
|
||||
|
||||
#endif // FUNCTION_ID_H
|
13
src/apps/debugger/ids/FunctionParameterID.cpp
Normal file
13
src/apps/debugger/ids/FunctionParameterID.cpp
Normal file
@ -0,0 +1,13 @@
|
||||
/*
|
||||
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#include "FunctionParameterID.h"
|
||||
|
||||
|
||||
FunctionParameterID::~FunctionParameterID()
|
||||
{
|
||||
}
|
||||
|
18
src/apps/debugger/ids/FunctionParameterID.h
Normal file
18
src/apps/debugger/ids/FunctionParameterID.h
Normal file
@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef FUNCTION_PARAMETER_ID_H
|
||||
#define FUNCTION_PARAMETER_ID_H
|
||||
|
||||
|
||||
#include "ObjectID.h"
|
||||
|
||||
|
||||
class FunctionParameterID : public ObjectID {
|
||||
public:
|
||||
virtual ~FunctionParameterID();
|
||||
};
|
||||
|
||||
|
||||
#endif // FUNCTION_PARAMETER_ID_H
|
13
src/apps/debugger/ids/LocalVariableID.cpp
Normal file
13
src/apps/debugger/ids/LocalVariableID.cpp
Normal file
@ -0,0 +1,13 @@
|
||||
/*
|
||||
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#include "LocalVariableID.h"
|
||||
|
||||
|
||||
LocalVariableID::~LocalVariableID()
|
||||
{
|
||||
}
|
||||
|
18
src/apps/debugger/ids/LocalVariableID.h
Normal file
18
src/apps/debugger/ids/LocalVariableID.h
Normal file
@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef LOCAL_VARIABLE_ID_H
|
||||
#define LOCAL_VARIABLE_ID_H
|
||||
|
||||
|
||||
#include "ObjectID.h"
|
||||
|
||||
|
||||
class LocalVariableID : public ObjectID {
|
||||
public:
|
||||
virtual ~LocalVariableID();
|
||||
};
|
||||
|
||||
|
||||
#endif // LOCAL_VARIABLE_ID_H
|
19
src/apps/debugger/ids/ObjectID.cpp
Normal file
19
src/apps/debugger/ids/ObjectID.cpp
Normal file
@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#include "ObjectID.h"
|
||||
|
||||
|
||||
ObjectID::ObjectID()
|
||||
:
|
||||
fHashValue(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
ObjectID::~ObjectID()
|
||||
{
|
||||
}
|
46
src/apps/debugger/ids/ObjectID.h
Normal file
46
src/apps/debugger/ids/ObjectID.h
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef OBJECT_ID_H
|
||||
#define OBJECT_ID_H
|
||||
|
||||
|
||||
#include <Referenceable.h>
|
||||
|
||||
|
||||
class ObjectID : public Referenceable {
|
||||
public:
|
||||
ObjectID();
|
||||
virtual ~ObjectID();
|
||||
|
||||
inline uint32 HashValue() const;
|
||||
|
||||
virtual bool operator==(const ObjectID& other) const = 0;
|
||||
inline bool operator!=(const ObjectID& other) const;
|
||||
|
||||
protected:
|
||||
virtual uint32 ComputeHashValue() const = 0;
|
||||
|
||||
protected:
|
||||
mutable uint32 fHashValue;
|
||||
};
|
||||
|
||||
|
||||
uint32
|
||||
ObjectID::HashValue() const
|
||||
{
|
||||
if (fHashValue == 0)
|
||||
fHashValue = ComputeHashValue();
|
||||
return fHashValue;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
ObjectID::operator!=(const ObjectID& other) const
|
||||
{
|
||||
return !(*this == other);
|
||||
}
|
||||
|
||||
|
||||
#endif // OBJECT_ID_H
|
Loading…
Reference in New Issue
Block a user