//----------------------------------------------------------------------------------
// <copyright file="LqrSMACCmdOutputFormatterAlias.cpp" company="LiquidRobotics">
//
// Copyright (c) 2014 Liquid Robotics, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
// This software is associated with a release.  Liquid Robotics makes no
// representation that the design, interfaces or component distribution will
// remain unchanged in future releases.
//
// </copyright>
//
// <summary>
//   Declaration of CmdOutputFormatterAlias, a subclass of a CmdOutputFormatter that
//   passes its output to the referenced instance
// </summary>
//
// <owner>Mike Cookson</owner>
//----------------------------------------------------------------------------------

#include "LqrSMACCmdOutputFormatterAlias.h"

using namespace std;

namespace LiquidRobotics {
namespace SMACFramework {

CmdOutputFormatterAlias::CmdOutputFormatterAlias(CmdOutputFormatter::Ptr _instance)
: instance(_instance)
{
}

void CmdOutputFormatterAlias::AddAttribute(const string& attributeName, const string& attributeValue)
{
	if (instance)
		instance->AddAttribute(attributeName, attributeValue);
}

void CmdOutputFormatterAlias::AppendOutput(const void* pStart, unsigned len)
{
	if (instance)
		instance->AppendOutput(pStart, len);
}

void CmdOutputFormatterAlias::AppendResult(const void* pStart, unsigned len)
{
	if (instance)
		instance->AppendResult(pStart, len);
}

void CmdOutputFormatterAlias::AppendTag(const string& tagName, const void* pStart, unsigned len)
{
	if (instance)
		instance->AppendTag(tagName, pStart, len);
}

string CmdOutputFormatterAlias::GetAttribute(const string& attributeName) const
{
	string result;

	if (instance)
		result = instance->GetAttribute(attributeName);

	return result;
}

string CmdOutputFormatterAlias::GetOutput() const
{
	string result;

	if (instance)
		result = instance->GetOutput();

	return result;
}

void CmdOutputFormatterAlias::AppendResult(const ByteArray& data)
{
	if (instance)
		instance->AppendResult(data);
}

void CmdOutputFormatterAlias::AppendResult(const string& data)
{
	if (instance)
		instance->AppendResult(data);
}

string CmdOutputFormatterAlias::GetTag(const string& tagName) const
{
	string result;

	if (instance)
		result = instance->GetTag(tagName);

	return result;
}

CmdOutputFormatterAlias::Ptr CmdOutputFormatterAlias::NewChild()
{
	Ptr result;

	if (instance)
		result = instance->NewChild();

	return result;
}

CmdOutputFormatterAlias::OutputStream& CmdOutputFormatterAlias::ToStream(OutputStream& stm, unsigned nesting, unsigned maxLength) const
{
	return instance->ToStream(stm, nesting, maxLength);
}

void CmdOutputFormatterAlias::AppendOutput(const ByteArray& data)
{
	if (instance)
		instance->AppendOutput(data);
}

void CmdOutputFormatterAlias::AppendOutput(const string& data)
{
	if (instance)
		instance->AppendOutput(data);
}

CmdOutputFormatterAlias::TimestampValue& CmdOutputFormatterAlias::CreateTime()
{
	return instance->CreateTime();
}

const CmdOutputFormatterAlias::TimestampValue& CmdOutputFormatterAlias::CreateTime() const
{
	return instance->CreateTime();
}

CmdOutputFormatterAlias::TimestampValue& CmdOutputFormatterAlias::EndTime()
{
	return instance->EndTime();
}

const CmdOutputFormatterAlias::TimestampValue& CmdOutputFormatterAlias::EndTime() const
{
	return instance->EndTime();
}

void CmdOutputFormatterAlias::FlagCompleted(CORBA::Exception& ex)
{
	// flagging functions are disabled
}

void CmdOutputFormatterAlias::FlagCompleted(std::exception& ex)
{
	// flagging functions are disabled
}

void CmdOutputFormatterAlias::FlagCompleted(bool success)
{
	// flagging functions are disabled
}

void CmdOutputFormatterAlias::FlagStarted()
{
	// flagging functions are disabled
}

bool CmdOutputFormatterAlias::FlaggedCompleted() const
{
	return instance->FlaggedCompleted();
}

bool CmdOutputFormatterAlias::FlaggedStarted() const
{
	return instance->FlaggedStarted();
}

void CmdOutputFormatterAlias::GetChildren(PtrArray& _children) const
{
	if (instance)
		instance->GetChildren(_children);
}

string CmdOutputFormatterAlias::GetCommandName() const
{
	string result;

	if (instance)
		result = instance->GetCommandName();

	return result;
}

CmdOutputFormatterBase* CmdOutputFormatterAlias::GetParent() const
{
	CmdOutputFormatterBase* result = NULL;

	if (instance)
		result = instance->GetParent();

	return result;
}

void CmdOutputFormatterAlias::NewChild(Ptr newChild)
{
	if (instance)
		instance->NewChild(newChild);
}

void CmdOutputFormatterAlias::NewChild(CmdOutputFormatterBase* newChild)
{
	if (instance)
		instance->NewChild(newChild);
}

CmdOutputFormatterAlias::OutputterStream& CmdOutputFormatterAlias::Output()
{
	return instance->Output();
}

const CmdOutputFormatterAlias::OutputterStream& CmdOutputFormatterAlias::Output() const
{
	return instance->Output();
}

void CmdOutputFormatterAlias::SetCommandName(const string& newValue)
{
	if (instance)
		instance->SetCommandName(newValue);
}

void CmdOutputFormatterAlias::SetParent(CmdOutputFormatterBase* newValue)
{
	if (instance)
		instance->SetParent(newValue);
}

CmdOutputFormatterAlias::TimestampValue& CmdOutputFormatterAlias::StartTime()
{
	return instance->StartTime();
}

const CmdOutputFormatterAlias::TimestampValue& CmdOutputFormatterAlias::StartTime() const
{
	return instance->StartTime();
}

string CmdOutputFormatterAlias::ToString(unsigned nesting, unsigned maxLength) const
{
	string result;

	if (instance)
		result = instance->ToString(nesting, maxLength);

	return result;
}

}
}
