/*
  Copyright (C) 2012 Stuffomatic Ltd. <contact@stuff-o-matic.com>

  All rights reserved.

  See the accompanying license file for details about usage, modification and
  distribution of this file.
*/
/**
 * \file
 * \brief Implementation of the bear::engine::game_filesystem class.
 * \author Julien Jorge
 */
#include "engine/system/game_filesystem.hpp"

#include "engine/system/base_game_filesystem.hpp"

#include <claw/assert.hpp>

/*----------------------------------------------------------------------------*/
/**
 * \brief Constructor.
 */
bear::engine::game_filesystem::game_filesystem()
  : m_impl(NULL)
{

} // game_filesystem::game_filesystem()

/*----------------------------------------------------------------------------*/
/**
 * \brief Copy constructor.
 * \param that The instance to copy.
 */
bear::engine::game_filesystem::game_filesystem( const game_filesystem& that )
{
  if ( that.m_impl == NULL )
    m_impl = NULL;
  else
    m_impl = that.m_impl->clone();
} // game_filesystem::game_filesystem()

/*----------------------------------------------------------------------------*/
/**
 * \brief Constructor from a given implementation.
 * \param impl The implementation.
 */
bear::engine::game_filesystem::game_filesystem
( const base_game_filesystem& impl )
  : m_impl( impl.clone() )
{

} // game_filesystem::game_filesystem()

/*----------------------------------------------------------------------------*/
/**
 * \brief Destructor.
 */
bear::engine::game_filesystem::~game_filesystem()
{
  delete m_impl;
} // game_filesystem::~game_filesystem()

/*----------------------------------------------------------------------------*/
/**
 * \brief Swap this instance with another one.
 * \param that The instance to swap with.
 */
void bear::engine::game_filesystem::swap( game_filesystem& that )
{
  std::swap( m_impl, that.m_impl );
} // game_filesystem::swap()

/*----------------------------------------------------------------------------*/
/**
 * \brief Assign another instance to this one.
 * \param that The instance to copy.
 */
bear::engine::game_filesystem&
bear::engine::game_filesystem::operator=( game_filesystem that )
{
  swap( that );
  return *this;
} // game_filesystem::operator=()

/*----------------------------------------------------------------------------*/
/**
 * \brief Returns the full path of a configuration file of the game.
 * \param name The name of the configuration file.
 */
std::string
bear::engine::game_filesystem::get_custom_config_file_name( std::string name )
{
  CLAW_PRECOND( m_impl != NULL );

  return m_impl->get_custom_config_file_name( name );
} // game_filesystem::get_custom_config_file_name()

/*----------------------------------------------------------------------------*/
/**
 * \brief Returns the full path of a file generated by the user in the game.
 * \param name The name of the file.
 */
std::string
bear::engine::game_filesystem::get_custom_data_file_name( std::string name )
{
  CLAW_PRECOND( m_impl != NULL );

  return m_impl->get_custom_data_file_name( name );
} // game_filesystem::get_custom_data_file_name()




namespace std
{
  /**
   * \brief Swaps the value of two game_filesystems.
   * \param a One game_filesystem.
   * \param b Another game_filesystem.
   */
  void swap
  ( bear::engine::game_filesystem& a, bear::engine::game_filesystem& b )
  {
    a.swap( b );
  } // swap()

} // namespace std
