2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
7 #include "FunctionID.h"
13 #include "StringUtils.h"
16 // #pragma mark - FunctionID
19 FunctionID::FunctionID(const BMessage
& archive
)
21 BArchivable(const_cast<BMessage
*>(&archive
))
23 archive
.FindString("FunctionID::path", &fPath
);
24 archive
.FindString("FunctionID::functionName", &fFunctionName
);
28 FunctionID::FunctionID(const BString
& path
, const BString
& functionName
)
31 fFunctionName(functionName
)
36 FunctionID::~FunctionID()
42 FunctionID::Archive(BMessage
* archive
, bool deep
) const
44 status_t error
= BArchivable::Archive(archive
, deep
);
48 error
= archive
->AddString("FunctionID::path", fPath
);
50 error
= archive
->AddString("FunctionID::functionName", fFunctionName
);
56 FunctionID::ComputeHashValue() const
58 return StringUtils::HashValue(fPath
) * 17
59 + StringUtils::HashValue(fFunctionName
);
64 FunctionID::IsValid() const
66 return !fPath
.Length() == 0 && !fFunctionName
.Length() == 0;
70 // #pragma mark - SourceFunctionID
73 SourceFunctionID::SourceFunctionID(const BMessage
& archive
)
80 SourceFunctionID::SourceFunctionID(const BString
& sourceFilePath
,
81 const BString
& functionName
)
83 FunctionID(sourceFilePath
, functionName
)
88 SourceFunctionID::~SourceFunctionID()
93 /*static*/ BArchivable
*
94 SourceFunctionID::Instantiate(BMessage
* archive
)
99 SourceFunctionID
* object
= new(std::nothrow
) SourceFunctionID(*archive
);
103 if (!object
->IsValid()) {
113 SourceFunctionID::operator==(const ObjectID
& _other
) const
115 const SourceFunctionID
* other
= dynamic_cast<const SourceFunctionID
*>(
117 return other
!= NULL
&& fPath
== other
->fPath
118 && fFunctionName
== other
->fFunctionName
;
122 // #pragma mark - ImageFunctionID
125 ImageFunctionID::ImageFunctionID(const BMessage
& archive
)
132 ImageFunctionID::ImageFunctionID(const BString
& imageName
,
133 const BString
& functionName
)
135 FunctionID(imageName
, functionName
)
140 ImageFunctionID::~ImageFunctionID()
145 /*static*/ BArchivable
*
146 ImageFunctionID::Instantiate(BMessage
* archive
)
151 ImageFunctionID
* object
= new(std::nothrow
) ImageFunctionID(*archive
);
155 if (!object
->IsValid()) {
165 ImageFunctionID::operator==(const ObjectID
& _other
) const
167 const ImageFunctionID
* other
= dynamic_cast<const ImageFunctionID
*>(
169 return other
!= NULL
&& fPath
== other
->fPath
170 && fFunctionName
== other
->fFunctionName
;