/*----------------------------------------------------------------------------*/ /* Copyright (c) 2017 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ /*----------------------------------------------------------------------------*/ #pragma once #ifndef __FRC_ROBORIO__ #include #include "MockData/NotifyListenerVector.h" template std::shared_ptr RegisterCallbackImpl( std::shared_ptr currentVector, const char* name, CallbackType callback, void* param, int32_t* newUid) { std::shared_ptr newCallbacks; if (currentVector == nullptr) { newCallbacks = std::make_shared( param, callback, reinterpret_cast(newUid)); } else { newCallbacks = currentVector->emplace_back( param, callback, reinterpret_cast(newUid)); } return newCallbacks; } template std::shared_ptr CancelCallbackImpl( std::shared_ptr currentVector, int32_t uid) { // Create a copy of the callbacks to erase from auto newCallbacks = currentVector->erase(uid); return newCallbacks; } std::shared_ptr RegisterCallback( std::shared_ptr currentVector, const char* name, HAL_NotifyCallback callback, void* param, int32_t* newUid); std::shared_ptr CancelCallback( std::shared_ptr currentVector, int32_t uid); void InvokeCallback(std::shared_ptr currentVector, const char* name, const HAL_Value* value); std::shared_ptr RegisterCallback( std::shared_ptr currentVector, const char* name, HAL_BufferCallback callback, void* param, int32_t* newUid); std::shared_ptr CancelCallback( std::shared_ptr currentVector, int32_t uid); void InvokeCallback(std::shared_ptr currentVector, const char* name, uint8_t* buffer, int32_t count); std::shared_ptr RegisterCallback( std::shared_ptr currentVector, const char* name, HAL_ConstBufferCallback callback, void* param, int32_t* newUid); std::shared_ptr CancelCallback( std::shared_ptr currentVector, int32_t uid); void InvokeCallback( std::shared_ptr currentVector, const char* name, const uint8_t* buffer, int32_t count); #endif