-
Notifications
You must be signed in to change notification settings - Fork 610
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added TIdWrapper class for BS_Controller
Added TIdWrapper class for BS_Controller Added hash for IdWrapper Small fix Small changes Start testing Wrapped TGroupId Implemented TGroupId partly in bscontroller, blobstorage and dsproxy Minor changes in TGroupId Minor changes Added IdWrapper for bscontroller, partly for blobstorage, nodewarden, dsproxy
- Loading branch information
Showing
105 changed files
with
683 additions
and
516 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
#pragma once | ||
#include "defs.h" | ||
#include <compare> | ||
#include <concepts> | ||
#include <util/generic/string.h> | ||
#include <util/string/builder.h> | ||
using TString = TBasicString<char>; | ||
|
||
class TGroupIdTag; | ||
template <class T> | ||
concept IntegralType = std::is_integral<T>::value; | ||
|
||
template <class T> | ||
concept StringType = std::convertible_to<T, TString>; | ||
template <typename T, typename Tag> class TIdWrapper { | ||
private: | ||
T Raw; | ||
|
||
public: | ||
using Type = T; | ||
using TTag = Tag; | ||
|
||
constexpr TIdWrapper() noexcept : Raw(0) {} | ||
|
||
~TIdWrapper() = default; | ||
|
||
explicit TIdWrapper(const T &value) : Raw(value) {} | ||
|
||
TIdWrapper(TIdWrapper &&value) = default; | ||
|
||
TIdWrapper(const TIdWrapper &other) = default; | ||
|
||
TIdWrapper &operator=(const TIdWrapper &value) = default; | ||
|
||
TIdWrapper &operator=(TIdWrapper &&value) = default; | ||
|
||
TString ToString() const { | ||
return TStringBuilder() << Raw; | ||
} | ||
|
||
void CopyToProto(NProtoBuf::Message *message, | ||
void (NProtoBuf::Message::*pfn)(T value)) { | ||
(message->*pfn)(*this); | ||
} | ||
|
||
static constexpr TIdWrapper FromValue(T value) noexcept { | ||
return TIdWrapper(value); | ||
} | ||
|
||
static constexpr TIdWrapper Zero() noexcept { return TIdWrapper(); } | ||
|
||
TIdWrapper &operator+=(const T &other) { | ||
Raw += other.Raw; | ||
return *this; | ||
} | ||
|
||
friend TIdWrapper operator+(const TIdWrapper &first, | ||
const T &second) Y_WARN_UNUSED_RESULT { | ||
return TIdWrapper(first->Raw + second); | ||
} | ||
|
||
TIdWrapper &operator++() { | ||
Raw++; | ||
return *this; | ||
} | ||
|
||
TIdWrapper operator++(int) { | ||
TIdWrapper old = *this; | ||
operator++(); | ||
return old; | ||
} | ||
|
||
friend std::ostream &operator<<(std::ostream &out, TIdWrapper &id) { | ||
return out << id.Raw; | ||
} | ||
|
||
friend IOutputStream& operator<<(IOutputStream& out, const TIdWrapper& id) { | ||
return out << id.Raw; | ||
} | ||
|
||
constexpr auto operator<=>(const TIdWrapper &) const = default; | ||
|
||
T GetRawId() const { return Raw; } | ||
|
||
friend std::hash<TIdWrapper<T, Tag>>; | ||
friend THash<TIdWrapper<T, Tag>>; | ||
}; | ||
|
||
template <typename T, typename Tag> struct std::hash<TIdWrapper<T, Tag>> { | ||
std::size_t operator()(const TIdWrapper<T, Tag> &id) const { | ||
return std::hash<T>{}(id.Raw); | ||
} | ||
}; | ||
|
||
template <typename T, typename Tag> struct THash<TIdWrapper<T, Tag>> { | ||
std::size_t operator()(const TIdWrapper<T, Tag> &id) const { | ||
return THash<T>()(id.Raw); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.