summaryrefslogtreecommitdiff
path: root/src/mongo/s/type_lockpings.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/s/type_lockpings.cpp')
-rw-r--r--src/mongo/s/type_lockpings.cpp129
1 files changed, 65 insertions, 64 deletions
diff --git a/src/mongo/s/type_lockpings.cpp b/src/mongo/s/type_lockpings.cpp
index 47beaea1485..c24d09a3506 100644
--- a/src/mongo/s/type_lockpings.cpp
+++ b/src/mongo/s/type_lockpings.cpp
@@ -32,91 +32,92 @@
namespace mongo {
- using std::string;
+using std::string;
- using mongoutils::str::stream;
+using mongoutils::str::stream;
- const std::string LockpingsType::ConfigNS = "config.lockpings";
+const std::string LockpingsType::ConfigNS = "config.lockpings";
- const BSONField<std::string> LockpingsType::process("_id");
- const BSONField<Date_t> LockpingsType::ping("ping");
+const BSONField<std::string> LockpingsType::process("_id");
+const BSONField<Date_t> LockpingsType::ping("ping");
- LockpingsType::LockpingsType() {
- clear();
- }
+LockpingsType::LockpingsType() {
+ clear();
+}
- LockpingsType::~LockpingsType() {
- }
+LockpingsType::~LockpingsType() {}
- bool LockpingsType::isValid(std::string* errMsg) const {
- std::string dummy;
- if (errMsg == NULL) {
- errMsg = &dummy;
- }
-
- // All the mandatory fields must be present.
- if (!_isProcessSet) {
- *errMsg = stream() << "missing " << process.name() << " field";
- return false;
- }
- if (!_isPingSet) {
- *errMsg = stream() << "missing " << ping.name() << " field";
- return false;
- }
-
- return true;
+bool LockpingsType::isValid(std::string* errMsg) const {
+ std::string dummy;
+ if (errMsg == NULL) {
+ errMsg = &dummy;
}
- BSONObj LockpingsType::toBSON() const {
- BSONObjBuilder builder;
-
- if (_isProcessSet) builder.append(process(), _process);
- if (_isPingSet) builder.append(ping(), _ping);
-
- return builder.obj();
+ // All the mandatory fields must be present.
+ if (!_isProcessSet) {
+ *errMsg = stream() << "missing " << process.name() << " field";
+ return false;
+ }
+ if (!_isPingSet) {
+ *errMsg = stream() << "missing " << ping.name() << " field";
+ return false;
}
- bool LockpingsType::parseBSON(const BSONObj& source, string* errMsg) {
- clear();
+ return true;
+}
- std::string dummy;
- if (!errMsg) errMsg = &dummy;
+BSONObj LockpingsType::toBSON() const {
+ BSONObjBuilder builder;
- FieldParser::FieldState fieldState;
- fieldState = FieldParser::extract(source, process, &_process, errMsg);
- if (fieldState == FieldParser::FIELD_INVALID) return false;
- _isProcessSet = fieldState == FieldParser::FIELD_SET;
+ if (_isProcessSet)
+ builder.append(process(), _process);
+ if (_isPingSet)
+ builder.append(ping(), _ping);
- fieldState = FieldParser::extract(source, ping, &_ping, errMsg);
- if (fieldState == FieldParser::FIELD_INVALID) return false;
- _isPingSet = fieldState == FieldParser::FIELD_SET;
+ return builder.obj();
+}
- return true;
- }
+bool LockpingsType::parseBSON(const BSONObj& source, string* errMsg) {
+ clear();
- void LockpingsType::clear() {
+ std::string dummy;
+ if (!errMsg)
+ errMsg = &dummy;
- _process.clear();
- _isProcessSet = false;
+ FieldParser::FieldState fieldState;
+ fieldState = FieldParser::extract(source, process, &_process, errMsg);
+ if (fieldState == FieldParser::FIELD_INVALID)
+ return false;
+ _isProcessSet = fieldState == FieldParser::FIELD_SET;
- _ping = Date_t();
- _isPingSet = false;
+ fieldState = FieldParser::extract(source, ping, &_ping, errMsg);
+ if (fieldState == FieldParser::FIELD_INVALID)
+ return false;
+ _isPingSet = fieldState == FieldParser::FIELD_SET;
- }
+ return true;
+}
- void LockpingsType::cloneTo(LockpingsType* other) const {
- other->clear();
+void LockpingsType::clear() {
+ _process.clear();
+ _isProcessSet = false;
- other->_process = _process;
- other->_isProcessSet = _isProcessSet;
+ _ping = Date_t();
+ _isPingSet = false;
+}
- other->_ping = _ping;
- other->_isPingSet = _isPingSet;
+void LockpingsType::cloneTo(LockpingsType* other) const {
+ other->clear();
- }
+ other->_process = _process;
+ other->_isProcessSet = _isProcessSet;
- std::string LockpingsType::toString() const {
- return toBSON().toString();
- }
+ other->_ping = _ping;
+ other->_isPingSet = _isPingSet;
+}
+
+std::string LockpingsType::toString() const {
+ return toBSON().toString();
+}
-} // namespace mongo
+} // namespace mongo