hch
2025-06-19 35f08360f1e07c7a8301f7b2031c0779e2998fb5
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
using System.Collections.Generic;
 
public class TBlackBoard {
 
    class TBlackboardItem {
 
        private object m_Value;
 
        public void SetValue(object v) {
            m_Value = v;
        }
 
        public T GetValue<T>() {
            return (T)m_Value;
        }
    }
 
    private Dictionary<string, TBlackboardItem> m_ItemDict;
 
    public TBlackBoard() {
        m_ItemDict = new Dictionary<string, TBlackboardItem>();
    }
 
    ~TBlackBoard() {
        m_ItemDict.Clear();
        m_ItemDict = null;
    }
 
    public void SetValue(string key, object v) {
        TBlackboardItem item;
        if (m_ItemDict.ContainsKey(key) == false) {
            item = new TBlackboardItem();
            m_ItemDict.Add(key, item);
        }
        else {
            item = m_ItemDict[key];
        }
        item.SetValue(v);
    }
 
    public T GetValue<T>(string key, T defaultValue) {
        if (m_ItemDict.ContainsKey(key) == false) {
            return defaultValue;
        }
        return m_ItemDict[key].GetValue<T>();
    }
}