设为首页 加入收藏

TOP

6.3.1 代码结构(1)
2013-10-07 16:03:07 来源: 作者: 【 】 浏览:66
Tags:6.3.1 代码 结构

6.3.1 代码结构(1)

muduo 的头文件明确分为客户可见和客户不可见两类。以下是安装之后暴露的头文件和库文件。对于使用muduo 库而言,只需要掌握5 个关键类:Buffer、EventLoop、TcpConnection、TcpClient、TcpServer。

  1. EventLoop、TcpConnection、TcpClient、TcpServer。  
  2. |-- include 头文件  
  3. | \-- muduo  
  4. | |-- base 基础库,同前,略  
  5. | \-- net 网络核心库  
  6. | |-- Buffer.h  
  7. | |-- Callbacks.h  
  8. | |-- Channel.h  
  9. | |-- Endian.h  
  10. | |-- EventLoop.h  
  11. | |-- EventLoopThread.h  
  12. | |-- InetAddress.h  
  13. | |-- TcpClient.h  
  14. | |-- TcpConnection.h  
  15. | |-- TcpServer.h  
  16. | |-- TimerId.h  
  17. | |-- http 以下为网络附属库的头文件  
  18. | | |-- HttpRequest.h  
  19. | | |-- HttpResponse.h  
  20. | | \-- HttpServer.h  
  21. | |-- inspect  
  22. | | |-- Inspector.h  
  23. | | \-- ProcessInspector.h  
  24. | \-- protorpc  
  25. | |-- RpcChannel.h  
  26. | |-- RpcCodec.h  
  27. | \-- RpcServer.h  
  28. \-- lib 静态库文件  
  29. |-- libmuduo_base.a, libmuduo_net.a  
  30. |-- libmuduo_http.a, libmuduo_inspect.a  
  31. \-- libmuduo_protorpc.a 

图6-1 是muduo 的网络核心库的头文件包含关系,用户可见的为白底,用户不可见的为灰底。

 
(点击查看大图)图6-1

muduo 头文件中使用了前向声明(forward declaration),大大简化了头文件之间的依赖关系。例如Acceptor.h、Channel.h、Connector.h、TcpConnection.h 都前向声明了EventLoop class,从而避免包含EventLoop.h。另外,TcpClient.h 前向声明了Connectorclass,从而避免将内部类暴露给用户,类似的做法还有TcpServer.h 用到的Acceptor 和EventLoopThreadPool、EventLoop.h 用到的Poller 和TimerQueue、TcpConnection.h 用到的Channel 和Socket 等等。

这里简单介绍各个class 的作用,详细的介绍参见后文。

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇1.14 Observer 之谬 下一篇6.3.1 代码结构(2)

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·MySQL 安装及连接-腾 (2025-12-25 06:20:28)
·MySQL的下载、安装、 (2025-12-25 06:20:26)
·MySQL 中文网:探索 (2025-12-25 06:20:23)
·Shell脚本:Linux Sh (2025-12-25 05:50:11)
·VMware虚拟机安装Lin (2025-12-25 05:50:08)