wangrong
2025-03-19 291afb9c81aae1d15d9e3edcea618d0a2e1fc5a6
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
#pragma once
 
#include <memory>
#include <vector>
#include <mutex>
#include <iostream>
 
#include "vp_meta_subscriber.h"
 
namespace vp_nodes {
    class vp_meta_publisher {
    private:
    protected:
        // push meta to next nodes
        virtual void push_meta(std::shared_ptr<vp_objects::vp_meta> meta);
 
        // non-copyable for all child class
        std::mutex subscribers_lock;
        // next nodes as subscribers
        std::vector<std::shared_ptr<vp_meta_subscriber>> subscribers;
    public:
        vp_meta_publisher(/* args */);
        ~vp_meta_publisher();
 
        // add next node
        void add_subscriber(std::shared_ptr<vp_meta_subscriber> subscriber);
        // remove next node
        void remove_subscriber(std::shared_ptr<vp_meta_subscriber> subscriber);
    };
 
}