当前位置:网站首页>Adapter mode
Adapter mode
2022-06-11 00:50:00 【jim0506】
The hardware adapter pattern provides a way , Make the existing hardware interface suitable for application expectation . It can be said that it is based on the hardware proxy mode , In order to be able to adapt to the underlying different hardware devices , Add a layer of adapter in the middle . For example, communication exists in hardware RS232,RS485, Programs need to be used in different situations 232 Communication or 485 Communications , The adapter can provide a unified interface to the client layer , Point to the desired communication through a pointer , Then you can achieve . The most important feature is the selection of , You need to generate a different executable than using a macro definition , Can be implemented in the program adaptive function .
1.2.1 Pattern structure

1.2.2 role
1.2.2.1 Hardware adapter (HardwareAdapter)
Hardware matching is performed between the client and the hardware agent . The customer said the hardware required for the adapter , The adapter performs the client's request .
1.2.2.2 Customer hardware interface (HardwareInterfaceToClient)
The customer's hardware interface represents a set of services and parameter lists that the customer expects the hardware agent to provide . Just as an interface , It didn't happen , The hardware implementation is provided through the adapter .
1.2.2.3 Hardware device (HardwareDevice)
It is consistent with the description in hardware proxy mode .
1.2.2.4 Hardware agent (HardwareProxy)
It is consistent with the description in hardware proxy mode .
1.2.3 effect
This mode allows the use of various hardware agents , And use the hardware devices associated with them in different applications , At the same time, some applications do not need to change when using different hardware devices . My personal understanding is somewhat similar to the concept of polymorphism in object-oriented languages .
1.2.4 Realization
The same as linux System driven , Create an interface proxy for the structure , The hardware device uses these interfaces to realize , Then use a pointer to the struct interface , Register the hardware device you need to use with the pointer , The client code just calls this pointer , You can operate specific hardware devices , And can dynamically modify the pointer to , So as to achieve dynamic load switching .
边栏推荐
- 市值215亿,这个四川80后会让电视机成为历史?
- twelve billion three hundred and twenty-four million two hundred and forty-three thousand two hundred and forty-two
- Automated test series
- How to ensure the sequence of messages, that messages are not lost or consumed repeatedly
- 452. detonate the balloon with the minimum number of arrows
- Canvas drawing line break
- Installation of phpstudy
- AQS explanation of concurrent programming
- 为什么使用 Golang 进行 Web 开发
- 自动化测试系列
猜你喜欢
![[network planning] 1.3 packet switching and circuit switching in the network core](/img/a8/74a1b44ce4d8b0b1a85043a091a91d.jpg)
[network planning] 1.3 packet switching and circuit switching in the network core

unity 网格面片生成抛物线,折线

String time sorting, sorting time format strings

亿级搜索系统(优酷视频搜索)的基石,如何保障实时数据质量?v2020

市值215亿,这个四川80后会让电视机成为历史?

Using solrj to add, delete, modify, and query Solr is too simple

MP framework basic operation (self use)

SLAM卡尔曼滤波&&非线性优化

Kubernetes入门介绍与基础搭建

海贼oj#146.字符串
随机推荐
LeetCode 1996. 游戏中弱角色的数量*
Wechat applet to realize OCR scanning recognition
Rich text activity test 1
[untitled]
文件缓存和session怎么处理?
Dynamic programming classical topic triangle shortest path
Block queue - delayedworkqueue Source Analysis
市值215亿,这个四川80后会让电视机成为历史?
网络工程师必修课防火墙安全区域及安全策略基础操作
The mystery of number idempotent and perfect square
非重叠矩形中的随机点
Unable to return to the default page after page Jump
图的最短路径问题 详细分解版
Review of software architecture in Harbin Institute of technology -- LSP principle, covariance and inversion
负载均衡策略图文详解
Word删除页眉横线的方法
圖的最短路徑問題 詳細分解版
阻塞隊列 — DelayedWorkQueue源碼分析
Fastdfs quick start
Kubernetes入门介绍与基础搭建