2018-07-22 14:50:54 +08:00
|
|
|
//
|
|
|
|
// Created by xiemenghui on 2018/7/20.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef DESIGNPATTERN_ADAPTER_H
|
|
|
|
#define DESIGNPATTERN_ADAPTER_H
|
|
|
|
|
|
|
|
#include "target.h"
|
|
|
|
#include "adaptee.h"
|
|
|
|
|
|
|
|
#ifndef SAFE_DELETE
|
|
|
|
#define SAFE_DELETE(p) { if(p){delete(p); (p)=NULL;} }
|
|
|
|
#endif
|
|
|
|
|
2020-12-16 16:07:24 +08:00
|
|
|
// Power Adapter
|
2018-07-22 14:50:54 +08:00
|
|
|
class PowerAdapter : public IRussiaSocket
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
PowerAdapter() : m_pCharger(new OwnCharger()){}
|
|
|
|
~PowerAdapter()
|
|
|
|
{
|
|
|
|
SAFE_DELETE(m_pCharger);
|
|
|
|
}
|
|
|
|
void Charge()
|
|
|
|
{
|
2020-12-16 16:07:24 +08:00
|
|
|
// Use the built-in charger (two-pin flat) to charge
|
2018-07-22 14:50:54 +08:00
|
|
|
m_pCharger->ChargeWithFeetFlat();
|
|
|
|
}
|
|
|
|
private:
|
2020-12-16 16:07:24 +08:00
|
|
|
// Hold the interface object that needs to be adapted (the built-in charger)
|
2018-07-22 14:50:54 +08:00
|
|
|
OwnCharger* m_pCharger;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif //DESIGNPATTERN_ADAPTER_H
|