/// ****************************************************************************
/// @file   
/// @author Dr.Neeton
/// @date   2015/03/24 - 2015/03/24
/// 
/// @brief  プロセス用共有フラグ
/// 
/// ****************************************************************************

#include "CPL_Core_SharedFlag.h"

#ifdef CPL_WINDOWS
#include "../../Win/Net/CPL_WIN_WS_SocketTCP.h"
#endif


namespace CPL {
namespace Core {

// _____________________________________________________________________________
/// @brief NetworkSharedFlag実体
///
// *****************************************************************************
class NetworkSharedFlag::Entity
{
  td_tstring m_name;
public:
  Entity
  ( _in<bool      > in_flag = false
  , _in<td_tstring> in_name = SwS("")
  )
  {
  }

  ~Entity()
  {
  }

  /// @brief SharedFlagBase::GetFlag
  bool GetFlag() const
  {
    return false; // まだ未実装
  }

  /// @brief SharedFlagBase::SetFlag
  bool
    SetFlag
      ( _in<bool     > in_flag
      , _in<TimePoint> in_time_out = TimePoint::Max()
      )
  {
    return false; // まだ未実装
  }

  /// @brief SharedFlagBase::GetName
  td_tstring GetName() const
  {
    return m_name;
  }
};


// _____________________________________________________________________________
/// @brief コンストラクタ
/// 
/// @param[in] in_flag : 設定するbool値。
/// @param[in] in_name : プロセス間で共有する共有フラグの識別名。
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
NetworkSharedFlag::NetworkSharedFlag
  ( _in<bool      > in_flag
  , _in<td_tstring> in_name
  ) : m_sp_entity( CPL_MAKE_SHARED( Entity, in_flag, in_name) )
{
}

/// @brief SharedFlagBase::GetFlag
bool NetworkSharedFlag::GetFlag() const
{
  return m_sp_entity->GetFlag();
}

/// @brief SharedFlagBase::SetFlag
bool
  NetworkSharedFlag::SetFlag
    ( _in<bool     > in_flag
    , _in<TimePoint> in_time_out
    )
{
  return m_sp_entity->SetFlag( in_flag, in_time_out );
}

/// @brief SharedFlagBase::GetName
td_tstring NetworkSharedFlag::GetName() const
{
  return m_sp_entity->GetName();
}

/// @brief SharedFlagBase::WaitOn
bool NetworkSharedFlag::WaitOn( _in<TimePoint> in_time_point_end )
{
  return false; // まだ未対応
}

/// @brief SharedFlagBase::WaitOff
bool NetworkSharedFlag::WaitOff( _in<TimePoint> in_time_point_end )
{
  return false; // まだ未対応
}


} // namespace Core
} // namespace CPL
