/*** @brief 枚举转字符串* @tparam T 枚举类型* @param s 枚举类型变量* @return 字符串*/template<typenameT>inline QString EnumToString(T s){// T是枚举类型,编译判断static_assert(std::is_enum<T>::value,"T must be an enum type");QMetaEnum meta = QMetaEnum::fromType<T>();return meta.valueToKey(int(s));}#ifndefE2S#defineE2S(x) Utils::EnumToString<decltype(x)>(x)#endif// !E2S/*** @brief 字符串转枚举* @tparam T 枚举类型* @param s 字符串* @return 枚举类型变量*/template<typenameT>inline T StringToEnum(const QString& s){// T是枚举类型,编译判断static_assert(std::is_enum<T>::value,"T must be an enum type");QMetaEnum meta = QMetaEnum::fromType<T>();returnT(meta.keyToValue(s.toStdString().c_str()));}#ifndefS2E#defineS2E(T, x) Utils::StringToEnum<T>(x)#endif// !S2E
组件的实现
1. 序
1.1. 总述 muduo库是基于多Reactor-多线程模型实现的TCP网络编程库,性能良好。如libev作者:“One loop per thread is usually a good model”,muduo库的作者陈硕在其《Linux多线程服务端编程》中也力荐这种“One loop pe…