- 
                Notifications
    
You must be signed in to change notification settings  - Fork 92
 
Advanced multiplexing #167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Open
      
      
            Ext3h
  wants to merge
  6
  commits into
  xR3b0rn:master
  
    
      
        
          
  
    
      Choose a base branch
      
     
    
      
        
      
      
        
          
          
        
        
          
            
              
              
              
  
           
        
        
          
            
              
              
           
        
       
     
  
        
          
            
          
            
          
        
       
    
      
from
Ext3h:advanced_multiplexing
  
      
      
   
  
    
  
  
  
 
  
      
    base: master
Could not load branches
            
              
  
    Branch not found: {{ refName }}
  
            
                
      Loading
              
            Could not load tags
            
            
              Nothing to show
            
              
  
            
                
      Loading
              
            Are you sure you want to change the base?
            Some commits from the old base branch may be removed from the timeline,
            and old review comments may become outdated.
          
          
  
     Open
                    Changes from 3 commits
      Commits
    
    
            Show all changes
          
          
            6 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      a54c321
              
                Make Iterable interface compatible with Container/LegacyIterator requ…
              
              
                 d6b632f
              
                Extend ISignal::EMultiplexer, validation for advanced multiplexing, d…
              
              
                 038333c
              
                Correct includes for Iterator header
              
              
                 73741f7
              
                Fixup meaning of having multiple SignalMultiplexerValues
              
              
                 c30e675
              
                Complete Iterator interface
              
              
                 a45701b
              
                Fix unsigned type in iterator interface breaking reverse iteraors
              
              
                 File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,102 +1,117 @@ | ||
| 
     | 
||
| #pragma once | ||
| 
     | 
||
| #include <functional> | ||
| #include <iterator> | ||
| 
     | 
||
| namespace dbcppp | ||
| { | ||
| template <class T> | ||
| class Iterator | ||
| template <class T, class P, typename F> | ||
| class Iterator final | ||
| { | ||
| public: | ||
| using self_t = Iterator<T>; | ||
| using self_t = Iterator<T, P, F>; | ||
| using iterator_category = std::random_access_iterator_tag; | ||
| using difference_type = std::ptrdiff_t; | ||
| using value_type = T; | ||
| using pointer = const value_type*; | ||
| using reference = const value_type&; | ||
| using get_t = std::function<reference (std::size_t)>; | ||
| using pointer = value_type*; | ||
| using reference = value_type&; | ||
| 
     | 
||
| Iterator(get_t get, std::size_t i) | ||
| : _get(get) | ||
| constexpr Iterator(P parent, F get, std::size_t i) noexcept | ||
| : _parent(parent) | ||
| , _get(std::move(get)) | ||
| , _i(i) | ||
| {} | ||
| reference operator*() const | ||
| inline reference operator*() const | ||
| { | ||
| return _get(_i); | ||
| return (_parent->*_get)(_i); | ||
| } | ||
| pointer operator->() const | ||
| inline pointer operator->() const | ||
| { | ||
| return &_get(_i); | ||
| return &(_parent->*_get)(_i); | ||
| } | ||
| self_t& operator++() | ||
| constexpr self_t& operator++() noexcept | ||
| { | ||
| _i++; | ||
| return *this; | ||
| } | ||
| self_t operator+(std::size_t o) | ||
| constexpr self_t operator+(std::size_t o) const noexcept | ||
| { | ||
| return {_get, _i + o}; | ||
| return {_parent, _get, _i + o}; | ||
| } | ||
| self_t operator-(std::size_t o) | ||
| constexpr self_t operator-(std::size_t o) const noexcept | ||
| { | ||
| return {_get, _i + o}; | ||
| return {_parent, _get, _i - o}; | ||
| } | ||
| difference_type operator-(const self_t& rhs) | ||
| constexpr difference_type operator-(const self_t& rhs) const noexcept | ||
| { | ||
| return _i - rhs._i; | ||
| } | ||
| self_t& operator+=(std::size_t o) | ||
| constexpr self_t& operator+=(std::size_t o) noexcept | ||
| { | ||
| _i += o; | ||
| return *this; | ||
| } | ||
| self_t& operator-=(std::size_t o) | ||
| constexpr self_t& operator-=(std::size_t o) noexcept | ||
| { | ||
| _i -= o; | ||
| return *this; | ||
| } | ||
| 
     | 
||
| bool operator==(const self_t& rhs) const | ||
| constexpr bool operator==(const self_t& rhs) const noexcept | ||
| { | ||
| return _i == rhs._i; | ||
| } | ||
| bool operator!=(const self_t& rhs) const | ||
| constexpr bool operator!=(const self_t& rhs) const noexcept | ||
| { | ||
| return !(*this == rhs); | ||
| } | ||
| 
     | 
||
| private: | ||
| get_t _get; | ||
| P _parent; | ||
| F _get; | ||
| std::size_t _i; | ||
| }; | ||
| template <class Iterator> | ||
| class Iterable | ||
| template<class T, class P, typename F> | ||
| class Iterable final | ||
| { | ||
| public: | ||
| Iterable(Iterator begin, Iterator end) | ||
| : _begin(begin) | ||
| , _end(end) | ||
| using value_type = const T; | ||
| using reference = value_type&; | ||
| using const_reference = const value_type&; | ||
| using iterator = Iterator<T, P, F>; | ||
| using const_iterator = Iterator<const T, P, F>; | ||
| using difference_type = std::ptrdiff_t; | ||
| using size_type = std::size_t; | ||
| 
     | 
||
| constexpr Iterable(P parent, F get, size_t size) noexcept | ||
| : _parent(std::move(parent)) | ||
| , _get(std::move(get)) | ||
| , _size(std::move(size)) | ||
| {} | ||
| Iterator& begin() | ||
| constexpr iterator begin() noexcept | ||
| { | ||
| return iterator(_parent, _get, 0); | ||
| } | ||
| constexpr iterator end() noexcept | ||
| { | ||
| return iterator(_parent, _get, _size); | ||
| } | ||
| constexpr const_iterator begin() const noexcept | ||
| { | ||
| return _begin; | ||
| return const_iterator(_parent, _get, 0); | ||
| } | ||
| Iterator& end() | ||
| constexpr const_iterator end() const noexcept | ||
| { | ||
| return _end; | ||
| return const_iterator(_parent, _get, _size); | ||
| } | ||
| 
     | 
||
| private: | ||
| Iterator _begin; | ||
| Iterator _end; | ||
| P _parent; | ||
| F _get; | ||
| size_t _size; | ||
| }; | ||
| } | ||
| #define DBCPPP_MAKE_ITERABLE(ClassName, Name, Type) \ | ||
| auto Name() const \ | ||
| { \ | ||
| auto get = std::bind(&ClassName::Name##_Get, this, std::placeholders::_1); \ | ||
| Iterator<Type> begin(get, 0); \ | ||
| Iterator<Type> end(get, Name##_Size()); \ | ||
| return Iterable(begin, end); \ | ||
| #define DBCPPP_MAKE_ITERABLE(ClassName, Name, Type) \ | ||
| inline Iterable<const Type, const ClassName*, decltype(&ClassName::Name##_Get)> Name() const noexcept \ | ||
                
      
                  Ext3h marked this conversation as resolved.
               
          
            Show resolved
            Hide resolved
         | 
||
| { \ | ||
| return {this, &ClassName::Name##_Get, Name##_Size()}; \ | ||
| } | ||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.