Mercurial > hg > orthanc
diff OrthancServer/ServerIndexChange.h @ 1240:62c35e4b67db
refactoring
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 05 Dec 2014 17:12:35 +0100 |
parents | 1169528a9a5f |
children | 58e6a89c3ef4 |
line wrap: on
line diff
--- a/OrthancServer/ServerIndexChange.h Fri Dec 05 16:22:18 2014 +0100 +++ b/OrthancServer/ServerIndexChange.h Fri Dec 05 17:12:35 2014 +0100 @@ -33,28 +33,57 @@ #pragma once #include "ServerEnumerations.h" +#include "../Core/Toolbox.h" #include <string> +#include <json/value.h> namespace Orthanc { struct ServerIndexChange { private: + int64_t seq_; ChangeType changeType_; ResourceType resourceType_; std::string publicId_; + std::string date_; public: ServerIndexChange(ChangeType changeType, ResourceType resourceType, - const std::string& publicId) : + const std::string& publicId) : + seq_(-1), changeType_(changeType), resourceType_(resourceType), - publicId_(publicId) + publicId_(publicId), + date_(Toolbox::GetNowIsoString()) { } + ServerIndexChange(int64_t seq, + ChangeType changeType, + ResourceType resourceType, + const std::string& publicId, + const std::string& date) : + seq_(seq), + changeType_(changeType), + resourceType_(resourceType), + publicId_(publicId), + date_(date) + { + } + + int64_t GetSeq() const + { + return seq_; + } + + void SetSeq(int64_t seq) + { + seq_ = seq; + } + ChangeType GetChangeType() const { return changeType_; @@ -69,5 +98,21 @@ { return publicId_; } + + const std::string& GetDate() const + { + return date_; + } + + void Format(Json::Value& item) const + { + item = Json::objectValue; + item["Seq"] = static_cast<int>(seq_); + item["ChangeType"] = EnumerationToString(changeType_); + item["ResourceType"] = EnumerationToString(resourceType_); + item["ID"] = publicId_; + item["Path"] = GetBasePath(resourceType_, publicId_); + item["Date"] = date_; + } }; }