summaryrefslogblamecommitdiffstats
path: root/src/Block.cpp
blob: 85870f64d1ba7022d61e8dfab1215383c306a0e7 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11

                    
              
                 


                     



                                                 

                                                                    
                                                                      

                                                 

 
                                          

                                                


                                                  
 
#include "Block.hpp"

#include <map>
#include <vector>

#include "Plugin.hpp"

static std::vector<BlockInfo> blocks;
static std::map<BlockId, size_t> staticBlockInfo;

BlockInfo WTFBlock{ true, "", "" };

void RegisterStaticBlockInfo(BlockId blockId, BlockInfo blockInfo) {
	//NOTE: It can be made thread-safe by using atomic incrementer
	staticBlockInfo[blockId] = blocks.size();
	blocks.push_back(blockInfo);
}

BlockInfo* GetBlockInfo(BlockId blockId) {
	auto it = staticBlockInfo.find(blockId);
	if (it != staticBlockInfo.end())
		return &blocks.data()[it->second];
	else
		return &WTFBlock;
}