chenlh
2025-09-18 ab07ada908b82340e7acd899e85a9802cf8a9057
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
/*
 * ctrl.h
 *
 *  Created on: 2025Äê7ÔÂ23ÈÕ
 *      Author: 86189
 */
 
#ifndef PARAM_CTRL_H_
#define PARAM_CTRL_H_
 
#include <map>
#include "IModule.h"
 
//Ô¤Éè²ÎÊý½âÎöÓÃ
typedef u32 (*ParamCtrl_fn)(IModule* m, void* handle, int &plen);
//²ÎÊý¿ØÖÆÓÃ
typedef u32 (*Ctrl_fn)(IModule* m, u32 pID, s16* val_c, u32 num);
 
class ParamEntry {
private:
    //u16 module_type;
    ParamCtrl_fn param;
    Ctrl_fn ctrl;
 
public:
    ParamCtrl_fn GetParamEntry() const {
        return param;
    }
 
    Ctrl_fn GetCtrlEntry() const {
        return ctrl;
    }
    ParamEntry() : param(nullptr), ctrl(nullptr) {}
    ParamEntry(ParamCtrl_fn fparam, Ctrl_fn fctrl){
        //module_type = type;
        param = fparam;
        ctrl = fctrl;
    }
};
 
class param_ctrl_t{
protected:
    std::map<u32, ParamEntry> mctrl_list;
 
public:
    // ·µ»Øpair±ÜÃâÖØ¸´²éÕÒ
    std::pair<ParamCtrl_fn, Ctrl_fn> GetEntries(u32 mtype) const
    {
        auto it = mctrl_list.find(mtype);
        if(it != mctrl_list.end()) {
            return {it->second.GetParamEntry(), it->second.GetCtrlEntry()};
        }
        return {nullptr, nullptr};
    }
 
    ParamCtrl_fn GetParamEntry(u32 mtype) const
    {
        auto it = mctrl_list.find(mtype);
        return (it != mctrl_list.end()) ? it->second.GetParamEntry() : nullptr;
    }
 
    Ctrl_fn GetCtrlEntry(u32 mtype) const
    {
        auto it = mctrl_list.find(mtype);
        return (it != mctrl_list.end()) ? it->second.GetCtrlEntry() : nullptr;
    }
 
    // ¼ì²éÊÇ·ñ´æÔÚ
    bool HasEntry(u32 mtype) const
    {
        return mctrl_list.find(mtype) != mctrl_list.end();
    }
};
/*class param_ctrl_t{
protected:
    std::map<u32, ParamEntry> mctrl_list;
public:
    ParamCtrl_fn GetParamEntry(u32 mtype)
    {
        if(mctrl_list.count(mtype))
            return mctrl_list[mtype].GetParamEntry();
        else
            return NULL;
    }
 
    Ctrl_fn GetCtrlEntry(u32 mtype)
    {
        if(mctrl_list.count(mtype))
            return mctrl_list[mtype].GetCtrlEntry();
        else
            return NULL;
    }
};*/
 
 
 
#endif /* PARAM_CTRL_H_ */