Browse Source

db manager encapsulation and logic implementation. need to test.

youchen 5 years ago
parent
commit
11b1c36e5b

+ 5 - 0
error_code/error_code.h

@@ -307,6 +307,11 @@ enum Error_code
     DB_DELETE_FAILED,                               //数据库删除失败
     DB_UPDATE_FAILED,                               //数据库更新失败
     DB_QUERY_FAILED,                                //数据库查询失败
+    DB_UNINITIALIZED,                               //数据库外层未初始化
+    DB_DISCONNECTED,                                //数据库外层连接失去
+    DB_RESULT_SET_EMPTY,                            //数据库外层查询返回结果空指针
+    DB_RESULT_SET_PARSE_ERROR,                      //数据库外层查询结果解析失败
+
 };
 
 //错误等级,用来做故障处理

+ 66 - 48
message/parkspace_allocation_message.pb.cc

@@ -390,7 +390,7 @@ void InitDefaultsParkspace_allocation_status_msg() {
 }
 
 ::google::protobuf::Metadata file_level_metadata[13];
-const ::google::protobuf::EnumDescriptor* file_level_enum_descriptors[2];
+const ::google::protobuf::EnumDescriptor* file_level_enum_descriptors[3];
 
 const ::google::protobuf::uint32 TableStruct::offsets[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
   GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::message::Car_info, _has_bits_),
@@ -424,12 +424,12 @@ const ::google::protobuf::uint32 TableStruct::offsets[] GOOGLE_PROTOBUF_ATTRIBUT
   GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::message::Parkspace_info, leave_time_),
   3,
   4,
-  10,
   5,
   6,
   7,
   8,
   9,
+  10,
   2,
   0,
   1,
@@ -680,13 +680,16 @@ void AddDescriptorsImpl() {
       "anager\030\002 \002(\0132\026.message.Error_manager\022/\n\016"
       "parkspace_info\030\003 \003(\0132\027.message.Parkspace"
       "_info*\207\001\n\020Parkspace_status\022\024\n\020eParkspace"
-      "_empty\020\000\022\025\n\021eParkspace_locked\020\001\022\027\n\023ePark"
-      "space_occupied\020\002\022\027\n\023eParkspace_reserved\020"
-      "\003\022\024\n\020eParkspace_error\020\004*(\n\tDirection\022\014\n\010"
-      "eForward\020\001\022\r\n\teBackward\020\002"
+      "_empty\020\000\022\027\n\023eParkspace_occupied\020\001\022\027\n\023ePa"
+      "rkspace_reserved\020\002\022\025\n\021eParkspace_locked\020"
+      "\003\022\024\n\020eParkspace_error\020\004*\177\n\016Vehicle_statu"
+      "s\022\021\n\reVehicle_idle\020\000\022\026\n\022eVehicle_in_gara"
+      "ge\020\001\022\024\n\020eVehicle_parking\020\002\022\025\n\021eVehicle_f"
+      "etching\020\003\022\025\n\021eVehicle_reserved\020\004*(\n\tDire"
+      "ction\022\014\n\010eForward\020\000\022\r\n\teBackward\020\001"
   };
   ::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
-      descriptor, 2505);
+      descriptor, 2634);
   ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
     "parkspace_allocation_message.proto", &protobuf_RegisterTypes);
   ::protobuf_message_5fbase_2eproto::AddDescriptors();
@@ -721,14 +724,31 @@ bool Parkspace_status_IsValid(int value) {
   }
 }
 
-const ::google::protobuf::EnumDescriptor* Direction_descriptor() {
+const ::google::protobuf::EnumDescriptor* Vehicle_status_descriptor() {
   protobuf_parkspace_5fallocation_5fmessage_2eproto::protobuf_AssignDescriptorsOnce();
   return protobuf_parkspace_5fallocation_5fmessage_2eproto::file_level_enum_descriptors[1];
 }
-bool Direction_IsValid(int value) {
+bool Vehicle_status_IsValid(int value) {
   switch (value) {
+    case 0:
     case 1:
     case 2:
+    case 3:
+    case 4:
+      return true;
+    default:
+      return false;
+  }
+}
+
+const ::google::protobuf::EnumDescriptor* Direction_descriptor() {
+  protobuf_parkspace_5fallocation_5fmessage_2eproto::protobuf_AssignDescriptorsOnce();
+  return protobuf_parkspace_5fallocation_5fmessage_2eproto::file_level_enum_descriptors[2];
+}
+bool Direction_IsValid(int value) {
+  switch (value) {
+    case 0:
+    case 1:
       return true;
     default:
       return false;
@@ -1188,8 +1208,8 @@ Parkspace_info::Parkspace_info(const Parkspace_info& from)
     car_info_ = NULL;
   }
   ::memcpy(&parkspace_id_, &from.parkspace_id_,
-    static_cast<size_t>(reinterpret_cast<char*>(&direction_) -
-    reinterpret_cast<char*>(&parkspace_id_)) + sizeof(direction_));
+    static_cast<size_t>(reinterpret_cast<char*>(&parkspace_status_) -
+    reinterpret_cast<char*>(&parkspace_id_)) + sizeof(parkspace_status_));
   // @@protoc_insertion_point(copy_constructor:message.Parkspace_info)
 }
 
@@ -1200,7 +1220,6 @@ void Parkspace_info::SharedCtor() {
   ::memset(&car_info_, 0, static_cast<size_t>(
       reinterpret_cast<char*>(&parkspace_status_) -
       reinterpret_cast<char*>(&car_info_)) + sizeof(parkspace_status_));
-  direction_ = 1;
 }
 
 Parkspace_info::~Parkspace_info() {
@@ -1260,14 +1279,13 @@ void Parkspace_info::Clear() {
   }
   if (cached_has_bits & 248u) {
     ::memset(&parkspace_id_, 0, static_cast<size_t>(
-        reinterpret_cast<char*>(&width_) -
-        reinterpret_cast<char*>(&parkspace_id_)) + sizeof(width_));
+        reinterpret_cast<char*>(&length_) -
+        reinterpret_cast<char*>(&parkspace_id_)) + sizeof(length_));
   }
   if (cached_has_bits & 1792u) {
-    ::memset(&height_, 0, static_cast<size_t>(
+    ::memset(&width_, 0, static_cast<size_t>(
         reinterpret_cast<char*>(&parkspace_status_) -
-        reinterpret_cast<char*>(&height_)) + sizeof(parkspace_status_));
-    direction_ = 1;
+        reinterpret_cast<char*>(&width_)) + sizeof(parkspace_status_));
   }
   _has_bits_.Clear();
   _internal_metadata_.Clear();
@@ -1489,33 +1507,33 @@ void Parkspace_info::SerializeWithCachedSizes(
   }
 
   // required .message.Direction direction = 3;
-  if (cached_has_bits & 0x00000400u) {
+  if (cached_has_bits & 0x00000020u) {
     ::google::protobuf::internal::WireFormatLite::WriteEnum(
       3, this->direction(), output);
   }
 
   // required int32 floor = 4;
-  if (cached_has_bits & 0x00000020u) {
+  if (cached_has_bits & 0x00000040u) {
     ::google::protobuf::internal::WireFormatLite::WriteInt32(4, this->floor(), output);
   }
 
   // optional float length = 5;
-  if (cached_has_bits & 0x00000040u) {
+  if (cached_has_bits & 0x00000080u) {
     ::google::protobuf::internal::WireFormatLite::WriteFloat(5, this->length(), output);
   }
 
   // required float width = 6;
-  if (cached_has_bits & 0x00000080u) {
+  if (cached_has_bits & 0x00000100u) {
     ::google::protobuf::internal::WireFormatLite::WriteFloat(6, this->width(), output);
   }
 
   // required float height = 7;
-  if (cached_has_bits & 0x00000100u) {
+  if (cached_has_bits & 0x00000200u) {
     ::google::protobuf::internal::WireFormatLite::WriteFloat(7, this->height(), output);
   }
 
   // required .message.Parkspace_status parkspace_status = 8;
-  if (cached_has_bits & 0x00000200u) {
+  if (cached_has_bits & 0x00000400u) {
     ::google::protobuf::internal::WireFormatLite::WriteEnum(
       8, this->parkspace_status(), output);
   }
@@ -1572,33 +1590,33 @@ void Parkspace_info::SerializeWithCachedSizes(
   }
 
   // required .message.Direction direction = 3;
-  if (cached_has_bits & 0x00000400u) {
+  if (cached_has_bits & 0x00000020u) {
     target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
       3, this->direction(), target);
   }
 
   // required int32 floor = 4;
-  if (cached_has_bits & 0x00000020u) {
+  if (cached_has_bits & 0x00000040u) {
     target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(4, this->floor(), target);
   }
 
   // optional float length = 5;
-  if (cached_has_bits & 0x00000040u) {
+  if (cached_has_bits & 0x00000080u) {
     target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(5, this->length(), target);
   }
 
   // required float width = 6;
-  if (cached_has_bits & 0x00000080u) {
+  if (cached_has_bits & 0x00000100u) {
     target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(6, this->width(), target);
   }
 
   // required float height = 7;
-  if (cached_has_bits & 0x00000100u) {
+  if (cached_has_bits & 0x00000200u) {
     target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(7, this->height(), target);
   }
 
   // required .message.Parkspace_status parkspace_status = 8;
-  if (cached_has_bits & 0x00000200u) {
+  if (cached_has_bits & 0x00000400u) {
     target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
       8, this->parkspace_status(), target);
   }
@@ -1658,6 +1676,12 @@ size_t Parkspace_info::RequiredFieldsByteSizeFallback() const {
         this->index());
   }
 
+  if (has_direction()) {
+    // required .message.Direction direction = 3;
+    total_size += 1 +
+      ::google::protobuf::internal::WireFormatLite::EnumSize(this->direction());
+  }
+
   if (has_floor()) {
     // required int32 floor = 4;
     total_size += 1 +
@@ -1681,12 +1705,6 @@ size_t Parkspace_info::RequiredFieldsByteSizeFallback() const {
       ::google::protobuf::internal::WireFormatLite::EnumSize(this->parkspace_status());
   }
 
-  if (has_direction()) {
-    // required .message.Direction direction = 3;
-    total_size += 1 +
-      ::google::protobuf::internal::WireFormatLite::EnumSize(this->direction());
-  }
-
   return total_size;
 }
 size_t Parkspace_info::ByteSizeLong() const {
@@ -1698,7 +1716,7 @@ size_t Parkspace_info::ByteSizeLong() const {
       ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
         _internal_metadata_.unknown_fields());
   }
-  if (((_has_bits_[0] & 0x000007b8) ^ 0x000007b8) == 0) {  // All required fields are present.
+  if (((_has_bits_[0] & 0x00000778) ^ 0x00000778) == 0) {  // All required fields are present.
     // required int32 parkspace_id = 1;
     total_size += 1 +
       ::google::protobuf::internal::WireFormatLite::Int32Size(
@@ -1709,6 +1727,10 @@ size_t Parkspace_info::ByteSizeLong() const {
       ::google::protobuf::internal::WireFormatLite::Int32Size(
         this->index());
 
+    // required .message.Direction direction = 3;
+    total_size += 1 +
+      ::google::protobuf::internal::WireFormatLite::EnumSize(this->direction());
+
     // required int32 floor = 4;
     total_size += 1 +
       ::google::protobuf::internal::WireFormatLite::Int32Size(
@@ -1724,10 +1746,6 @@ size_t Parkspace_info::ByteSizeLong() const {
     total_size += 1 +
       ::google::protobuf::internal::WireFormatLite::EnumSize(this->parkspace_status());
 
-    // required .message.Direction direction = 3;
-    total_size += 1 +
-      ::google::protobuf::internal::WireFormatLite::EnumSize(this->direction());
-
   } else {
     total_size += RequiredFieldsByteSizeFallback();
   }
@@ -1808,25 +1826,25 @@ void Parkspace_info::MergeFrom(const Parkspace_info& from) {
       index_ = from.index_;
     }
     if (cached_has_bits & 0x00000020u) {
-      floor_ = from.floor_;
+      direction_ = from.direction_;
     }
     if (cached_has_bits & 0x00000040u) {
-      length_ = from.length_;
+      floor_ = from.floor_;
     }
     if (cached_has_bits & 0x00000080u) {
-      width_ = from.width_;
+      length_ = from.length_;
     }
     _has_bits_[0] |= cached_has_bits;
   }
   if (cached_has_bits & 1792u) {
     if (cached_has_bits & 0x00000100u) {
-      height_ = from.height_;
+      width_ = from.width_;
     }
     if (cached_has_bits & 0x00000200u) {
-      parkspace_status_ = from.parkspace_status_;
+      height_ = from.height_;
     }
     if (cached_has_bits & 0x00000400u) {
-      direction_ = from.direction_;
+      parkspace_status_ = from.parkspace_status_;
     }
     _has_bits_[0] |= cached_has_bits;
   }
@@ -1847,7 +1865,7 @@ void Parkspace_info::CopyFrom(const Parkspace_info& from) {
 }
 
 bool Parkspace_info::IsInitialized() const {
-  if ((_has_bits_[0] & 0x000007b8) != 0x000007b8) return false;
+  if ((_has_bits_[0] & 0x00000778) != 0x00000778) return false;
   if (has_car_info()) {
     if (!this->car_info_->IsInitialized()) return false;
   }
@@ -1865,12 +1883,12 @@ void Parkspace_info::InternalSwap(Parkspace_info* other) {
   swap(car_info_, other->car_info_);
   swap(parkspace_id_, other->parkspace_id_);
   swap(index_, other->index_);
+  swap(direction_, other->direction_);
   swap(floor_, other->floor_);
   swap(length_, other->length_);
   swap(width_, other->width_);
   swap(height_, other->height_);
   swap(parkspace_status_, other->parkspace_status_);
-  swap(direction_, other->direction_);
   swap(_has_bits_[0], other->_has_bits_[0]);
   _internal_metadata_.Swap(&other->_internal_metadata_);
   swap(_cached_size_, other->_cached_size_);

+ 59 - 32
message/parkspace_allocation_message.pb.h

@@ -131,9 +131,9 @@ namespace message {
 
 enum Parkspace_status {
   eParkspace_empty = 0,
-  eParkspace_locked = 1,
-  eParkspace_occupied = 2,
-  eParkspace_reserved = 3,
+  eParkspace_occupied = 1,
+  eParkspace_reserved = 2,
+  eParkspace_locked = 3,
   eParkspace_error = 4
 };
 bool Parkspace_status_IsValid(int value);
@@ -151,9 +151,31 @@ inline bool Parkspace_status_Parse(
   return ::google::protobuf::internal::ParseNamedEnum<Parkspace_status>(
     Parkspace_status_descriptor(), name, value);
 }
+enum Vehicle_status {
+  eVehicle_idle = 0,
+  eVehicle_in_garage = 1,
+  eVehicle_parking = 2,
+  eVehicle_fetching = 3,
+  eVehicle_reserved = 4
+};
+bool Vehicle_status_IsValid(int value);
+const Vehicle_status Vehicle_status_MIN = eVehicle_idle;
+const Vehicle_status Vehicle_status_MAX = eVehicle_reserved;
+const int Vehicle_status_ARRAYSIZE = Vehicle_status_MAX + 1;
+
+const ::google::protobuf::EnumDescriptor* Vehicle_status_descriptor();
+inline const ::std::string& Vehicle_status_Name(Vehicle_status value) {
+  return ::google::protobuf::internal::NameOfEnum(
+    Vehicle_status_descriptor(), value);
+}
+inline bool Vehicle_status_Parse(
+    const ::std::string& name, Vehicle_status* value) {
+  return ::google::protobuf::internal::ParseNamedEnum<Vehicle_status>(
+    Vehicle_status_descriptor(), name, value);
+}
 enum Direction {
-  eForward = 1,
-  eBackward = 2
+  eForward = 0,
+  eBackward = 1
 };
 bool Direction_IsValid(int value);
 const Direction Direction_MIN = eForward;
@@ -465,6 +487,13 @@ class Parkspace_info : public ::google::protobuf::Message /* @@protoc_insertion_
   ::google::protobuf::int32 index() const;
   void set_index(::google::protobuf::int32 value);
 
+  // required .message.Direction direction = 3;
+  bool has_direction() const;
+  void clear_direction();
+  static const int kDirectionFieldNumber = 3;
+  ::message::Direction direction() const;
+  void set_direction(::message::Direction value);
+
   // required int32 floor = 4;
   bool has_floor() const;
   void clear_floor();
@@ -500,13 +529,6 @@ class Parkspace_info : public ::google::protobuf::Message /* @@protoc_insertion_
   ::message::Parkspace_status parkspace_status() const;
   void set_parkspace_status(::message::Parkspace_status value);
 
-  // required .message.Direction direction = 3;
-  bool has_direction() const;
-  void clear_direction();
-  static const int kDirectionFieldNumber = 3;
-  ::message::Direction direction() const;
-  void set_direction(::message::Direction value);
-
   // @@protoc_insertion_point(class_scope:message.Parkspace_info)
  private:
   void set_has_parkspace_id();
@@ -543,12 +565,12 @@ class Parkspace_info : public ::google::protobuf::Message /* @@protoc_insertion_
   ::message::Car_info* car_info_;
   ::google::protobuf::int32 parkspace_id_;
   ::google::protobuf::int32 index_;
+  int direction_;
   ::google::protobuf::int32 floor_;
   float length_;
   float width_;
   float height_;
   int parkspace_status_;
-  int direction_;
   friend struct ::protobuf_parkspace_5fallocation_5fmessage_2eproto::TableStruct;
   friend void ::protobuf_parkspace_5fallocation_5fmessage_2eproto::InitDefaultsParkspace_infoImpl();
 };
@@ -2332,16 +2354,16 @@ inline void Parkspace_info::set_index(::google::protobuf::int32 value) {
 
 // required .message.Direction direction = 3;
 inline bool Parkspace_info::has_direction() const {
-  return (_has_bits_[0] & 0x00000400u) != 0;
+  return (_has_bits_[0] & 0x00000020u) != 0;
 }
 inline void Parkspace_info::set_has_direction() {
-  _has_bits_[0] |= 0x00000400u;
+  _has_bits_[0] |= 0x00000020u;
 }
 inline void Parkspace_info::clear_has_direction() {
-  _has_bits_[0] &= ~0x00000400u;
+  _has_bits_[0] &= ~0x00000020u;
 }
 inline void Parkspace_info::clear_direction() {
-  direction_ = 1;
+  direction_ = 0;
   clear_has_direction();
 }
 inline ::message::Direction Parkspace_info::direction() const {
@@ -2357,13 +2379,13 @@ inline void Parkspace_info::set_direction(::message::Direction value) {
 
 // required int32 floor = 4;
 inline bool Parkspace_info::has_floor() const {
-  return (_has_bits_[0] & 0x00000020u) != 0;
+  return (_has_bits_[0] & 0x00000040u) != 0;
 }
 inline void Parkspace_info::set_has_floor() {
-  _has_bits_[0] |= 0x00000020u;
+  _has_bits_[0] |= 0x00000040u;
 }
 inline void Parkspace_info::clear_has_floor() {
-  _has_bits_[0] &= ~0x00000020u;
+  _has_bits_[0] &= ~0x00000040u;
 }
 inline void Parkspace_info::clear_floor() {
   floor_ = 0;
@@ -2381,13 +2403,13 @@ inline void Parkspace_info::set_floor(::google::protobuf::int32 value) {
 
 // optional float length = 5;
 inline bool Parkspace_info::has_length() const {
-  return (_has_bits_[0] & 0x00000040u) != 0;
+  return (_has_bits_[0] & 0x00000080u) != 0;
 }
 inline void Parkspace_info::set_has_length() {
-  _has_bits_[0] |= 0x00000040u;
+  _has_bits_[0] |= 0x00000080u;
 }
 inline void Parkspace_info::clear_has_length() {
-  _has_bits_[0] &= ~0x00000040u;
+  _has_bits_[0] &= ~0x00000080u;
 }
 inline void Parkspace_info::clear_length() {
   length_ = 0;
@@ -2405,13 +2427,13 @@ inline void Parkspace_info::set_length(float value) {
 
 // required float width = 6;
 inline bool Parkspace_info::has_width() const {
-  return (_has_bits_[0] & 0x00000080u) != 0;
+  return (_has_bits_[0] & 0x00000100u) != 0;
 }
 inline void Parkspace_info::set_has_width() {
-  _has_bits_[0] |= 0x00000080u;
+  _has_bits_[0] |= 0x00000100u;
 }
 inline void Parkspace_info::clear_has_width() {
-  _has_bits_[0] &= ~0x00000080u;
+  _has_bits_[0] &= ~0x00000100u;
 }
 inline void Parkspace_info::clear_width() {
   width_ = 0;
@@ -2429,13 +2451,13 @@ inline void Parkspace_info::set_width(float value) {
 
 // required float height = 7;
 inline bool Parkspace_info::has_height() const {
-  return (_has_bits_[0] & 0x00000100u) != 0;
+  return (_has_bits_[0] & 0x00000200u) != 0;
 }
 inline void Parkspace_info::set_has_height() {
-  _has_bits_[0] |= 0x00000100u;
+  _has_bits_[0] |= 0x00000200u;
 }
 inline void Parkspace_info::clear_has_height() {
-  _has_bits_[0] &= ~0x00000100u;
+  _has_bits_[0] &= ~0x00000200u;
 }
 inline void Parkspace_info::clear_height() {
   height_ = 0;
@@ -2453,13 +2475,13 @@ inline void Parkspace_info::set_height(float value) {
 
 // required .message.Parkspace_status parkspace_status = 8;
 inline bool Parkspace_info::has_parkspace_status() const {
-  return (_has_bits_[0] & 0x00000200u) != 0;
+  return (_has_bits_[0] & 0x00000400u) != 0;
 }
 inline void Parkspace_info::set_has_parkspace_status() {
-  _has_bits_[0] |= 0x00000200u;
+  _has_bits_[0] |= 0x00000400u;
 }
 inline void Parkspace_info::clear_has_parkspace_status() {
-  _has_bits_[0] &= ~0x00000200u;
+  _has_bits_[0] &= ~0x00000400u;
 }
 inline void Parkspace_info::clear_parkspace_status() {
   parkspace_status_ = 0;
@@ -4424,6 +4446,11 @@ template <>
 inline const EnumDescriptor* GetEnumDescriptor< ::message::Parkspace_status>() {
   return ::message::Parkspace_status_descriptor();
 }
+template <> struct is_proto_enum< ::message::Vehicle_status> : ::google::protobuf::internal::true_type {};
+template <>
+inline const EnumDescriptor* GetEnumDescriptor< ::message::Vehicle_status>() {
+  return ::message::Vehicle_status_descriptor();
+}
 template <> struct is_proto_enum< ::message::Direction> : ::google::protobuf::internal::true_type {};
 template <>
 inline const EnumDescriptor* GetEnumDescriptor< ::message::Direction>() {

+ 16 - 5
message/parkspace_allocation_message.proto

@@ -21,16 +21,27 @@ message Car_info
 enum Parkspace_status
 {
     eParkspace_empty            = 0;         //空闲,可分配
-    eParkspace_locked           = 1;         //临时锁定,不可分配
-    eParkspace_occupied         = 2;         //被车辆占用,不可分配
-    eParkspace_reserved        = 3;          //被预约,预约车辆可分配
+    eParkspace_occupied         = 1;         //被车辆占用,不可分配
+    eParkspace_reserved        = 2;          //被预约,预约车辆可分配
+    eParkspace_locked           = 3;         //临时锁定,不可分配
     eParkspace_error            = 4;         //车位机械结构或硬件故障   
 }
 
+//车辆状态枚举
+enum Vehicle_status
+{
+    eVehicle_idle           = 0;         //车辆空闲
+    eVehicle_in_garage      = 1;         //车辆已入库
+    eVehicle_parking        = 2;         //车辆停车中
+    eVehicle_fetching       = 3;         //车辆取车中
+    eVehicle_reserved       = 4;         //已预约未停入
+    eVehicle_unknown        = 5;         //未知状态
+}
+
 enum Direction
 {
-    eForward = 1;
-    eBackward = 2;
+    eForward = 0;
+    eBackward = 1;
 }
 
 //单个车位基本信息与状态信息

+ 3 - 26
parkspace_allocation/database_controller.cpp

@@ -2,7 +2,7 @@
  * @Description: 数据库操作类
  * @Author: yct
  * @Date: 2020-07-15 14:08:46
- * @LastEditTime: 2020-07-19 00:02:06
+ * @LastEditTime: 2020-07-19 10:28:11
  * @LastEditors: yct
  */
 
@@ -29,31 +29,7 @@ Error_manager Database_controller::database_controller_init(std::string ip, int
         return DB_INIT_FAILED;
     }
     //创建连接池
-    m_conn_mutex.lock();
-    for (int i = 0; i < m_conn_pool_size; i++)
-    {
-        try
-        {
-            boost::shared_ptr<sql::Connection> t_conn_ptr(m_mysql_driver->connect(m_db_param.connect_string, m_db_param.username, m_db_param.pass));
-            if (t_conn_ptr->isValid())
-            {
-                m_db_conn_pool.push(t_conn_ptr);
-                std::cout << "conn pushed." << std::endl;
-            }
-            else
-            {
-                std::cout << "conn create failed." << std::endl;
-            }
-        }
-        catch (sql::SQLException &e)
-        {
-            char buf[1024];
-            memset(buf, 0, 1024);
-            sprintf(buf, "# ERR: %s\n (MySQL error code: %d, SQLState: %s", e.what(), e.getErrorCode(), e.getSQLState().c_str());
-            std::cout << buf << std::endl;
-        }
-    }
-    m_conn_mutex.unlock();
+    fill_up_pool(m_conn_pool_size);
     
     //守护线程,检查连接状态并保持连接数量
     mp_guard_thread = new std::thread(&Database_controller::database_status_update, this);
@@ -84,6 +60,7 @@ Error_manager Database_controller::database_controller_uninit()
 //数据库连接状态
 bool Database_controller::is_connected()
 {
+    check_status();
     return mb_connected;
 }
 

+ 105 - 7
parkspace_allocation/parkspace_allocator.cpp

@@ -2,7 +2,7 @@
  * @Description: 车位分配算法模块,使用单例模式,接收外部请求并通过调用通信块接口发送反馈
  * @Author: yct
  * @Date: 2020-07-10 11:02:40
- * @LastEditTime: 2020-07-17 09:19:38
+ * @LastEditTime: 2020-07-21 18:15:51
  * @LastEditors: yct
  */ 
 
@@ -11,7 +11,6 @@
 
 Parkspace_allocator::Parkspace_allocator()
 {
-
 }
 
 Parkspace_allocator::~Parkspace_allocator()
@@ -20,8 +19,21 @@ Parkspace_allocator::~Parkspace_allocator()
 }
 
 //初始化
-Error_manager Parkspace_allocator::parkspace_allocator_init(int threads_size)
+Error_manager Parkspace_allocator::parkspace_allocator_init(int threads_size, parkspace_proto::database_config db_config)
 {
+    // 初始化db连接
+    mp_db_manager = Parkspace_db_manager::get_instance_pointer();
+    if(mp_db_manager == nullptr)
+    {
+        return POINTER_IS_NULL;
+    }
+    Error_manager ec = mp_db_manager->Parkspace_db_manager_init(db_config);
+    if(ec != SUCCESS)
+    {
+        return ec;
+    }
+    m_current_status = eParkspace_allocator_normal;
+    // 初始化任务处理线程池
 	m_thread_pool.thread_pool_init(threads_size);
 	m_current_status = eParkspace_allocator_normal;
 	return Error_code::SUCCESS;
@@ -31,6 +43,7 @@ Error_manager Parkspace_allocator::parkspace_allocator_init(int threads_size)
 Error_manager Parkspace_allocator::parkspace_allocator_uninit()
 {
 	m_thread_pool.thread_pool_uninit();
+    mp_db_manager->Parkspace_db_manager_uninit();
 	m_current_status = eParkspace_allocator_unknown;
 	return Error_code::SUCCESS;
 }
@@ -210,6 +223,18 @@ void Parkspace_allocator::execute_for_allocate(message::Car_info car_info, int t
             // 分配车位后更新车位状态
             Parkspace_allocation_communicator::get_instance_references().update_parkspace_status(index, t_space_to_lock);
             LOG(INFO) << "第"<<index<<"号位占用, id: "<<t_space_to_lock.parkspace_id();
+            // 数据库操作,修改车位状态为锁定,车辆状态为停车中
+            message::Vehicle_status t_vehicle_status = message::Vehicle_status::eVehicle_parking;
+            Error_manager ec = Parkspace_db_manager::get_instance_references().update_parkspace_status(t_space_to_lock);
+            if(ec != SUCCESS)
+            {
+                LOG(ERROR) << "更新db车位状态失败";
+            }
+            ec = Parkspace_db_manager::get_instance_references().update_vehicle_status(t_space_to_lock, t_vehicle_status);
+            if (ec != SUCCESS)
+            {
+                LOG(ERROR) << "更新db车辆状态失败";
+            }
         }
     }
     response_msg.mutable_base_info()->CopyFrom(t_response_header);
@@ -227,7 +252,6 @@ void Parkspace_allocator::execute_for_search(message::Car_info car_info, int com
     std::lock_guard<std::mutex> lck(m_mutex);
     LOG(INFO) << "查询";
     //根据车辆凭证信息查询车辆位置
-    //!!!!!此处跳过外部处理与调用的过程,直接在内部调用,发送分配结果用于测试,目前一直发布第一个车位
     message::Parkspace_search_response_msg response_msg;
     message::Base_info t_response_header;
     message::Error_manager t_error;
@@ -268,6 +292,7 @@ void Parkspace_allocator::execute_for_search(message::Car_info car_info, int com
             message::Parkspace_info t_space_searching = t_current_parkspace_status.parkspace_info(index);
             t_car_position.CopyFrom(t_space_searching);
             LOG(INFO) << "车辆"<<car_info.license() <<"在第"<<index<<"号位, id: "<<t_space_searching.parkspace_id();
+            // 无数据库操作
         }
     }
     response_msg.mutable_base_info()->CopyFrom(t_response_header);
@@ -285,7 +310,6 @@ void Parkspace_allocator::execute_for_release(message::Parkspace_info space_info
     std::lock_guard<std::mutex> lck(m_mutex);
     LOG(INFO) << "释放";
     //根据车位信息定位待释放车位位置,车辆凭证号用于校验
-    //!!!!!此处跳过外部处理与调用的过程,直接在内部调用,发送分配结果用于测试,目前一直发布第一个车位
     message::Parkspace_release_response_msg response_msg;
     message::Base_info t_response_header;
     t_response_header.set_msg_type(message::eParkspace_release_response_msg);
@@ -312,7 +336,7 @@ void Parkspace_allocator::execute_for_release(message::Parkspace_info space_info
     {
         for (size_t i = 0; i < t_current_parkspace_status.parkspace_info_size(); i++)
         {
-            // 找到高于车高且空闲车位,则分
+            // 找到占用或锁定的车位,且车辆信息匹
             if (t_current_parkspace_status.parkspace_info(i).parkspace_id() == space_info.parkspace_id()
             && (t_current_parkspace_status.parkspace_info(i).parkspace_status() == message::Parkspace_status::eParkspace_occupied
                 ||t_current_parkspace_status.parkspace_info(i).parkspace_status() == message::Parkspace_status::eParkspace_locked)
@@ -336,6 +360,45 @@ void Parkspace_allocator::execute_for_release(message::Parkspace_info space_info
             // 分配车位后更新车位状态
             Parkspace_allocation_communicator::get_instance_references().update_parkspace_status(index, t_space_to_release);
             LOG(INFO) << "第"<<index<<"号位释放, id: "<<t_space_to_release.parkspace_id();
+            // 数据库操作,车位状态改为空闲,查询车辆状态,确定是停车失败还是取车完成
+            // 停车失败仅修改车位与车辆状态
+            // 取车完成同时还修改停车记录
+            Error_manager ec = Parkspace_db_manager::get_instance_references().update_parkspace_status(t_space_to_release);
+            if(ec != SUCCESS)
+            {
+                LOG(ERROR) << "更新db车位状态失败";
+            }
+            message::Vehicle_status t_vehicle_status = message::Vehicle_status::eVehicle_idle;
+            ec = Parkspace_db_manager::get_instance_references().update_vehicle_status(t_space_to_release, t_vehicle_status);
+            if(ec != SUCCESS)
+            {
+                LOG(ERROR) << "更新db车辆状态失败";
+            }
+            int t_park_record_id;
+            ec = Parkspace_db_manager::get_instance_references().query_vehicle(t_space_to_release.car_info().license(), t_vehicle_status, t_park_record_id);
+            if(ec != SUCCESS)
+            {
+                LOG(ERROR) << "查询db车辆状态失败";
+            }else if(t_vehicle_status == message::Vehicle_status::eVehicle_in_garage)
+            {
+                time_t tt = time(NULL);
+                tm *t = localtime(&tt);
+                char my_time_buf[255];
+                memset(my_time_buf, 0, 255);
+                sprintf(my_time_buf, "%d-%02d-%02d %02d:%02d:%02d",
+                        t->tm_year + 1900,
+                        t->tm_mon + 1,
+                        t->tm_mday,
+                        t->tm_hour,
+                        t->tm_min,
+                        t->tm_sec);
+                t_space_to_release.set_leave_time(my_time_buf);
+                ec = Parkspace_db_manager::get_instance_references().update_parking_record(t_space_to_release, t_park_record_id);
+                if(ec != SUCCESS)
+                {
+                    LOG(ERROR) << "更新db停车记录失败";
+                }
+            }
         }
     }
     response_msg.mutable_base_info()->CopyFrom(t_response_header);
@@ -389,6 +452,12 @@ void Parkspace_allocator::execute_for_force_update(message::Parkspace_info space
             // 分配车位后更新车位状态
             Parkspace_allocation_communicator::get_instance_references().update_parkspace_status(index, t_update_space);
             LOG(INFO) << "第"<<index<<"号位已手动更新, id: "<<t_update_space.parkspace_id();
+            // 数据库操作,车位状态根据手动值进行修改
+            Error_manager ec = Parkspace_db_manager::get_instance_references().update_parkspace_status(t_update_space);
+            if(ec != SUCCESS)
+            {
+                LOG(ERROR) << "更新db车位状态失败";
+            }
         }
     }
     response_msg.mutable_base_info()->CopyFrom(t_response_header);
@@ -447,9 +516,38 @@ void Parkspace_allocator::execute_for_confirm_alloc(message::Parkspace_info spac
             t_error.set_error_level(message::Error_level::NORMAL);
             t_confirm_space.CopyFrom(space_info);
             t_confirm_space.set_parkspace_status(message::Parkspace_status::eParkspace_occupied);
+            time_t tt = time(NULL);
+            tm *t = localtime(&tt);
+            char my_time_buf[255];
+            memset(my_time_buf, 0, 255);
+            sprintf(my_time_buf, "%d-%02d-%02d %02d:%02d:%02d",
+                   t->tm_year + 1900,
+                   t->tm_mon + 1,
+                   t->tm_mday,
+                   t->tm_hour,
+                   t->tm_min,
+                   t->tm_sec);
+            t_confirm_space.set_entry_time(my_time_buf);
             // 分配车位后更新车位状态
             Parkspace_allocation_communicator::get_instance_references().update_parkspace_status(index, t_confirm_space);
-            LOG(INFO) << "第"<<index<<"号位已确认占用, id: "<<t_confirm_space.parkspace_id();
+            LOG(INFO) << "第" << index << "号位已确认占用, id: " << t_confirm_space.parkspace_id();
+            // 数据库操作,车位状态改为占用,插入停车记录,更新车辆状态为入库
+            Error_manager ec = Parkspace_db_manager::get_instance_references().update_parkspace_status(t_confirm_space);
+            if(ec != SUCCESS)
+            {
+                LOG(ERROR) << "更新db车位状态失败";
+            }
+            ec = Parkspace_db_manager::get_instance_references().insert_parking_record(t_confirm_space);
+            if(ec != SUCCESS)
+            {
+                LOG(ERROR) << "插入db停车记录失败";
+            }
+            message::Vehicle_status t_vehicle_status = message::Vehicle_status::eVehicle_in_garage;
+            ec = Parkspace_db_manager::get_instance_references().update_vehicle_status(t_confirm_space, t_vehicle_status);
+            if(ec != SUCCESS)
+            {
+                LOG(ERROR) << "更新db车辆状态失败";
+            }
         }
     }
     response_msg.mutable_base_info()->CopyFrom(t_response_header);

+ 6 - 2
parkspace_allocation/parkspace_allocator.h

@@ -2,7 +2,7 @@
  * @Description: 车位分配算法模块,使用单例模式,接收外部请求并通过调用通信块接口发送反馈
  * @Author: yct
  * @Date: 2020-07-10 09:25:56
- * @LastEditTime: 2020-07-15 17:30:18
+ * @LastEditTime: 2020-07-21 18:00:45
  * @LastEditors: yct
  */ 
 
@@ -14,6 +14,8 @@
 #include "../error_code/error_code.h"
 #include "../communication/communication_message.h"
 #include "../message/parkspace_allocation_message.pb.h"
+#include "parkspace_db_manager.h"
+#include <ctime>
 
 class Parkspace_allocator : public Singleton<Parkspace_allocator>
 {
@@ -36,7 +38,7 @@ public:
     ~Parkspace_allocator();
 public://API functions
 	//初始化
-	Error_manager parkspace_allocator_init(int threads_size);
+	Error_manager parkspace_allocator_init(int threads_size, parkspace_proto::database_config db_config);
 	//反初始化
 	Error_manager parkspace_allocator_uninit();
 
@@ -67,6 +69,8 @@ private:
     parkspace_allocator_status  m_current_status;               //分配器当前状态
 	Thread_pool 				m_thread_pool;					//执行多任务的线程池
     std::mutex                  m_mutex;                        //车位变动锁
+    Parkspace_db_manager*       mp_db_manager;                  //车位模块数据库管理句柄
+
 };
 
 #endif // !PARKSPACE_ALLOCATOR_HH

+ 619 - 0
parkspace_allocation/parkspace_db_manager.cpp

@@ -0,0 +1,619 @@
+/*
+ * @Description: 车位数据库管理
+ * @Author: yct
+ * @Date: 2020-07-19 09:57:45
+ * @LastEditTime: 2020-07-21 17:58:53
+ * @LastEditors: yct
+ */
+
+#include "parkspace_db_manager.h"
+
+// 车位数据库管理初始化
+Error_manager Parkspace_db_manager::Parkspace_db_manager_init(parkspace_proto::database_config config)
+{
+    Error_manager ec = SUCCESS;
+    mp_db_controller = boost::shared_ptr<Database_controller>(Database_controller::get_instance_pointer());
+    if(mp_db_controller != nullptr)
+    {
+        ec = mp_db_controller->database_controller_init(config.db_ip(), config.db_port(), config.db_username(), config.db_passwd(), config.db_name(), config.db_conn_pool_size());
+        mb_initialized = true;
+        return ec;
+    }
+    else
+    {
+        mb_initialized = false;
+        return POINTER_IS_NULL;
+    }
+}
+// 车位数据库管理反初始化
+Error_manager Parkspace_db_manager::Parkspace_db_manager_uninit()
+{
+    if(mp_db_controller!=nullptr)
+    {
+        return mp_db_controller->database_controller_uninit();
+    }else{
+        return POINTER_IS_NULL;
+    }
+}
+
+// 连接状态
+bool Parkspace_db_manager::is_connected()
+{
+    if(mp_db_controller!=nullptr)
+    {
+        mb_connected = mp_db_controller->is_connected();
+        return mb_connected;
+    }
+    else{
+        return false;
+    }
+}
+
+// 初始化状态
+bool Parkspace_db_manager::is_initialized()
+{
+    return mb_initialized;
+}
+
+// 从数据库获得所有车位信息,用于车位模块初始化
+Error_manager Parkspace_db_manager::get_all_parkspace_info(message::Parkspace_allocation_status_msg &all_parkspace_info)
+{
+    // 基本条件判断
+    if(!mb_initialized)
+    {
+        return DB_UNINITIALIZED;
+    }
+    if(mp_db_controller == nullptr)
+    {
+        return POINTER_IS_NULL;
+    }else{
+        //执行sql操作
+        std::string get_all_space_sql = "select * from parkingspace";
+        boost::shared_ptr<sql::ResultSet>  tp_result = nullptr;
+        Error_manager ec = mp_db_controller->sql_query(get_all_space_sql, tp_result);
+        if(ec == SUCCESS)
+        {
+            if(tp_result == nullptr)
+            {
+                return DB_RESULT_SET_EMPTY;
+            }
+            all_parkspace_info.clear_parkspace_info();
+            while (tp_result->next())
+            {
+                message::Parkspace_info *t_parkspace = all_parkspace_info.add_parkspace_info();
+                char buf[1024];
+                memset(buf, 0, 1024);
+                try
+                {
+                    t_parkspace->set_parkspace_id(tp_result->getInt("parkingSpaceID"));
+                    t_parkspace->set_index(tp_result->getInt("parkingSpaceX"));
+                    if (tp_result->getInt("parkingSpaceY") > 0)
+                    {
+                        t_parkspace->set_direction(message::Direction::eForward);
+                    }
+                    else
+                    {
+                        t_parkspace->set_direction(message::Direction::eBackward);
+                    }
+                    t_parkspace->set_floor(tp_result->getInt("parkingSpaceZ"));
+                    switch (tp_result->getInt("parkingSpaceState"))
+                    {
+                    case 0:
+                        t_parkspace->set_parkspace_status(message::Parkspace_status::eParkspace_empty);
+                        break;
+                    case 1:
+                        t_parkspace->set_parkspace_status(message::Parkspace_status::eParkspace_occupied);
+                        break;
+                    case 2:
+                        t_parkspace->set_parkspace_status(message::Parkspace_status::eParkspace_reserved);
+                        break;
+                    case 3:
+                        t_parkspace->set_parkspace_status(message::Parkspace_status::eParkspace_locked);
+                        break;
+                    case 4:
+                        t_parkspace->set_parkspace_status(message::Parkspace_status::eParkspace_error);
+                        break;
+                    default:
+                        t_parkspace->set_parkspace_status(message::Parkspace_status::eParkspace_error);
+                        break;
+                    }
+                    t_parkspace->mutable_car_info()->set_license(tp_result->getString("parkSpaceCarLicense"));
+                    t_parkspace->mutable_car_info()->set_car_length(tp_result->getDouble("parkSpaceCarLength"));
+                    t_parkspace->mutable_car_info()->set_car_width(tp_result->getDouble("parkSpaceCarWidth"));
+                    t_parkspace->mutable_car_info()->set_car_height(tp_result->getDouble("parkSpaceCarHeight"));
+                    t_parkspace->set_entry_time(tp_result->getString("entryTime"));
+                    t_parkspace->set_leave_time(tp_result->getString("leaveTime"));
+                }
+                catch (sql::SQLException &e)
+                {
+                    /* Use what() (derived from std::runtime_error) to fetch the error message */
+                    sprintf(buf, "# ERR: %s\n (MySQL error code: %d, SQLState: %s", e.what(), e.getErrorCode(), e.getSQLState().c_str());
+                    return Error_manager(DB_RESULT_SET_PARSE_ERROR, NEGLIGIBLE_ERROR, buf);
+                }
+                catch (std::runtime_error &e)
+                {
+                    sprintf(buf, "# ERR: %s\n ERR: runtime_error in  %s ", e.what(), __FILE__);
+                    return Error_manager(DB_RESULT_SET_PARSE_ERROR, NEGLIGIBLE_ERROR, buf);
+                }
+            }
+            return SUCCESS;
+        }
+        else
+        {
+            return ec;
+        }
+    }
+}
+
+// 更新数据库中所有车位信息
+Error_manager Parkspace_db_manager::update_all_parkspace_info(message::Parkspace_allocation_status_msg all_parkspace_info)
+{
+    return SUCCESS;
+}
+
+// 更新数据库中车位状态
+Error_manager Parkspace_db_manager::update_parkspace_status(message::Parkspace_info parkspace_info)
+{
+// 基本条件判断
+    if(!mb_initialized)
+    {
+        return DB_UNINITIALIZED;
+    }
+    if(mp_db_controller == nullptr)
+    {
+        return POINTER_IS_NULL;
+    }else{
+        //执行sql操作
+        char update_space_sql[1024];
+        memset(update_space_sql, 0, 1024);
+        int status = -1;
+        switch (parkspace_info.parkspace_status())
+        {
+        case message::Parkspace_status::eParkspace_empty:
+            status = 0;
+            break;
+        case message::Parkspace_status::eParkspace_occupied:
+            status = 1;
+            break;
+        case message::Parkspace_status::eParkspace_reserved:
+            status = 2;
+            break;
+        case message::Parkspace_status::eParkspace_locked:
+            status = 3;
+            break;
+        case message::Parkspace_status::eParkspace_error:
+            status = 4;
+            break;
+        default:
+            break;
+        }
+        if(parkspace_info.has_car_info())
+        {
+            sprintf(update_space_sql, "update parkingspace set parkingSpaceState = %d,parkSpaceCarLicense = '%s',parkSpaceCarLength = %.3f,parkSpaceCarWidth = %.3f,parkSpaceCarHeight = %.3f,entryTime = '%s',leaveTime = '%s' where parkingSpaceID = %d",
+                    status, 
+                    parkspace_info.car_info().license().c_str(),
+                    parkspace_info.car_info().has_car_length()?parkspace_info.car_info().car_length():0.0f,
+                    parkspace_info.car_info().car_width(),
+                    parkspace_info.car_info().car_height(),
+                    parkspace_info.entry_time().c_str(),
+                    parkspace_info.leave_time().c_str(),
+                    parkspace_info.parkspace_id());
+        }else{
+            sprintf(update_space_sql, "update parkingspace set parkingSpaceState = %d where parkingSpaceID = %d", status, parkspace_info.parkspace_id());
+        }
+        if(status < 0)
+            return ERROR;
+        boost::shared_ptr<sql::ResultSet>  tp_result = nullptr;
+        Error_manager ec = mp_db_controller->sql_update(update_space_sql);
+        return ec;
+    }
+}
+
+// 更新数据库车辆状态,车位信息中包含车辆信息用于匹配更新
+Error_manager Parkspace_db_manager::update_vehicle_status(message::Parkspace_info parkspace_info, message::Vehicle_status &vehicle_status)
+{
+    // 基本条件判断
+    if(!mb_initialized)
+    {
+        return DB_UNINITIALIZED;
+    }
+    if(mp_db_controller == nullptr)
+    {
+        return POINTER_IS_NULL;
+    }else{
+        //执行sql操作
+        if(!parkspace_info.has_car_info())
+        {
+            return PARAMETER_ERROR;
+        }
+        std::string find_vehicle_sql = std::string("select * from vehicle where numberPlate = '").append(parkspace_info.car_info().license()).append("'");
+        boost::shared_ptr<sql::ResultSet> query_vehicle_result = nullptr;
+        mp_db_controller->sql_query(find_vehicle_sql, query_vehicle_result);
+        //判断车辆是否存在
+        if(query_vehicle_result == nullptr || !query_vehicle_result->next())
+        {
+            insert_vehicle(parkspace_info, vehicle_status);
+        }else{
+            char update_vehicle_sql[1024];
+            memset(update_vehicle_sql, 0, 1024);
+            int vehicle_status_code = -1;
+            switch (vehicle_status)
+            {
+            case message::Vehicle_status::eVehicle_idle:
+                vehicle_status_code = 0;
+                break;
+            case message::Vehicle_status::eVehicle_in_garage:
+                vehicle_status_code = 1;
+                break;
+            case message::Vehicle_status::eVehicle_parking:
+                vehicle_status_code = 2;
+                break;
+            case message::Vehicle_status::eVehicle_fetching:
+                vehicle_status_code = 3;
+                break;
+            case message::Vehicle_status::eVehicle_reserved:
+                vehicle_status_code = 4;
+                break;
+            default:
+                break;
+            }
+            //车位为空,仅更新车辆状态与长宽高
+            if(parkspace_info.parkspace_id() <= 0)
+            {
+                sprintf(update_vehicle_sql, "update vehicle set vehicleParkState = %d,carLength=%.3f,carWidth=%.3f,carHeight=%.3f where numberPlate = '%s'", 
+                        vehicle_status_code,
+                        parkspace_info.car_info().car_length(),
+                        parkspace_info.car_info().car_width(),
+                        parkspace_info.car_info().car_height(),
+                        parkspace_info.car_info().license());
+            }
+            //车位不为空,表示车辆所在车位,同时更新
+            else
+            {
+                 sprintf(update_vehicle_sql, "update vehicle set vehicleParkState = %d,carLength=%.3f,carWidth=%.3f,carHeight=%.3f,parkingSpaceID=%d where numberPlate = '%s'", 
+                        vehicle_status_code,
+                        parkspace_info.car_info().car_length(),
+                        parkspace_info.car_info().car_width(),
+                        parkspace_info.car_info().car_height(),
+                        parkspace_info.parkspace_id(),
+                        parkspace_info.car_info().license());
+            }
+            if (vehicle_status_code < 0)
+                return ERROR;
+            Error_manager ec = mp_db_controller->sql_update(update_vehicle_sql);
+            return ec;
+        }
+    }
+}
+
+// 插入车辆
+Error_manager Parkspace_db_manager::insert_vehicle(message::Parkspace_info parkspace_info, message::Vehicle_status &vehicle_status)
+{
+    // 基本条件判断
+    if(!mb_initialized)
+    {
+        return DB_UNINITIALIZED;
+    }
+    if(mp_db_controller == nullptr)
+    {
+        return POINTER_IS_NULL;
+    }else{
+        //执行sql操作
+        if(!parkspace_info.has_car_info())
+        {
+            return PARAMETER_ERROR;
+        }
+        char insert_vehicle_sql[1024];
+        memset(insert_vehicle_sql, 0, 1024);
+        int vehicle_status_code = -1;
+        switch (vehicle_status)
+        {
+        case message::Vehicle_status::eVehicle_idle:
+            vehicle_status_code = 0;
+            break;
+        case message::Vehicle_status::eVehicle_in_garage:
+            vehicle_status_code = 1;
+            break;
+        case message::Vehicle_status::eVehicle_parking:
+            vehicle_status_code = 2;
+            break;
+        case message::Vehicle_status::eVehicle_fetching:
+            vehicle_status_code = 3;
+            break;
+        case message::Vehicle_status::eVehicle_reserved:
+            vehicle_status_code = 4;
+            break;
+        default:
+            break;
+        }
+        //车位为空,仅更新车辆状态与长宽高
+        if(parkspace_info.parkspace_id() <= 0)
+        {
+            sprintf(insert_vehicle_sql, "INSERT INTO vehicle (numberPlate,vehicleParkState,carLength,carWidth,carHeight) values ('%s',%d,%.3f,%.3f,%.3f)", 
+                    parkspace_info.car_info().license(),
+                    vehicle_status_code,
+                    parkspace_info.car_info().car_length(),
+                    parkspace_info.car_info().car_width(),
+                    parkspace_info.car_info().car_height());
+        }
+        //车位不为空,表示车辆在车位,同时更新
+        else
+        {
+            sprintf(insert_vehicle_sql, "INSERT INTO vehicle (numberPlate,vehicleParkState,carLength,carWidth,carHeight,parkingSpaceID) values ('%s',%d,%.3f,%.3f,%.3f,%d)", 
+                parkspace_info.car_info().license(),
+                vehicle_status_code,
+                parkspace_info.car_info().car_length(),
+                parkspace_info.car_info().car_width(),
+                parkspace_info.car_info().car_height(),
+                parkspace_info.parkspace_id());
+        }
+        if (vehicle_status_code < 0)
+            return ERROR;
+        Error_manager ec = mp_db_controller->sql_insert(insert_vehicle_sql);
+        return ec;
+    }
+}
+
+// 插入停车记录
+Error_manager Parkspace_db_manager::insert_parking_record(message::Parkspace_info parkspace_info)
+{
+    // 基本条件判断
+    if(!mb_initialized)
+    {
+        return DB_UNINITIALIZED;
+    }
+    if(mp_db_controller == nullptr)
+    {
+        return POINTER_IS_NULL;
+    }else{
+        //参数中必须包含车辆信息与车位编号
+        if(!parkspace_info.has_car_info() || parkspace_info.parkspace_id() <= 0)
+        {
+            return PARAMETER_ERROR;
+        }
+        char insert_parking_record_sql[1024];
+        memset(insert_parking_record_sql, 0, 1024);
+        //将车辆号牌,车位ID,记录状态,停车与取车时间写入
+            sprintf(insert_parking_record_sql, "INSERT INTO parkingrecords (numberPlate,parkingSpaceID,realParkTime) values ('%s',%d,'%s')", 
+                    parkspace_info.car_info().license(),
+                    parkspace_info.parkspace_id(),
+                    parkspace_info.entry_time().c_str());
+        Error_manager ec = mp_db_controller->sql_insert(insert_parking_record_sql);
+        return ec;
+    }
+}
+
+// 更新停车记录,待计费系统加入后完善!!!
+Error_manager Parkspace_db_manager::update_parking_record(message::Parkspace_info parkspace_info, int record_id)
+{
+    // 基本条件判断
+    if(!mb_initialized)
+    {
+        return DB_UNINITIALIZED;
+    }
+    if(mp_db_controller == nullptr)
+    {
+        return POINTER_IS_NULL;
+    }else{
+        //执行sql操作
+        if(!parkspace_info.has_car_info() || parkspace_info.parkspace_id() <= 0)
+        {
+            return PARAMETER_ERROR;
+        }
+        char update_parking_record_sql[1024];
+        memset(update_parking_record_sql, 0, 1024);
+        sprintf(update_parking_record_sql, "update parkingrecords set realGetTime='%s',parkingPrice=%d where parkingRecordsID = %d",
+                parkspace_info.leave_time(),
+                0,
+                record_id);
+        Error_manager ec = mp_db_controller->sql_update(update_parking_record_sql);
+        return ec;
+    }
+}
+
+// 根据车位编号查询车位状态
+Error_manager Parkspace_db_manager::query_parkspace(int parkspace_id, message::Parkspace_info &parkspace_info)
+{
+    // 基本条件判断
+    if(!mb_initialized)
+    {
+        return DB_UNINITIALIZED;
+    }
+    if(mp_db_controller == nullptr)
+    {
+        return POINTER_IS_NULL;
+    }else{
+        //执行sql操作
+        std::string query_parkspace_sql = std::string("select * from parkingspace where parkspace_id=").append(std::to_string(parkspace_id));
+        boost::shared_ptr<sql::ResultSet>  tp_result = nullptr;
+        Error_manager ec = mp_db_controller->sql_query(query_parkspace_sql, tp_result);
+        if(ec == SUCCESS)
+        {
+            if(tp_result == nullptr)
+            {
+                return DB_RESULT_SET_EMPTY;
+            }
+            if (tp_result->next())
+            {
+                char buf[1024];
+                memset(buf, 0, 1024);
+                try
+                {
+                    switch (tp_result->getInt("parkingSpaceState"))
+                    {
+                    case 0:
+                        parkspace_info.set_parkspace_status(message::Parkspace_status::eParkspace_empty);
+                        break;
+                    case 1:
+                        parkspace_info.set_parkspace_status(message::Parkspace_status::eParkspace_occupied);
+                        break;
+                    case 2:
+                        parkspace_info.set_parkspace_status(message::Parkspace_status::eParkspace_reserved);
+                        break;
+                    case 3:
+                        parkspace_info.set_parkspace_status(message::Parkspace_status::eParkspace_locked);
+                        break;
+                    case 4:
+                        parkspace_info.set_parkspace_status(message::Parkspace_status::eParkspace_error);
+                        break;
+                    default:
+                        parkspace_info.set_parkspace_status(message::Parkspace_status::eParkspace_error);
+                        break;
+                    }
+                    parkspace_info.set_index(tp_result->getInt("parkingSpaceX"));
+                    parkspace_info.set_direction(tp_result->getInt("parkingSpaceY") > 0 ? message::Direction::eForward : message::Direction::eBackward);
+                    parkspace_info.set_floor(tp_result->getInt("parkingSpaceZ"));
+                    parkspace_info.mutable_car_info()->set_license(tp_result->getString("parkSpaceCarLicense"));
+                    parkspace_info.mutable_car_info()->set_car_length(tp_result->getDouble("parkSpaceCatLength"));
+                    parkspace_info.mutable_car_info()->set_car_width(tp_result->getDouble("parkSpaceCarWidth"));
+                    parkspace_info.mutable_car_info()->set_car_height(tp_result->getDouble("parkSpaceCarHeight"));
+                    parkspace_info.set_entry_time(tp_result->getString("entryTime"));
+                    parkspace_info.set_leave_time(tp_result->getString("leaveTime"));
+                }
+                catch (sql::SQLException &e)
+                {
+                    /* Use what() (derived from std::runtime_error) to fetch the error message */
+                    sprintf(buf, "# ERR: %s\n (MySQL error code: %d, SQLState: %s", e.what(), e.getErrorCode(), e.getSQLState().c_str());
+                    return Error_manager(DB_RESULT_SET_PARSE_ERROR, NEGLIGIBLE_ERROR, buf);
+                }
+                catch (std::runtime_error &e)
+                {
+                    sprintf(buf, "# ERR: %s\n ERR: runtime_error in  %s ", e.what(), __FILE__);
+                    return Error_manager(DB_RESULT_SET_PARSE_ERROR, NEGLIGIBLE_ERROR, buf);
+                }
+            }
+            return SUCCESS;
+        }
+        else
+        {
+            return ec;
+        }
+    }
+}
+
+// 查询车辆状态,暂时不使用
+Error_manager Parkspace_db_manager::query_vehicle(std::string license, message::Vehicle_status &vehicle_status, int &park_record_id)
+{
+    // 基本条件判断
+    if(!mb_initialized)
+    {
+        return DB_UNINITIALIZED;
+    }
+    if(mp_db_controller == nullptr)
+    {
+        return POINTER_IS_NULL;
+    }else{
+        //执行sql操作
+        std::string query_parkspace_sql = std::string("select * from vehicle where numberPlate='").append(license).append("'");
+        boost::shared_ptr<sql::ResultSet>  tp_result = nullptr;
+        Error_manager ec = mp_db_controller->sql_query(query_parkspace_sql, tp_result);
+        if(ec == SUCCESS)
+        {
+            if(tp_result == nullptr)
+            {
+                return DB_RESULT_SET_EMPTY;
+            }
+            if (tp_result->next())
+            {
+                char buf[1024];
+                memset(buf, 0, 1024);
+                try
+                {
+                    switch (tp_result->getInt("vehicleParkState"))
+                    {
+                    case 0:
+                        vehicle_status = message::Vehicle_status::eVehicle_idle;
+                        break;
+                    case 1:
+                        vehicle_status = message::Vehicle_status::eVehicle_in_garage;
+                        break;
+                    case 2:
+                        vehicle_status = message::Vehicle_status::eVehicle_parking;
+                        break;
+                    case 3:
+                        vehicle_status = message::Vehicle_status::eVehicle_fetching;
+                        break;
+                    case 4:
+                        vehicle_status = message::Vehicle_status::eVehicle_reserved;
+                        break;
+                    default:
+                        vehicle_status = message::Vehicle_status::eVehicle_reserved;
+                        break;
+                    }
+                    park_record_id = tp_result->getInt("parkingRecordsID");
+                }
+                catch (sql::SQLException &e)
+                {
+                    /* Use what() (derived from std::runtime_error) to fetch the error message */
+                    sprintf(buf, "# ERR: %s\n (MySQL error code: %d, SQLState: %s", e.what(), e.getErrorCode(), e.getSQLState().c_str());
+                    return Error_manager(DB_RESULT_SET_PARSE_ERROR, NEGLIGIBLE_ERROR, buf);
+                }
+                catch (std::runtime_error &e)
+                {
+                    sprintf(buf, "# ERR: %s\n ERR: runtime_error in  %s ", e.what(), __FILE__);
+                    return Error_manager(DB_RESULT_SET_PARSE_ERROR, NEGLIGIBLE_ERROR, buf);
+                }
+            }
+            return SUCCESS;
+        }
+        else
+        {
+            return ec;
+        }
+    }
+}
+
+// 查询停车记录,根据车牌号、车位id查询,反馈停车记录id
+Error_manager Parkspace_db_manager::query_parking_record(message::Parkspace_info &parkspace_info, int &record_id)
+{
+    // 基本条件判断
+    if(!mb_initialized)
+    {
+        return DB_UNINITIALIZED;
+    }
+    if(mp_db_controller == nullptr)
+    {
+        return POINTER_IS_NULL;
+    }else{
+        //执行sql操作
+        if(!parkspace_info.has_car_info() || parkspace_info.parkspace_id() <= 0)
+        {
+            return PARAMETER_ERROR;
+        }
+        std::string query_park_record_sql = std::string("select * from parkingrecords where numberPlate='").append(parkspace_info.car_info().license()).append("' and parkingSpaceID=").append(std::to_string(parkspace_info.parkspace_id())).append(" ORDER BY parkingRecordsID DESC");
+        boost::shared_ptr<sql::ResultSet>  tp_result = nullptr;
+        Error_manager ec = mp_db_controller->sql_query(query_park_record_sql, tp_result);
+        if(ec == SUCCESS)
+        {
+            if(tp_result == nullptr)
+            {
+                return DB_RESULT_SET_EMPTY;
+            }
+            if (tp_result->next())
+            {
+                char buf[1024];
+                memset(buf, 0, 1024);
+                try
+                {
+                    record_id = tp_result->getInt("parkingRecordsID");
+                }
+                catch (sql::SQLException &e)
+                {
+                    /* Use what() (derived from std::runtime_error) to fetch the error message */
+                    sprintf(buf, "# ERR: %s\n (MySQL error code: %d, SQLState: %s", e.what(), e.getErrorCode(), e.getSQLState().c_str());
+                    return Error_manager(DB_RESULT_SET_PARSE_ERROR, NEGLIGIBLE_ERROR, buf);
+                }
+                catch (std::runtime_error &e)
+                {
+                    sprintf(buf, "# ERR: %s\n ERR: runtime_error in  %s ", e.what(), __FILE__);
+                    return Error_manager(DB_RESULT_SET_PARSE_ERROR, NEGLIGIBLE_ERROR, buf);
+                }
+            }
+            return SUCCESS;
+        }
+        else
+        {
+            return ec;
+        }
+    }
+}

+ 72 - 0
parkspace_allocation/parkspace_db_manager.h

@@ -0,0 +1,72 @@
+/*
+ * @Description: 车位模块数据库管理类,提供接口实现特定的数据库操作
+ * @Author: yct
+ * @Date: 2020-07-19 09:44:17
+ * @LastEditTime: 2020-07-21 16:22:12
+ * @LastEditors: yct
+ */ 
+
+#ifndef PARKSPACE_DB_MANAGER_HH
+#define PARKSPACE_DB_MANAGER_HH
+
+#include "../tool/singleton.h"
+#include "../error_code/error_code.h"
+#include "../communication/communication_message.h"
+#include "../message/parkspace_allocation_message.pb.h"
+#include "parkspace_parameter.pb.h"
+
+#include "database_controller.h"
+#include <atomic>
+
+class Parkspace_db_manager : public Singleton<Parkspace_db_manager>
+{
+    // 子类必须把父类设定为友元函数,这样父类才能使用子类的私有构造函数。
+    friend class Singleton<Parkspace_db_manager>;
+
+public:
+    // 必须关闭拷贝构造和赋值构造,只能通过 get_instance 函数来进行操作唯一的实例。
+    Parkspace_db_manager(const Parkspace_db_manager &) = delete;
+    Parkspace_db_manager &operator=(const Parkspace_db_manager &) = delete;
+    ~Parkspace_db_manager() = default;
+    // 车位数据库管理初始化
+    Error_manager Parkspace_db_manager_init(parkspace_proto::database_config config);
+    // 车位数据库管理反初始化
+    Error_manager Parkspace_db_manager_uninit();
+    // 连接状态
+    bool is_connected();
+    // 初始化状态
+    bool is_initialized();
+    // ******** 数据库具体操作函数 *********
+    // 从数据库获得所有车位信息,用于车位模块初始化
+    Error_manager get_all_parkspace_info(message::Parkspace_allocation_status_msg &all_parkspace_info);
+    // 更新数据库中所有车位信息
+    Error_manager update_all_parkspace_info(message::Parkspace_allocation_status_msg all_parkspace_info);
+    // 更新数据库中车位状态
+    Error_manager update_parkspace_status(message::Parkspace_info parkspace_info);
+    // 更新数据库车辆状态,车位信息中包含车辆信息用于匹配更新
+    Error_manager update_vehicle_status(message::Parkspace_info parkspace_info, message::Vehicle_status &vehicle_status);
+    // 插入车辆
+    Error_manager insert_vehicle(message::Parkspace_info parkspace_info, message::Vehicle_status &vehicle_status);
+    // 插入停车记录
+    Error_manager insert_parking_record(message::Parkspace_info parkspace_info);
+    // 更新停车记录,待计费系统加入后完善!!!
+    Error_manager update_parking_record(message::Parkspace_info parkspace_info, int record_id);
+    // 根据车位编号查询车位状态
+    Error_manager query_parkspace(int parkspace_id, message::Parkspace_info &parkspace_info);
+    // 查询车辆状态,暂时不使用
+    Error_manager query_vehicle(std::string license, message::Vehicle_status &vehicle_status, int &park_record_id);
+    // 查询停车记录
+    Error_manager query_parking_record(message::Parkspace_info &parkspace_info, int &record_id);
+
+private:
+    // 父类的构造函数必须保护,子类的构造函数必须私有。
+    Parkspace_db_manager() = default;
+    // 数据库操作单例句柄
+    boost::shared_ptr<Database_controller> mp_db_controller;
+    // 初始化状态
+    std::atomic_bool mb_initialized;
+    // 连接状态
+    std::atomic_bool mb_connected;
+};
+
+#endif // !PARKSPACE_DB_MANAGER_HH

+ 695 - 0
parkspace_allocation/parkspace_parameter.pb.cc

@@ -0,0 +1,695 @@
+// Generated by the protocol buffer compiler.  DO NOT EDIT!
+// source: parkspace_parameter.proto
+
+#include "parkspace_parameter.pb.h"
+
+#include <algorithm>
+
+#include <google/protobuf/stubs/common.h>
+#include <google/protobuf/stubs/port.h>
+#include <google/protobuf/stubs/once.h>
+#include <google/protobuf/io/coded_stream.h>
+#include <google/protobuf/wire_format_lite_inl.h>
+#include <google/protobuf/descriptor.h>
+#include <google/protobuf/generated_message_reflection.h>
+#include <google/protobuf/reflection_ops.h>
+#include <google/protobuf/wire_format.h>
+// This is a temporary google only hack
+#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
+#include "third_party/protobuf/version.h"
+#endif
+// @@protoc_insertion_point(includes)
+namespace parkspace_proto {
+class database_configDefaultTypeInternal {
+ public:
+  ::google::protobuf::internal::ExplicitlyConstructed<database_config>
+      _instance;
+} _database_config_default_instance_;
+}  // namespace parkspace_proto
+namespace protobuf_parkspace_5fparameter_2eproto {
+void InitDefaultsdatabase_configImpl() {
+  GOOGLE_PROTOBUF_VERIFY_VERSION;
+
+#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
+  ::google::protobuf::internal::InitProtobufDefaultsForceUnique();
+#else
+  ::google::protobuf::internal::InitProtobufDefaults();
+#endif  // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
+  {
+    void* ptr = &::parkspace_proto::_database_config_default_instance_;
+    new (ptr) ::parkspace_proto::database_config();
+    ::google::protobuf::internal::OnShutdownDestroyMessage(ptr);
+  }
+  ::parkspace_proto::database_config::InitAsDefaultInstance();
+}
+
+void InitDefaultsdatabase_config() {
+  static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
+  ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsdatabase_configImpl);
+}
+
+::google::protobuf::Metadata file_level_metadata[1];
+
+const ::google::protobuf::uint32 TableStruct::offsets[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::parkspace_proto::database_config, _has_bits_),
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::parkspace_proto::database_config, _internal_metadata_),
+  ~0u,  // no _extensions_
+  ~0u,  // no _oneof_case_
+  ~0u,  // no _weak_field_map_
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::parkspace_proto::database_config, db_ip_),
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::parkspace_proto::database_config, db_port_),
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::parkspace_proto::database_config, db_username_),
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::parkspace_proto::database_config, db_passwd_),
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::parkspace_proto::database_config, db_name_),
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::parkspace_proto::database_config, db_conn_pool_size_),
+  0,
+  4,
+  1,
+  2,
+  3,
+  5,
+};
+static const ::google::protobuf::internal::MigrationSchema schemas[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
+  { 0, 11, sizeof(::parkspace_proto::database_config)},
+};
+
+static ::google::protobuf::Message const * const file_default_instances[] = {
+  reinterpret_cast<const ::google::protobuf::Message*>(&::parkspace_proto::_database_config_default_instance_),
+};
+
+void protobuf_AssignDescriptors() {
+  AddDescriptors();
+  ::google::protobuf::MessageFactory* factory = NULL;
+  AssignDescriptors(
+      "parkspace_parameter.proto", schemas, file_default_instances, TableStruct::offsets, factory,
+      file_level_metadata, NULL, NULL);
+}
+
+void protobuf_AssignDescriptorsOnce() {
+  static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
+  ::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors);
+}
+
+void protobuf_RegisterTypes(const ::std::string&) GOOGLE_PROTOBUF_ATTRIBUTE_COLD;
+void protobuf_RegisterTypes(const ::std::string&) {
+  protobuf_AssignDescriptorsOnce();
+  ::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 1);
+}
+
+void AddDescriptorsImpl() {
+  InitDefaults();
+  static const char descriptor[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
+      "\n\031parkspace_parameter.proto\022\017parkspace_p"
+      "roto\"\207\001\n\017database_config\022\r\n\005db_ip\030\001 \002(\t\022"
+      "\017\n\007db_port\030\002 \002(\003\022\023\n\013db_username\030\003 \002(\t\022\023\n"
+      "\tdb_passwd\030\004 \001(\t:\000\022\017\n\007db_name\030\005 \002(\t\022\031\n\021d"
+      "b_conn_pool_size\030\006 \001(\003"
+  };
+  ::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
+      descriptor, 182);
+  ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
+    "parkspace_parameter.proto", &protobuf_RegisterTypes);
+}
+
+void AddDescriptors() {
+  static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
+  ::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl);
+}
+// Force AddDescriptors() to be called at dynamic initialization time.
+struct StaticDescriptorInitializer {
+  StaticDescriptorInitializer() {
+    AddDescriptors();
+  }
+} static_descriptor_initializer;
+}  // namespace protobuf_parkspace_5fparameter_2eproto
+namespace parkspace_proto {
+
+// ===================================================================
+
+void database_config::InitAsDefaultInstance() {
+}
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int database_config::kDbIpFieldNumber;
+const int database_config::kDbPortFieldNumber;
+const int database_config::kDbUsernameFieldNumber;
+const int database_config::kDbPasswdFieldNumber;
+const int database_config::kDbNameFieldNumber;
+const int database_config::kDbConnPoolSizeFieldNumber;
+#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+database_config::database_config()
+  : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+  if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
+    ::protobuf_parkspace_5fparameter_2eproto::InitDefaultsdatabase_config();
+  }
+  SharedCtor();
+  // @@protoc_insertion_point(constructor:parkspace_proto.database_config)
+}
+database_config::database_config(const database_config& from)
+  : ::google::protobuf::Message(),
+      _internal_metadata_(NULL),
+      _has_bits_(from._has_bits_),
+      _cached_size_(0) {
+  _internal_metadata_.MergeFrom(from._internal_metadata_);
+  db_ip_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+  if (from.has_db_ip()) {
+    db_ip_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.db_ip_);
+  }
+  db_username_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+  if (from.has_db_username()) {
+    db_username_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.db_username_);
+  }
+  db_passwd_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+  if (from.has_db_passwd()) {
+    db_passwd_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.db_passwd_);
+  }
+  db_name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+  if (from.has_db_name()) {
+    db_name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.db_name_);
+  }
+  ::memcpy(&db_port_, &from.db_port_,
+    static_cast<size_t>(reinterpret_cast<char*>(&db_conn_pool_size_) -
+    reinterpret_cast<char*>(&db_port_)) + sizeof(db_conn_pool_size_));
+  // @@protoc_insertion_point(copy_constructor:parkspace_proto.database_config)
+}
+
+void database_config::SharedCtor() {
+  _cached_size_ = 0;
+  db_ip_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+  db_username_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+  db_passwd_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+  db_name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+  ::memset(&db_port_, 0, static_cast<size_t>(
+      reinterpret_cast<char*>(&db_conn_pool_size_) -
+      reinterpret_cast<char*>(&db_port_)) + sizeof(db_conn_pool_size_));
+}
+
+database_config::~database_config() {
+  // @@protoc_insertion_point(destructor:parkspace_proto.database_config)
+  SharedDtor();
+}
+
+void database_config::SharedDtor() {
+  db_ip_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+  db_username_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+  db_passwd_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+  db_name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+
+void database_config::SetCachedSize(int size) const {
+  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+  _cached_size_ = size;
+  GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* database_config::descriptor() {
+  ::protobuf_parkspace_5fparameter_2eproto::protobuf_AssignDescriptorsOnce();
+  return ::protobuf_parkspace_5fparameter_2eproto::file_level_metadata[kIndexInFileMessages].descriptor;
+}
+
+const database_config& database_config::default_instance() {
+  ::protobuf_parkspace_5fparameter_2eproto::InitDefaultsdatabase_config();
+  return *internal_default_instance();
+}
+
+database_config* database_config::New(::google::protobuf::Arena* arena) const {
+  database_config* n = new database_config;
+  if (arena != NULL) {
+    arena->Own(n);
+  }
+  return n;
+}
+
+void database_config::Clear() {
+// @@protoc_insertion_point(message_clear_start:parkspace_proto.database_config)
+  ::google::protobuf::uint32 cached_has_bits = 0;
+  // Prevent compiler warnings about cached_has_bits being unused
+  (void) cached_has_bits;
+
+  cached_has_bits = _has_bits_[0];
+  if (cached_has_bits & 15u) {
+    if (cached_has_bits & 0x00000001u) {
+      GOOGLE_DCHECK(!db_ip_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
+      (*db_ip_.UnsafeRawStringPointer())->clear();
+    }
+    if (cached_has_bits & 0x00000002u) {
+      GOOGLE_DCHECK(!db_username_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
+      (*db_username_.UnsafeRawStringPointer())->clear();
+    }
+    if (cached_has_bits & 0x00000004u) {
+      GOOGLE_DCHECK(!db_passwd_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
+      (*db_passwd_.UnsafeRawStringPointer())->clear();
+    }
+    if (cached_has_bits & 0x00000008u) {
+      GOOGLE_DCHECK(!db_name_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
+      (*db_name_.UnsafeRawStringPointer())->clear();
+    }
+  }
+  if (cached_has_bits & 48u) {
+    ::memset(&db_port_, 0, static_cast<size_t>(
+        reinterpret_cast<char*>(&db_conn_pool_size_) -
+        reinterpret_cast<char*>(&db_port_)) + sizeof(db_conn_pool_size_));
+  }
+  _has_bits_.Clear();
+  _internal_metadata_.Clear();
+}
+
+bool database_config::MergePartialFromCodedStream(
+    ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+  ::google::protobuf::uint32 tag;
+  // @@protoc_insertion_point(parse_start:parkspace_proto.database_config)
+  for (;;) {
+    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
+    tag = p.first;
+    if (!p.second) goto handle_unusual;
+    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+      // required string db_ip = 1;
+      case 1: {
+        if (static_cast< ::google::protobuf::uint8>(tag) ==
+            static_cast< ::google::protobuf::uint8>(10u /* 10 & 0xFF */)) {
+          DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+                input, this->mutable_db_ip()));
+          ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+            this->db_ip().data(), static_cast<int>(this->db_ip().length()),
+            ::google::protobuf::internal::WireFormat::PARSE,
+            "parkspace_proto.database_config.db_ip");
+        } else {
+          goto handle_unusual;
+        }
+        break;
+      }
+
+      // required int64 db_port = 2;
+      case 2: {
+        if (static_cast< ::google::protobuf::uint8>(tag) ==
+            static_cast< ::google::protobuf::uint8>(16u /* 16 & 0xFF */)) {
+          set_has_db_port();
+          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+                   ::google::protobuf::int64, ::google::protobuf::internal::WireFormatLite::TYPE_INT64>(
+                 input, &db_port_)));
+        } else {
+          goto handle_unusual;
+        }
+        break;
+      }
+
+      // required string db_username = 3;
+      case 3: {
+        if (static_cast< ::google::protobuf::uint8>(tag) ==
+            static_cast< ::google::protobuf::uint8>(26u /* 26 & 0xFF */)) {
+          DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+                input, this->mutable_db_username()));
+          ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+            this->db_username().data(), static_cast<int>(this->db_username().length()),
+            ::google::protobuf::internal::WireFormat::PARSE,
+            "parkspace_proto.database_config.db_username");
+        } else {
+          goto handle_unusual;
+        }
+        break;
+      }
+
+      // optional string db_passwd = 4 [default = ""];
+      case 4: {
+        if (static_cast< ::google::protobuf::uint8>(tag) ==
+            static_cast< ::google::protobuf::uint8>(34u /* 34 & 0xFF */)) {
+          DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+                input, this->mutable_db_passwd()));
+          ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+            this->db_passwd().data(), static_cast<int>(this->db_passwd().length()),
+            ::google::protobuf::internal::WireFormat::PARSE,
+            "parkspace_proto.database_config.db_passwd");
+        } else {
+          goto handle_unusual;
+        }
+        break;
+      }
+
+      // required string db_name = 5;
+      case 5: {
+        if (static_cast< ::google::protobuf::uint8>(tag) ==
+            static_cast< ::google::protobuf::uint8>(42u /* 42 & 0xFF */)) {
+          DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+                input, this->mutable_db_name()));
+          ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+            this->db_name().data(), static_cast<int>(this->db_name().length()),
+            ::google::protobuf::internal::WireFormat::PARSE,
+            "parkspace_proto.database_config.db_name");
+        } else {
+          goto handle_unusual;
+        }
+        break;
+      }
+
+      // optional int64 db_conn_pool_size = 6;
+      case 6: {
+        if (static_cast< ::google::protobuf::uint8>(tag) ==
+            static_cast< ::google::protobuf::uint8>(48u /* 48 & 0xFF */)) {
+          set_has_db_conn_pool_size();
+          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+                   ::google::protobuf::int64, ::google::protobuf::internal::WireFormatLite::TYPE_INT64>(
+                 input, &db_conn_pool_size_)));
+        } else {
+          goto handle_unusual;
+        }
+        break;
+      }
+
+      default: {
+      handle_unusual:
+        if (tag == 0) {
+          goto success;
+        }
+        DO_(::google::protobuf::internal::WireFormat::SkipField(
+              input, tag, _internal_metadata_.mutable_unknown_fields()));
+        break;
+      }
+    }
+  }
+success:
+  // @@protoc_insertion_point(parse_success:parkspace_proto.database_config)
+  return true;
+failure:
+  // @@protoc_insertion_point(parse_failure:parkspace_proto.database_config)
+  return false;
+#undef DO_
+}
+
+void database_config::SerializeWithCachedSizes(
+    ::google::protobuf::io::CodedOutputStream* output) const {
+  // @@protoc_insertion_point(serialize_start:parkspace_proto.database_config)
+  ::google::protobuf::uint32 cached_has_bits = 0;
+  (void) cached_has_bits;
+
+  cached_has_bits = _has_bits_[0];
+  // required string db_ip = 1;
+  if (cached_has_bits & 0x00000001u) {
+    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+      this->db_ip().data(), static_cast<int>(this->db_ip().length()),
+      ::google::protobuf::internal::WireFormat::SERIALIZE,
+      "parkspace_proto.database_config.db_ip");
+    ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
+      1, this->db_ip(), output);
+  }
+
+  // required int64 db_port = 2;
+  if (cached_has_bits & 0x00000010u) {
+    ::google::protobuf::internal::WireFormatLite::WriteInt64(2, this->db_port(), output);
+  }
+
+  // required string db_username = 3;
+  if (cached_has_bits & 0x00000002u) {
+    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+      this->db_username().data(), static_cast<int>(this->db_username().length()),
+      ::google::protobuf::internal::WireFormat::SERIALIZE,
+      "parkspace_proto.database_config.db_username");
+    ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
+      3, this->db_username(), output);
+  }
+
+  // optional string db_passwd = 4 [default = ""];
+  if (cached_has_bits & 0x00000004u) {
+    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+      this->db_passwd().data(), static_cast<int>(this->db_passwd().length()),
+      ::google::protobuf::internal::WireFormat::SERIALIZE,
+      "parkspace_proto.database_config.db_passwd");
+    ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
+      4, this->db_passwd(), output);
+  }
+
+  // required string db_name = 5;
+  if (cached_has_bits & 0x00000008u) {
+    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+      this->db_name().data(), static_cast<int>(this->db_name().length()),
+      ::google::protobuf::internal::WireFormat::SERIALIZE,
+      "parkspace_proto.database_config.db_name");
+    ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
+      5, this->db_name(), output);
+  }
+
+  // optional int64 db_conn_pool_size = 6;
+  if (cached_has_bits & 0x00000020u) {
+    ::google::protobuf::internal::WireFormatLite::WriteInt64(6, this->db_conn_pool_size(), output);
+  }
+
+  if (_internal_metadata_.have_unknown_fields()) {
+    ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+        _internal_metadata_.unknown_fields(), output);
+  }
+  // @@protoc_insertion_point(serialize_end:parkspace_proto.database_config)
+}
+
+::google::protobuf::uint8* database_config::InternalSerializeWithCachedSizesToArray(
+    bool deterministic, ::google::protobuf::uint8* target) const {
+  (void)deterministic; // Unused
+  // @@protoc_insertion_point(serialize_to_array_start:parkspace_proto.database_config)
+  ::google::protobuf::uint32 cached_has_bits = 0;
+  (void) cached_has_bits;
+
+  cached_has_bits = _has_bits_[0];
+  // required string db_ip = 1;
+  if (cached_has_bits & 0x00000001u) {
+    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+      this->db_ip().data(), static_cast<int>(this->db_ip().length()),
+      ::google::protobuf::internal::WireFormat::SERIALIZE,
+      "parkspace_proto.database_config.db_ip");
+    target =
+      ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
+        1, this->db_ip(), target);
+  }
+
+  // required int64 db_port = 2;
+  if (cached_has_bits & 0x00000010u) {
+    target = ::google::protobuf::internal::WireFormatLite::WriteInt64ToArray(2, this->db_port(), target);
+  }
+
+  // required string db_username = 3;
+  if (cached_has_bits & 0x00000002u) {
+    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+      this->db_username().data(), static_cast<int>(this->db_username().length()),
+      ::google::protobuf::internal::WireFormat::SERIALIZE,
+      "parkspace_proto.database_config.db_username");
+    target =
+      ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
+        3, this->db_username(), target);
+  }
+
+  // optional string db_passwd = 4 [default = ""];
+  if (cached_has_bits & 0x00000004u) {
+    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+      this->db_passwd().data(), static_cast<int>(this->db_passwd().length()),
+      ::google::protobuf::internal::WireFormat::SERIALIZE,
+      "parkspace_proto.database_config.db_passwd");
+    target =
+      ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
+        4, this->db_passwd(), target);
+  }
+
+  // required string db_name = 5;
+  if (cached_has_bits & 0x00000008u) {
+    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+      this->db_name().data(), static_cast<int>(this->db_name().length()),
+      ::google::protobuf::internal::WireFormat::SERIALIZE,
+      "parkspace_proto.database_config.db_name");
+    target =
+      ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
+        5, this->db_name(), target);
+  }
+
+  // optional int64 db_conn_pool_size = 6;
+  if (cached_has_bits & 0x00000020u) {
+    target = ::google::protobuf::internal::WireFormatLite::WriteInt64ToArray(6, this->db_conn_pool_size(), target);
+  }
+
+  if (_internal_metadata_.have_unknown_fields()) {
+    target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+        _internal_metadata_.unknown_fields(), target);
+  }
+  // @@protoc_insertion_point(serialize_to_array_end:parkspace_proto.database_config)
+  return target;
+}
+
+size_t database_config::RequiredFieldsByteSizeFallback() const {
+// @@protoc_insertion_point(required_fields_byte_size_fallback_start:parkspace_proto.database_config)
+  size_t total_size = 0;
+
+  if (has_db_ip()) {
+    // required string db_ip = 1;
+    total_size += 1 +
+      ::google::protobuf::internal::WireFormatLite::StringSize(
+        this->db_ip());
+  }
+
+  if (has_db_username()) {
+    // required string db_username = 3;
+    total_size += 1 +
+      ::google::protobuf::internal::WireFormatLite::StringSize(
+        this->db_username());
+  }
+
+  if (has_db_name()) {
+    // required string db_name = 5;
+    total_size += 1 +
+      ::google::protobuf::internal::WireFormatLite::StringSize(
+        this->db_name());
+  }
+
+  if (has_db_port()) {
+    // required int64 db_port = 2;
+    total_size += 1 +
+      ::google::protobuf::internal::WireFormatLite::Int64Size(
+        this->db_port());
+  }
+
+  return total_size;
+}
+size_t database_config::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:parkspace_proto.database_config)
+  size_t total_size = 0;
+
+  if (_internal_metadata_.have_unknown_fields()) {
+    total_size +=
+      ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+        _internal_metadata_.unknown_fields());
+  }
+  if (((_has_bits_[0] & 0x0000001b) ^ 0x0000001b) == 0) {  // All required fields are present.
+    // required string db_ip = 1;
+    total_size += 1 +
+      ::google::protobuf::internal::WireFormatLite::StringSize(
+        this->db_ip());
+
+    // required string db_username = 3;
+    total_size += 1 +
+      ::google::protobuf::internal::WireFormatLite::StringSize(
+        this->db_username());
+
+    // required string db_name = 5;
+    total_size += 1 +
+      ::google::protobuf::internal::WireFormatLite::StringSize(
+        this->db_name());
+
+    // required int64 db_port = 2;
+    total_size += 1 +
+      ::google::protobuf::internal::WireFormatLite::Int64Size(
+        this->db_port());
+
+  } else {
+    total_size += RequiredFieldsByteSizeFallback();
+  }
+  // optional string db_passwd = 4 [default = ""];
+  if (has_db_passwd()) {
+    total_size += 1 +
+      ::google::protobuf::internal::WireFormatLite::StringSize(
+        this->db_passwd());
+  }
+
+  // optional int64 db_conn_pool_size = 6;
+  if (has_db_conn_pool_size()) {
+    total_size += 1 +
+      ::google::protobuf::internal::WireFormatLite::Int64Size(
+        this->db_conn_pool_size());
+  }
+
+  int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+  _cached_size_ = cached_size;
+  GOOGLE_SAFE_CONCURRENT_WRITES_END();
+  return total_size;
+}
+
+void database_config::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:parkspace_proto.database_config)
+  GOOGLE_DCHECK_NE(&from, this);
+  const database_config* source =
+      ::google::protobuf::internal::DynamicCastToGenerated<const database_config>(
+          &from);
+  if (source == NULL) {
+  // @@protoc_insertion_point(generalized_merge_from_cast_fail:parkspace_proto.database_config)
+    ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+  } else {
+  // @@protoc_insertion_point(generalized_merge_from_cast_success:parkspace_proto.database_config)
+    MergeFrom(*source);
+  }
+}
+
+void database_config::MergeFrom(const database_config& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:parkspace_proto.database_config)
+  GOOGLE_DCHECK_NE(&from, this);
+  _internal_metadata_.MergeFrom(from._internal_metadata_);
+  ::google::protobuf::uint32 cached_has_bits = 0;
+  (void) cached_has_bits;
+
+  cached_has_bits = from._has_bits_[0];
+  if (cached_has_bits & 63u) {
+    if (cached_has_bits & 0x00000001u) {
+      set_has_db_ip();
+      db_ip_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.db_ip_);
+    }
+    if (cached_has_bits & 0x00000002u) {
+      set_has_db_username();
+      db_username_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.db_username_);
+    }
+    if (cached_has_bits & 0x00000004u) {
+      set_has_db_passwd();
+      db_passwd_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.db_passwd_);
+    }
+    if (cached_has_bits & 0x00000008u) {
+      set_has_db_name();
+      db_name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.db_name_);
+    }
+    if (cached_has_bits & 0x00000010u) {
+      db_port_ = from.db_port_;
+    }
+    if (cached_has_bits & 0x00000020u) {
+      db_conn_pool_size_ = from.db_conn_pool_size_;
+    }
+    _has_bits_[0] |= cached_has_bits;
+  }
+}
+
+void database_config::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:parkspace_proto.database_config)
+  if (&from == this) return;
+  Clear();
+  MergeFrom(from);
+}
+
+void database_config::CopyFrom(const database_config& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:parkspace_proto.database_config)
+  if (&from == this) return;
+  Clear();
+  MergeFrom(from);
+}
+
+bool database_config::IsInitialized() const {
+  if ((_has_bits_[0] & 0x0000001b) != 0x0000001b) return false;
+  return true;
+}
+
+void database_config::Swap(database_config* other) {
+  if (other == this) return;
+  InternalSwap(other);
+}
+void database_config::InternalSwap(database_config* other) {
+  using std::swap;
+  db_ip_.Swap(&other->db_ip_);
+  db_username_.Swap(&other->db_username_);
+  db_passwd_.Swap(&other->db_passwd_);
+  db_name_.Swap(&other->db_name_);
+  swap(db_port_, other->db_port_);
+  swap(db_conn_pool_size_, other->db_conn_pool_size_);
+  swap(_has_bits_[0], other->_has_bits_[0]);
+  _internal_metadata_.Swap(&other->_internal_metadata_);
+  swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata database_config::GetMetadata() const {
+  protobuf_parkspace_5fparameter_2eproto::protobuf_AssignDescriptorsOnce();
+  return ::protobuf_parkspace_5fparameter_2eproto::file_level_metadata[kIndexInFileMessages];
+}
+
+
+// @@protoc_insertion_point(namespace_scope)
+}  // namespace parkspace_proto
+
+// @@protoc_insertion_point(global_scope)

+ 574 - 0
parkspace_allocation/parkspace_parameter.pb.h

@@ -0,0 +1,574 @@
+// Generated by the protocol buffer compiler.  DO NOT EDIT!
+// source: parkspace_parameter.proto
+
+#ifndef PROTOBUF_parkspace_5fparameter_2eproto__INCLUDED
+#define PROTOBUF_parkspace_5fparameter_2eproto__INCLUDED
+
+#include <string>
+
+#include <google/protobuf/stubs/common.h>
+
+#if GOOGLE_PROTOBUF_VERSION < 3005000
+#error This file was generated by a newer version of protoc which is
+#error incompatible with your Protocol Buffer headers.  Please update
+#error your headers.
+#endif
+#if 3005000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
+#error This file was generated by an older version of protoc which is
+#error incompatible with your Protocol Buffer headers.  Please
+#error regenerate this file with a newer version of protoc.
+#endif
+
+#include <google/protobuf/io/coded_stream.h>
+#include <google/protobuf/arena.h>
+#include <google/protobuf/arenastring.h>
+#include <google/protobuf/generated_message_table_driven.h>
+#include <google/protobuf/generated_message_util.h>
+#include <google/protobuf/metadata.h>
+#include <google/protobuf/message.h>
+#include <google/protobuf/repeated_field.h>  // IWYU pragma: export
+#include <google/protobuf/extension_set.h>  // IWYU pragma: export
+#include <google/protobuf/unknown_field_set.h>
+// @@protoc_insertion_point(includes)
+
+namespace protobuf_parkspace_5fparameter_2eproto {
+// Internal implementation detail -- do not use these members.
+struct TableStruct {
+  static const ::google::protobuf::internal::ParseTableField entries[];
+  static const ::google::protobuf::internal::AuxillaryParseTableField aux[];
+  static const ::google::protobuf::internal::ParseTable schema[1];
+  static const ::google::protobuf::internal::FieldMetadata field_metadata[];
+  static const ::google::protobuf::internal::SerializationTable serialization_table[];
+  static const ::google::protobuf::uint32 offsets[];
+};
+void AddDescriptors();
+void InitDefaultsdatabase_configImpl();
+void InitDefaultsdatabase_config();
+inline void InitDefaults() {
+  InitDefaultsdatabase_config();
+}
+}  // namespace protobuf_parkspace_5fparameter_2eproto
+namespace parkspace_proto {
+class database_config;
+class database_configDefaultTypeInternal;
+extern database_configDefaultTypeInternal _database_config_default_instance_;
+}  // namespace parkspace_proto
+namespace parkspace_proto {
+
+// ===================================================================
+
+class database_config : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:parkspace_proto.database_config) */ {
+ public:
+  database_config();
+  virtual ~database_config();
+
+  database_config(const database_config& from);
+
+  inline database_config& operator=(const database_config& from) {
+    CopyFrom(from);
+    return *this;
+  }
+  #if LANG_CXX11
+  database_config(database_config&& from) noexcept
+    : database_config() {
+    *this = ::std::move(from);
+  }
+
+  inline database_config& operator=(database_config&& from) noexcept {
+    if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) {
+      if (this != &from) InternalSwap(&from);
+    } else {
+      CopyFrom(from);
+    }
+    return *this;
+  }
+  #endif
+  inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+    return _internal_metadata_.unknown_fields();
+  }
+  inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+    return _internal_metadata_.mutable_unknown_fields();
+  }
+
+  static const ::google::protobuf::Descriptor* descriptor();
+  static const database_config& default_instance();
+
+  static void InitAsDefaultInstance();  // FOR INTERNAL USE ONLY
+  static inline const database_config* internal_default_instance() {
+    return reinterpret_cast<const database_config*>(
+               &_database_config_default_instance_);
+  }
+  static PROTOBUF_CONSTEXPR int const kIndexInFileMessages =
+    0;
+
+  void Swap(database_config* other);
+  friend void swap(database_config& a, database_config& b) {
+    a.Swap(&b);
+  }
+
+  // implements Message ----------------------------------------------
+
+  inline database_config* New() const PROTOBUF_FINAL { return New(NULL); }
+
+  database_config* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+  void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+  void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+  void CopyFrom(const database_config& from);
+  void MergeFrom(const database_config& from);
+  void Clear() PROTOBUF_FINAL;
+  bool IsInitialized() const PROTOBUF_FINAL;
+
+  size_t ByteSizeLong() const PROTOBUF_FINAL;
+  bool MergePartialFromCodedStream(
+      ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
+  void SerializeWithCachedSizes(
+      ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
+  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+      bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
+  int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
+  private:
+  void SharedCtor();
+  void SharedDtor();
+  void SetCachedSize(int size) const PROTOBUF_FINAL;
+  void InternalSwap(database_config* other);
+  private:
+  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+    return NULL;
+  }
+  inline void* MaybeArenaPtr() const {
+    return NULL;
+  }
+  public:
+
+  ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
+
+  // nested types ----------------------------------------------------
+
+  // accessors -------------------------------------------------------
+
+  // required string db_ip = 1;
+  bool has_db_ip() const;
+  void clear_db_ip();
+  static const int kDbIpFieldNumber = 1;
+  const ::std::string& db_ip() const;
+  void set_db_ip(const ::std::string& value);
+  #if LANG_CXX11
+  void set_db_ip(::std::string&& value);
+  #endif
+  void set_db_ip(const char* value);
+  void set_db_ip(const char* value, size_t size);
+  ::std::string* mutable_db_ip();
+  ::std::string* release_db_ip();
+  void set_allocated_db_ip(::std::string* db_ip);
+
+  // required string db_username = 3;
+  bool has_db_username() const;
+  void clear_db_username();
+  static const int kDbUsernameFieldNumber = 3;
+  const ::std::string& db_username() const;
+  void set_db_username(const ::std::string& value);
+  #if LANG_CXX11
+  void set_db_username(::std::string&& value);
+  #endif
+  void set_db_username(const char* value);
+  void set_db_username(const char* value, size_t size);
+  ::std::string* mutable_db_username();
+  ::std::string* release_db_username();
+  void set_allocated_db_username(::std::string* db_username);
+
+  // optional string db_passwd = 4 [default = ""];
+  bool has_db_passwd() const;
+  void clear_db_passwd();
+  static const int kDbPasswdFieldNumber = 4;
+  const ::std::string& db_passwd() const;
+  void set_db_passwd(const ::std::string& value);
+  #if LANG_CXX11
+  void set_db_passwd(::std::string&& value);
+  #endif
+  void set_db_passwd(const char* value);
+  void set_db_passwd(const char* value, size_t size);
+  ::std::string* mutable_db_passwd();
+  ::std::string* release_db_passwd();
+  void set_allocated_db_passwd(::std::string* db_passwd);
+
+  // required string db_name = 5;
+  bool has_db_name() const;
+  void clear_db_name();
+  static const int kDbNameFieldNumber = 5;
+  const ::std::string& db_name() const;
+  void set_db_name(const ::std::string& value);
+  #if LANG_CXX11
+  void set_db_name(::std::string&& value);
+  #endif
+  void set_db_name(const char* value);
+  void set_db_name(const char* value, size_t size);
+  ::std::string* mutable_db_name();
+  ::std::string* release_db_name();
+  void set_allocated_db_name(::std::string* db_name);
+
+  // required int64 db_port = 2;
+  bool has_db_port() const;
+  void clear_db_port();
+  static const int kDbPortFieldNumber = 2;
+  ::google::protobuf::int64 db_port() const;
+  void set_db_port(::google::protobuf::int64 value);
+
+  // optional int64 db_conn_pool_size = 6;
+  bool has_db_conn_pool_size() const;
+  void clear_db_conn_pool_size();
+  static const int kDbConnPoolSizeFieldNumber = 6;
+  ::google::protobuf::int64 db_conn_pool_size() const;
+  void set_db_conn_pool_size(::google::protobuf::int64 value);
+
+  // @@protoc_insertion_point(class_scope:parkspace_proto.database_config)
+ private:
+  void set_has_db_ip();
+  void clear_has_db_ip();
+  void set_has_db_port();
+  void clear_has_db_port();
+  void set_has_db_username();
+  void clear_has_db_username();
+  void set_has_db_passwd();
+  void clear_has_db_passwd();
+  void set_has_db_name();
+  void clear_has_db_name();
+  void set_has_db_conn_pool_size();
+  void clear_has_db_conn_pool_size();
+
+  // helper for ByteSizeLong()
+  size_t RequiredFieldsByteSizeFallback() const;
+
+  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+  ::google::protobuf::internal::HasBits<1> _has_bits_;
+  mutable int _cached_size_;
+  ::google::protobuf::internal::ArenaStringPtr db_ip_;
+  ::google::protobuf::internal::ArenaStringPtr db_username_;
+  ::google::protobuf::internal::ArenaStringPtr db_passwd_;
+  ::google::protobuf::internal::ArenaStringPtr db_name_;
+  ::google::protobuf::int64 db_port_;
+  ::google::protobuf::int64 db_conn_pool_size_;
+  friend struct ::protobuf_parkspace_5fparameter_2eproto::TableStruct;
+  friend void ::protobuf_parkspace_5fparameter_2eproto::InitDefaultsdatabase_configImpl();
+};
+// ===================================================================
+
+
+// ===================================================================
+
+#ifdef __GNUC__
+  #pragma GCC diagnostic push
+  #pragma GCC diagnostic ignored "-Wstrict-aliasing"
+#endif  // __GNUC__
+// database_config
+
+// required string db_ip = 1;
+inline bool database_config::has_db_ip() const {
+  return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void database_config::set_has_db_ip() {
+  _has_bits_[0] |= 0x00000001u;
+}
+inline void database_config::clear_has_db_ip() {
+  _has_bits_[0] &= ~0x00000001u;
+}
+inline void database_config::clear_db_ip() {
+  db_ip_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+  clear_has_db_ip();
+}
+inline const ::std::string& database_config::db_ip() const {
+  // @@protoc_insertion_point(field_get:parkspace_proto.database_config.db_ip)
+  return db_ip_.GetNoArena();
+}
+inline void database_config::set_db_ip(const ::std::string& value) {
+  set_has_db_ip();
+  db_ip_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+  // @@protoc_insertion_point(field_set:parkspace_proto.database_config.db_ip)
+}
+#if LANG_CXX11
+inline void database_config::set_db_ip(::std::string&& value) {
+  set_has_db_ip();
+  db_ip_.SetNoArena(
+    &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+  // @@protoc_insertion_point(field_set_rvalue:parkspace_proto.database_config.db_ip)
+}
+#endif
+inline void database_config::set_db_ip(const char* value) {
+  GOOGLE_DCHECK(value != NULL);
+  set_has_db_ip();
+  db_ip_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+  // @@protoc_insertion_point(field_set_char:parkspace_proto.database_config.db_ip)
+}
+inline void database_config::set_db_ip(const char* value, size_t size) {
+  set_has_db_ip();
+  db_ip_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+      ::std::string(reinterpret_cast<const char*>(value), size));
+  // @@protoc_insertion_point(field_set_pointer:parkspace_proto.database_config.db_ip)
+}
+inline ::std::string* database_config::mutable_db_ip() {
+  set_has_db_ip();
+  // @@protoc_insertion_point(field_mutable:parkspace_proto.database_config.db_ip)
+  return db_ip_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline ::std::string* database_config::release_db_ip() {
+  // @@protoc_insertion_point(field_release:parkspace_proto.database_config.db_ip)
+  clear_has_db_ip();
+  return db_ip_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void database_config::set_allocated_db_ip(::std::string* db_ip) {
+  if (db_ip != NULL) {
+    set_has_db_ip();
+  } else {
+    clear_has_db_ip();
+  }
+  db_ip_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), db_ip);
+  // @@protoc_insertion_point(field_set_allocated:parkspace_proto.database_config.db_ip)
+}
+
+// required int64 db_port = 2;
+inline bool database_config::has_db_port() const {
+  return (_has_bits_[0] & 0x00000010u) != 0;
+}
+inline void database_config::set_has_db_port() {
+  _has_bits_[0] |= 0x00000010u;
+}
+inline void database_config::clear_has_db_port() {
+  _has_bits_[0] &= ~0x00000010u;
+}
+inline void database_config::clear_db_port() {
+  db_port_ = GOOGLE_LONGLONG(0);
+  clear_has_db_port();
+}
+inline ::google::protobuf::int64 database_config::db_port() const {
+  // @@protoc_insertion_point(field_get:parkspace_proto.database_config.db_port)
+  return db_port_;
+}
+inline void database_config::set_db_port(::google::protobuf::int64 value) {
+  set_has_db_port();
+  db_port_ = value;
+  // @@protoc_insertion_point(field_set:parkspace_proto.database_config.db_port)
+}
+
+// required string db_username = 3;
+inline bool database_config::has_db_username() const {
+  return (_has_bits_[0] & 0x00000002u) != 0;
+}
+inline void database_config::set_has_db_username() {
+  _has_bits_[0] |= 0x00000002u;
+}
+inline void database_config::clear_has_db_username() {
+  _has_bits_[0] &= ~0x00000002u;
+}
+inline void database_config::clear_db_username() {
+  db_username_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+  clear_has_db_username();
+}
+inline const ::std::string& database_config::db_username() const {
+  // @@protoc_insertion_point(field_get:parkspace_proto.database_config.db_username)
+  return db_username_.GetNoArena();
+}
+inline void database_config::set_db_username(const ::std::string& value) {
+  set_has_db_username();
+  db_username_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+  // @@protoc_insertion_point(field_set:parkspace_proto.database_config.db_username)
+}
+#if LANG_CXX11
+inline void database_config::set_db_username(::std::string&& value) {
+  set_has_db_username();
+  db_username_.SetNoArena(
+    &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+  // @@protoc_insertion_point(field_set_rvalue:parkspace_proto.database_config.db_username)
+}
+#endif
+inline void database_config::set_db_username(const char* value) {
+  GOOGLE_DCHECK(value != NULL);
+  set_has_db_username();
+  db_username_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+  // @@protoc_insertion_point(field_set_char:parkspace_proto.database_config.db_username)
+}
+inline void database_config::set_db_username(const char* value, size_t size) {
+  set_has_db_username();
+  db_username_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+      ::std::string(reinterpret_cast<const char*>(value), size));
+  // @@protoc_insertion_point(field_set_pointer:parkspace_proto.database_config.db_username)
+}
+inline ::std::string* database_config::mutable_db_username() {
+  set_has_db_username();
+  // @@protoc_insertion_point(field_mutable:parkspace_proto.database_config.db_username)
+  return db_username_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline ::std::string* database_config::release_db_username() {
+  // @@protoc_insertion_point(field_release:parkspace_proto.database_config.db_username)
+  clear_has_db_username();
+  return db_username_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void database_config::set_allocated_db_username(::std::string* db_username) {
+  if (db_username != NULL) {
+    set_has_db_username();
+  } else {
+    clear_has_db_username();
+  }
+  db_username_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), db_username);
+  // @@protoc_insertion_point(field_set_allocated:parkspace_proto.database_config.db_username)
+}
+
+// optional string db_passwd = 4 [default = ""];
+inline bool database_config::has_db_passwd() const {
+  return (_has_bits_[0] & 0x00000004u) != 0;
+}
+inline void database_config::set_has_db_passwd() {
+  _has_bits_[0] |= 0x00000004u;
+}
+inline void database_config::clear_has_db_passwd() {
+  _has_bits_[0] &= ~0x00000004u;
+}
+inline void database_config::clear_db_passwd() {
+  db_passwd_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+  clear_has_db_passwd();
+}
+inline const ::std::string& database_config::db_passwd() const {
+  // @@protoc_insertion_point(field_get:parkspace_proto.database_config.db_passwd)
+  return db_passwd_.GetNoArena();
+}
+inline void database_config::set_db_passwd(const ::std::string& value) {
+  set_has_db_passwd();
+  db_passwd_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+  // @@protoc_insertion_point(field_set:parkspace_proto.database_config.db_passwd)
+}
+#if LANG_CXX11
+inline void database_config::set_db_passwd(::std::string&& value) {
+  set_has_db_passwd();
+  db_passwd_.SetNoArena(
+    &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+  // @@protoc_insertion_point(field_set_rvalue:parkspace_proto.database_config.db_passwd)
+}
+#endif
+inline void database_config::set_db_passwd(const char* value) {
+  GOOGLE_DCHECK(value != NULL);
+  set_has_db_passwd();
+  db_passwd_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+  // @@protoc_insertion_point(field_set_char:parkspace_proto.database_config.db_passwd)
+}
+inline void database_config::set_db_passwd(const char* value, size_t size) {
+  set_has_db_passwd();
+  db_passwd_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+      ::std::string(reinterpret_cast<const char*>(value), size));
+  // @@protoc_insertion_point(field_set_pointer:parkspace_proto.database_config.db_passwd)
+}
+inline ::std::string* database_config::mutable_db_passwd() {
+  set_has_db_passwd();
+  // @@protoc_insertion_point(field_mutable:parkspace_proto.database_config.db_passwd)
+  return db_passwd_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline ::std::string* database_config::release_db_passwd() {
+  // @@protoc_insertion_point(field_release:parkspace_proto.database_config.db_passwd)
+  clear_has_db_passwd();
+  return db_passwd_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void database_config::set_allocated_db_passwd(::std::string* db_passwd) {
+  if (db_passwd != NULL) {
+    set_has_db_passwd();
+  } else {
+    clear_has_db_passwd();
+  }
+  db_passwd_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), db_passwd);
+  // @@protoc_insertion_point(field_set_allocated:parkspace_proto.database_config.db_passwd)
+}
+
+// required string db_name = 5;
+inline bool database_config::has_db_name() const {
+  return (_has_bits_[0] & 0x00000008u) != 0;
+}
+inline void database_config::set_has_db_name() {
+  _has_bits_[0] |= 0x00000008u;
+}
+inline void database_config::clear_has_db_name() {
+  _has_bits_[0] &= ~0x00000008u;
+}
+inline void database_config::clear_db_name() {
+  db_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+  clear_has_db_name();
+}
+inline const ::std::string& database_config::db_name() const {
+  // @@protoc_insertion_point(field_get:parkspace_proto.database_config.db_name)
+  return db_name_.GetNoArena();
+}
+inline void database_config::set_db_name(const ::std::string& value) {
+  set_has_db_name();
+  db_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+  // @@protoc_insertion_point(field_set:parkspace_proto.database_config.db_name)
+}
+#if LANG_CXX11
+inline void database_config::set_db_name(::std::string&& value) {
+  set_has_db_name();
+  db_name_.SetNoArena(
+    &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+  // @@protoc_insertion_point(field_set_rvalue:parkspace_proto.database_config.db_name)
+}
+#endif
+inline void database_config::set_db_name(const char* value) {
+  GOOGLE_DCHECK(value != NULL);
+  set_has_db_name();
+  db_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+  // @@protoc_insertion_point(field_set_char:parkspace_proto.database_config.db_name)
+}
+inline void database_config::set_db_name(const char* value, size_t size) {
+  set_has_db_name();
+  db_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+      ::std::string(reinterpret_cast<const char*>(value), size));
+  // @@protoc_insertion_point(field_set_pointer:parkspace_proto.database_config.db_name)
+}
+inline ::std::string* database_config::mutable_db_name() {
+  set_has_db_name();
+  // @@protoc_insertion_point(field_mutable:parkspace_proto.database_config.db_name)
+  return db_name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline ::std::string* database_config::release_db_name() {
+  // @@protoc_insertion_point(field_release:parkspace_proto.database_config.db_name)
+  clear_has_db_name();
+  return db_name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void database_config::set_allocated_db_name(::std::string* db_name) {
+  if (db_name != NULL) {
+    set_has_db_name();
+  } else {
+    clear_has_db_name();
+  }
+  db_name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), db_name);
+  // @@protoc_insertion_point(field_set_allocated:parkspace_proto.database_config.db_name)
+}
+
+// optional int64 db_conn_pool_size = 6;
+inline bool database_config::has_db_conn_pool_size() const {
+  return (_has_bits_[0] & 0x00000020u) != 0;
+}
+inline void database_config::set_has_db_conn_pool_size() {
+  _has_bits_[0] |= 0x00000020u;
+}
+inline void database_config::clear_has_db_conn_pool_size() {
+  _has_bits_[0] &= ~0x00000020u;
+}
+inline void database_config::clear_db_conn_pool_size() {
+  db_conn_pool_size_ = GOOGLE_LONGLONG(0);
+  clear_has_db_conn_pool_size();
+}
+inline ::google::protobuf::int64 database_config::db_conn_pool_size() const {
+  // @@protoc_insertion_point(field_get:parkspace_proto.database_config.db_conn_pool_size)
+  return db_conn_pool_size_;
+}
+inline void database_config::set_db_conn_pool_size(::google::protobuf::int64 value) {
+  set_has_db_conn_pool_size();
+  db_conn_pool_size_ = value;
+  // @@protoc_insertion_point(field_set:parkspace_proto.database_config.db_conn_pool_size)
+}
+
+#ifdef __GNUC__
+  #pragma GCC diagnostic pop
+#endif  // __GNUC__
+
+// @@protoc_insertion_point(namespace_scope)
+
+}  // namespace parkspace_proto
+
+// @@protoc_insertion_point(global_scope)
+
+#endif  // PROTOBUF_parkspace_5fparameter_2eproto__INCLUDED

+ 12 - 0
parkspace_allocation/parkspace_parameter.proto

@@ -0,0 +1,12 @@
+syntax = "proto2";
+package parkspace_proto;
+
+message database_config
+{
+    required string db_ip=1;
+    required int64 db_port=2;
+    required string db_username=3;
+    optional string db_passwd=4[default=""];
+    required string db_name=5;
+    optional int64 db_conn_pool_size=6;
+}

+ 1 - 0
proto.sh

@@ -3,3 +3,4 @@ protoc -I=./message measure_message.proto --cpp_out=./message
 protoc -I=./message hardware_message.proto --cpp_out=./message
 protoc -I=./message parkspace_allocation_message.proto --cpp_out=./message
 #protoc -I=./ setting.proto --cpp_out=./
+protoc -I=./parkspace_allocation parkspace_parameter.proto --cpp_out=./parkspace_allocation

+ 7 - 4
test/db_test.cpp

@@ -2,7 +2,7 @@
  * @Description: 数据库测试
  * @Author: yct
  * @Date: 2020-07-18 21:46:45
- * @LastEditTime: 2020-07-18 23:57:19
+ * @LastEditTime: 2020-07-20 14:56:48
  * @LastEditors: yct
  */ 
 
@@ -13,7 +13,7 @@ int main()
 {
     Database_controller *db = Database_controller::get_instance_pointer();
     db->database_controller_init("127.0.0.1", 3306, "yct", "123456", "test");
-    usleep(1000*1000);
+    // usleep(1000*1000);
     if(db->is_connected())
     {
         // 增加
@@ -23,12 +23,15 @@ int main()
         // 查询
         boost::shared_ptr<sql::ResultSet> query_result = nullptr;
         // cout<<"---"<<endl;
-        ec = db->sql_query("SELECT id,content FROM my_test where id < 5", query_result);
+        ec = db->sql_query("SELECT * FROM my_test where id < 5", query_result);
         cout<<"search: "<< ec.to_string() <<endl;
         while(query_result!=nullptr && query_result->next())
         {
             cout << query_result->getInt("id") << endl;
-            cout << query_result->getString("content") << endl;
+            if(query_result->getString("content") != ""){
+                cout << query_result->getInt("numm") << endl;
+                cout << query_result->getString("content") << endl;
+            }
         }
         // 删除
         ec = db->sql_delete("DELETE FROM my_test WHERE id=2");

+ 9 - 2
test/test_parkspace_sample.cpp

@@ -2,7 +2,7 @@
  * @Description: 测试车位分配模块通信情况
  * @Author: yct
  * @Date: 2020-07-08 15:51:46
- * @LastEditTime: 2020-07-10 17:14:16
+ * @LastEditTime: 2020-07-21 18:16:10
  * @LastEditors: yct
  */ 
 #include "../parkspace_allocation/parkspace_allocation_communicator.h"
@@ -18,7 +18,14 @@ int main()
     Parkspace_allocation_communicator *p_parkspace_allocation_communicater = Parkspace_allocation_communicator::get_instance_pointer();
     Parkspace_allocator *p_parkspace_allocator = Parkspace_allocator::get_instance_pointer();
 
-    p_parkspace_allocator->parkspace_allocator_init(4);
+    parkspace_proto::database_config config;
+    config.set_db_ip("127.0.0.1");
+    config.set_db_port(3306);
+    config.set_db_username("yct");
+    config.set_db_passwd("123456");
+    config.set_db_name("test");
+    config.set_db_conn_pool_size(5);
+    p_parkspace_allocator->parkspace_allocator_init(4, config);
     p_parkspace_allocation_communicater->communication_bind("tcp://192.168.2.125:7001");
     // p_parkspace_allocation_communicater->communication_connect("tcp://127.0.0.1:7000");
     p_parkspace_allocation_communicater->communication_run();