Program Listing for File stcamera_node_impl.hpp

Return to documentation for file (/tmp/ws/src/stcamera_ros2/stcamera_components/include/impl/stcamera_node_impl.hpp)

/******************************************************************************
 * Software License Agreement (BSD License)
 *
 * Copyright (C) 2023, OMRON SENTECH. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *   * Redistributions of source code must retain the above copyright notice,
 *   this list of conditions and the following disclaimer.
 *   * Redistributions in binary form must reproduce the above copyright
 *   notice, this list of conditions and the following disclaimer in the
 *   documentation and/or other materials provided with the distribution.
 *   * Neither the names of OMRON SENTECH nor the names of its
 *   contributors may be used to endorse or promote products derived from
 *   this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 *****************************************************************************/

#ifndef STCAMERA_STCAMERA_NODE_IMPL_H
#define STCAMERA_STCAMERA_NODE_IMPL_H

#include "../stcamera_node.hpp"
#include <StApi_TL.h>

namespace stcamera
{
  class StCameraNodeImpl
  {
    public:
        explicit StCameraNodeImpl(StCameraNode *p_stcamera_node);
        ~StCameraNodeImpl();

      void DetectingAndOpenningDevices();

      bool initializeCamera(StApi::IStInterface *p_iface,
                            const StApi::IStDeviceInfo *p_devinfo);

      bool getDeviceListCallback(
          const std::shared_ptr<stcamera_msgs::srv::GetDeviceList_Request> req,
          std::shared_ptr<stcamera_msgs::srv::GetDeviceList_Response> res);

      bool getSDKInfoCallback(
          const std::shared_ptr<stcamera_msgs::srv::GetSDKInfo_Request> req,
          std::shared_ptr<stcamera_msgs::srv::GetSDKInfo_Response> res);

      bool getModuleListCallback(
          const std::shared_ptr<stcamera_msgs::srv::GetModuleList_Request> req,
          std::shared_ptr<stcamera_msgs::srv::GetModuleList_Response> res);

      void initSystemsAndInterfaces();
    protected:
      const std::string &getTextForMsg() const {return(stcamera_node_text_);}
      rclcpp::Logger get_logger()
      {
        return(p_stcamera_node_->get_logger());
      }
    protected:
      rclcpp::Clock clock_;

      MapCameraInterface map_camera_;

      MapDeviceConnection map_connection_;

      StApi::CStApiAutoInit stapi_autoinit_;

      StApi::CIStSystemPtrArray stapi_systems_;

      StCameraNode *p_stcamera_node_;

      const std::string stcamera_node_text_;

    private:

      std::mutex mtx_update_device_list_;

      std::mutex mtx_map_camera_;

  };
}
#endif //STCAMERA_STCAMERA_NODE_IMPL_H