xingzilong
2017-08-18 9e5babf9db52e64bdae60137be7696e56241fca6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#include "PL_Fork1.h"
#include "MaterialBuffer.h"
#include "logger.h"
 
struct PL_Fork1_Internal
{
    //uint8_t buffer[1920*1080*4];
    //size_t buffSize;
    //size_t buffSizeMax;
 
    PipeMaterial lastPm;
    
    MB_Frame lastFrame;
    
    PL_Fork1_Config config;
 
    bool payError;
 
    PL_Fork1_Internal() : 
        //buffSize(0), buffSizeMax(sizeof(buffer)), 
        lastPm(), lastFrame(), config(), payError(true)
    {
    }
    
    ~PL_Fork1_Internal()
    {
    }
    
    void reset()
    {
        //buffSize = 0;
        payError = true;
        
        PipeMaterial _lastPm;
        lastPm = _lastPm;
        
        MB_Frame _lastFrame;
        lastFrame = _lastFrame;
        
        PL_Fork1_Config _config;
        config = _config;
    }
};
 
PipeLineElem* create_PL_Fork1()
{
    return new PL_Fork1;
}
 
PL_Fork1::PL_Fork1() : internal(new PL_Fork1_Internal), pl(nullptr)
{
}
 
PL_Fork1::~PL_Fork1()
{
    delete (PL_Fork1_Internal*)internal;
    internal= nullptr;
}
 
bool PL_Fork1::init(void* args)
{
    PL_Fork1_Internal* in = (PL_Fork1_Internal*)internal;
    in->reset();
 
    if (args == nullptr)
    {
        LOG_ERROR << "Config should give" << std::endl;
        return false;
    }
 
    PL_Fork1_Config* config = (PL_Fork1_Config*)args;
    in->config = *config;
 
    return true;
}
 
void PL_Fork1::finit()
{
    PL_Fork1_Internal* in = (PL_Fork1_Internal*)internal;
 
}
 
bool PL_Fork1::pay(const PipeMaterial& pm)
{
    PL_Fork1_Internal* in = (PL_Fork1_Internal*)internal;
    PL_Fork1_Config& config(in->config);
 
    in->lastPm = pm;
    
    return false;
}
 
bool PL_Fork1::gain(PipeMaterial& pm)
{
    PL_Fork1_Internal* in = (PL_Fork1_Internal*)internal;
    
    return false;
}
 
void PL_Fork1::attach_pipe_line(PipeLine* pl)
{
    PL_Fork1_Internal* in = (PL_Fork1_Internal*)internal;
    
    if (this->pl != nullptr)
    {
        LOG_ERROR << "Has areadly attached pipe line" << std::endl;
        return;
    }
    
    if (pl == nullptr)
    {
        LOG_NOTICE << "Detach pipe line" << std::endl;
        this->pl->remove_elem(this);
        this->pl = nullptr;
        return;
    }
    
    this->pl = pl;
    PipeLine* mainPipeLineManager = this->manager;
    pl->push_front_elem(this);
    this->manager = mainPipeLineManager;
}