Lets do away with this

Consistency.

Change-Id: Iea670b77ab5f3f668183eac52f3ae8db92d79a40
This commit is contained in:
Pranav Kant 2017-07-07 12:17:11 +05:30
parent b97e02bcfc
commit 13a541e4bb

View file

@ -50,7 +50,7 @@ int Document::expireView(const std::string& sessionId)
if (--_activeViews == 0) if (--_activeViews == 0)
_end = std::time(nullptr); _end = std::time(nullptr);
} }
this->takeSnapshot(); takeSnapshot();
return _activeViews; return _activeViews;
} }
@ -61,12 +61,12 @@ std::pair<std::time_t, std::string> Document::getSnapshot() const
std::ostringstream oss; std::ostringstream oss;
oss << "{"; oss << "{";
oss << "\"creationTime\"" << ":" << ct << ","; oss << "\"creationTime\"" << ":" << ct << ",";
oss << "\"memoryDirty\"" << ":" << this->getMemoryDirty() << ","; oss << "\"memoryDirty\"" << ":" << getMemoryDirty() << ",";
oss << "\"activeViews\"" << ":" << this->getActiveViews() << ","; oss << "\"activeViews\"" << ":" << getActiveViews() << ",";
oss << "\"views\"" << ":["; oss << "\"views\"" << ":[";
std::string separator; std::string separator;
for (auto view : this->getViews()) for (auto view : getViews())
{ {
oss << separator << "\""; oss << separator << "\"";
if(view.second.isExpired()) if(view.second.isExpired())
@ -78,7 +78,7 @@ std::pair<std::time_t, std::string> Document::getSnapshot() const
} }
oss << "],"; oss << "],";
oss << "\"lastActivity\"" << ":" << this->_lastActivity; oss << "\"lastActivity\"" << ":" << _lastActivity;
oss << "}"; oss << "}";
return std::make_pair(ct, oss.str()); return std::make_pair(ct, oss.str());
} }
@ -87,11 +87,11 @@ const std::string Document::getHistory() const
{ {
std::ostringstream oss; std::ostringstream oss;
oss << "{"; oss << "{";
oss << "\"docKey\"" << ":\"" << this->_docKey << "\","; oss << "\"docKey\"" << ":\"" << _docKey << "\",";
oss << "\"filename\"" << ":\"" << this->getFilename() << "\","; oss << "\"filename\"" << ":\"" << getFilename() << "\",";
oss << "\"start\"" << ":" << this->_start << ","; oss << "\"start\"" << ":" << _start << ",";
oss << "\"end\"" << ":" << this->_end << ","; oss << "\"end\"" << ":" << _end << ",";
oss << "\"pid\"" << ":" << this->getPid() << ","; oss << "\"pid\"" << ":" << getPid() << ",";
oss << "\"snapshots\"" << ":["; oss << "\"snapshots\"" << ":[";
std::string separator; std::string separator;
for (auto s : _snapshots) for (auto s : _snapshots)
@ -105,7 +105,7 @@ const std::string Document::getHistory() const
void Document::takeSnapshot() void Document::takeSnapshot()
{ {
auto p = this->getSnapshot(); auto p = getSnapshot();
auto insPoint = _snapshots.upper_bound(p.first); auto insPoint = _snapshots.upper_bound(p.first);
_snapshots.insert(insPoint, p); _snapshots.insert(insPoint, p);
} }
@ -114,13 +114,13 @@ std::string Document::to_string() const
{ {
std::ostringstream oss; std::ostringstream oss;
std::string encodedFilename; std::string encodedFilename;
Poco::URI::encode(this->getFilename(), " ", encodedFilename); Poco::URI::encode(getFilename(), " ", encodedFilename);
oss << this->getPid() << ' ' oss << getPid() << ' '
<< encodedFilename << ' ' << encodedFilename << ' '
<< this->getActiveViews() << ' ' << getActiveViews() << ' '
<< this->getMemoryDirty() << ' ' << getMemoryDirty() << ' '
<< this->getElapsedTime() << ' ' << getElapsedTime() << ' '
<< this->getIdleTime() << ' '; << getIdleTime() << ' ';
return oss.str(); return oss.str();
} }