summaryrefslogtreecommitdiff
path: root/src/mongo/s/catalog/type_database.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/s/catalog/type_database.h')
-rw-r--r--src/mongo/s/catalog/type_database.h121
1 files changed, 65 insertions, 56 deletions
diff --git a/src/mongo/s/catalog/type_database.h b/src/mongo/s/catalog/type_database.h
index 95735903307..e452bd826a2 100644
--- a/src/mongo/s/catalog/type_database.h
+++ b/src/mongo/s/catalog/type_database.h
@@ -35,67 +35,76 @@
namespace mongo {
- class BSONObj;
- class Status;
- template<typename T> class StatusWith;
+class BSONObj;
+class Status;
+template <typename T>
+class StatusWith;
- /**
- * This class represents the layout and contents of documents contained in the config.databases
- * collection. All manipulation of documents coming from that collection should be done with
- * this class.
- */
- class DatabaseType {
- public:
- // Name of the databases collection in the config server.
- static const std::string ConfigNS;
-
- static const BSONField<std::string> name;
- static const BSONField<std::string> primary;
- static const BSONField<bool> sharded;
-
-
- /**
- * Constructs a new DatabaseType object from BSON. Also does validation of the contents.
- */
- static StatusWith<DatabaseType> fromBSON(const BSONObj& source);
-
- /**
- * Returns OK if all fields have been set. Otherwise returns NoSuchKey and information
- * about what is the first field which is missing.
- */
- Status validate() const;
-
- /**
- * Returns the BSON representation of the entry.
- */
- BSONObj toBSON() const;
-
- /**
- * Returns a std::string representation of the current internal state.
- */
- std::string toString() const;
-
- const std::string& getName() const { return _name.get(); }
- void setName(const std::string& name);
+/**
+ * This class represents the layout and contents of documents contained in the config.databases
+ * collection. All manipulation of documents coming from that collection should be done with
+ * this class.
+ */
+class DatabaseType {
+public:
+ // Name of the databases collection in the config server.
+ static const std::string ConfigNS;
- const std::string& getPrimary() const { return _primary.get(); }
- void setPrimary(const std::string& primary);
+ static const BSONField<std::string> name;
+ static const BSONField<std::string> primary;
+ static const BSONField<bool> sharded;
- bool getSharded() const { return _sharded.get(); }
- void setSharded(bool sharded) { _sharded = sharded; }
- private:
- // Requred database name
- boost::optional<std::string> _name;
+ /**
+ * Constructs a new DatabaseType object from BSON. Also does validation of the contents.
+ */
+ static StatusWith<DatabaseType> fromBSON(const BSONObj& source);
- // Required primary shard (must be set even if the database is sharded, because there
- // might be collections, which are unsharded).
- boost::optional<std::string> _primary;
+ /**
+ * Returns OK if all fields have been set. Otherwise returns NoSuchKey and information
+ * about what is the first field which is missing.
+ */
+ Status validate() const;
- // Required whether sharding is enabled for this database. Even though this field is of
- // type optional, it is only used as an indicator that the value was explicitly set.
- boost::optional<bool> _sharded;
- };
+ /**
+ * Returns the BSON representation of the entry.
+ */
+ BSONObj toBSON() const;
-} // namespace mongo
+ /**
+ * Returns a std::string representation of the current internal state.
+ */
+ std::string toString() const;
+
+ const std::string& getName() const {
+ return _name.get();
+ }
+ void setName(const std::string& name);
+
+ const std::string& getPrimary() const {
+ return _primary.get();
+ }
+ void setPrimary(const std::string& primary);
+
+ bool getSharded() const {
+ return _sharded.get();
+ }
+ void setSharded(bool sharded) {
+ _sharded = sharded;
+ }
+
+private:
+ // Requred database name
+ boost::optional<std::string> _name;
+
+ // Required primary shard (must be set even if the database is sharded, because there
+ // might be collections, which are unsharded).
+ boost::optional<std::string> _primary;
+
+ // Required whether sharding is enabled for this database. Even though this field is of
+ // type optional, it is only used as an indicator that the value was explicitly set.
+ boost::optional<bool> _sharded;
+};
+
+} // namespace mongo