parameterlinks.h (1898B)
1 #pragma once 2 3 #include <map> 4 #include <memory> 5 6 #include "parameterlink.h" 7 #include "types.h" 8 9 namespace pluginLib 10 { 11 class ParameterRegion; 12 class Controller; 13 class Parameter; 14 15 class ParameterLinks 16 { 17 public: 18 ParameterLinks(Controller& _controller); 19 20 bool add(Parameter* _source, Parameter* _dest, bool _applyCurrentSourceToTarget); 21 bool remove(const Parameter* _source, Parameter* _dest); 22 23 ParameterLinkType getRegionLinkType(const std::string& _regionId, uint8_t _part) const; 24 25 bool linkRegion(const std::string& _regionId, uint8_t _partSource, uint8_t _partDest, bool _applyCurrentSourceToTarget); 26 bool unlinkRegion(const std::string& _regionId, uint8_t _partSource, uint8_t _partDest); 27 bool isRegionLinked(const std::string& _regionId, uint8_t _partSource, uint8_t _partDest) const; 28 29 void saveChunkData(baseLib::BinaryStream& s) const; 30 void loadChunkData(baseLib::ChunkReader& _cr); 31 32 private: 33 struct RegionLink 34 { 35 std::string regionId; 36 uint8_t sourcePart = 0; 37 uint8_t destPart = 0; 38 39 bool operator == (const RegionLink& _link) const 40 { 41 return sourcePart == _link.sourcePart && destPart == _link.destPart && regionId == _link.regionId; 42 } 43 44 bool operator < (const RegionLink& _link) const 45 { 46 if(sourcePart < _link.sourcePart) return true; 47 if(sourcePart > _link.sourcePart) return false; 48 if(destPart < _link.destPart) return true; 49 if(destPart > _link.destPart) return false; 50 if(regionId < _link.regionId) return true; 51 return false; 52 } 53 }; 54 55 bool updateRegionLinks(const ParameterRegion& _region, uint8_t _partSource, uint8_t _partDest, bool _enableLink, bool _applyCurrentSourceToTarget); 56 57 Controller& m_controller; 58 std::map<const Parameter*, std::unique_ptr<ParameterLink>> m_parameterLinks; 59 std::map<const Parameter*, std::set<const Parameter*>> m_destToSource; 60 std::set<RegionLink> m_linkedRegions; 61 }; 62 }