Program Listing for File ecal_util.h

Return to documentation for file (ecal/core/include/ecal/ecal_util.h)

/* ========================= eCAL LICENSE =================================
 *
 * Copyright (C) 2016 - 2019 Continental Corporation
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * ========================= eCAL LICENSE =================================
*/

#pragma once

#include <ecal/ecal_os.h>
#include <string>

#ifndef ECAL_C_DLL

namespace eCAL
{
  namespace Util
  {
    ECAL_API std::string GeteCALHomePath();

    ECAL_API std::string GeteCALConfigPath();

    ECAL_API std::string GeteCALUserSettingsPath();

    ECAL_API std::string GeteCALLogPath();

    ECAL_API std::string GeteCALDefaultIniFile();

    ECAL_API void ShutdownProcess(const std::string& unit_name_);

    ECAL_API void ShutdownProcess(int process_id_);

    ECAL_API void ShutdownProcesses();

    ECAL_API void ShutdownCore();

    ECAL_API void EnableLoopback(bool state_);

    ECAL_API void PubShareType(bool state_);

    ECAL_API void PubShareDescription(bool state_);

    ECAL_API bool GetTypeName(const std::string& topic_name_, std::string& topic_type_);

    ECAL_API std::string GetTypeName(const std::string& topic_name_);

    ECAL_API bool GetDescription(const std::string& topic_name_, std::string& topic_desc_);

    ECAL_API std::string GetDescription(const std::string& topic_name_);
  }
}

#else /* ! ECAL_C_DLL */

#include <ecal/ecalc.h>

namespace eCAL
{
  namespace Util
  {
    inline void ShutdownProcess(const std::string& unit_name_)
    {
      eCAL_Util_ShutdownUnitName(unit_name_.c_str());
    }

    inline void ShutdownProcess(int process_id_)
    {
      eCAL_Util_ShutdownProcessID(process_id_);
    }

    inline void ShutdownProcesses()
    {
      eCAL_Util_ShutdownProcesses();
    }

    inline void ShutdownCore()
    {
      eCAL_Util_ShutdownCore();
    }

    inline void EnableLoopback(bool state_)
    {
      eCAL_Util_EnableLoopback(state_);
    }

    inline bool GetTypeName(const std::string& topic_name_, std::string& topic_type_)
    {
      void* buf = nullptr;
      std::string type;
      size_t buf_len = eCAL_Util_GetTypeName(topic_name_.c_str(), &buf, ECAL_ALLOCATE_4ME);
      if(buf_len > 0)
      {
        type = std::string(static_cast<char*>(buf), buf_len);
        eCAL_FreeMem(buf);
      }
      topic_type_ = type;
      return(!type.empty());
    }

    inline std::string GetTypeName(const std::string& topic_name_)
    {
      std::string topic_type;
      GetTypeName(topic_name_, topic_type);
      return(topic_type);
    }

    inline bool GetDescription(const std::string& topic_name_, std::string& topic_desc_)
    {
      void* buf = nullptr;
      std::string desc;
      size_t buf_len = eCAL_Util_GetDescription(topic_name_.c_str(), &buf, ECAL_ALLOCATE_4ME);
      if(buf_len > 0)
      {
        desc = std::string(static_cast<char*>(buf), buf_len);
        eCAL_FreeMem(buf);
      }
      topic_desc_ = desc;
      return(!desc.empty());
    }

    inline std::string GetDescription(const std::string& topic_name_)
    {
      std::string topic_desc;
      GetDescription(topic_name_, topic_desc);
      return(topic_desc);
    }
  }
}

#endif /* ! ECAL_C_DLL */