/*

Copyright (c) 2002-2005, Yauheni Akhotnikau
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.

- The name of the author may not be used to endorse or promote products derived
from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.

*/

#include <iostream>

#include <oess_1/stdsn/h/inout_templ.hpp>
#include <oess_1/stdsn/h/shptr.hpp>

namespace oess_1 {

namespace stdsn {

// Этот код был получен с помощью oess_cpp_serializer.
//
// Регистратор фабрики для shptr_t объявлен в файле
// serializable.cpp. Если же регистратор фабрики объявить
// в этом файле, то с некоторыми компиляторами (MinGW)
// происходит сбой при инициализации приложения -- похоже,
// что регистратор фабрики начинает работать раньше, чем
// будут созданы внутренности obj_factory_t.
//
//--- Начало автоматически сгенерированного сегмента ---
//
void	oess_1::stdsn::shptr_t::oess_serializer_t::unpack(
	oess_1::stdsn::ient_t & s,
	oess_1::stdsn::shptr_t & o,
	oess_1::stdsn::isubclass_extension_t * )
{
	if( s.obj_start( &o, &type_name(), scheme() ) )
	{
		{
			oess_1::stdsn::iptr_t< oess_1::stdsn::serializable_t > io_ptr( o.m_ptr );
			oess_1::stdsn::iobj_t< oess_1::stdsn::iptr_t< oess_1::stdsn::serializable_t > > io_obj( io_ptr );
			s >> io_obj;
		}
		s.obj_finish( &o, &type_name() );
	}
}
void	oess_1::stdsn::shptr_t::oess_serializer_t::unpack_complete(
	oess_1::stdsn::ient_t & s,
	oess_1::stdsn::shptr_t & o )
{
	s.obj_complete( &o, &type_name() );
}
void	oess_1::stdsn::shptr_t::oess_serializer_t::pack(
	oess_1::stdsn::oent_t & s,
	const oess_1::stdsn::shptr_t & o,
	oess_1::stdsn::osubclass_extension_t * )
{
	if( s.obj_start( &o, &type_name(), scheme() ) )
	{
		{
			oess_1::stdsn::optr_t< oess_1::stdsn::serializable_t > io_ptr( o.m_ptr );
			oess_1::stdsn::oobj_t< oess_1::stdsn::optr_t< oess_1::stdsn::serializable_t > > io_obj( io_ptr );
			s << io_obj;
		}
		s.obj_finish( &o, &type_name() );
	}
}
void	oess_1::stdsn::shptr_t::oess_serializer_t::pack_complete(
	oess_1::stdsn::oent_t & s,
	const oess_1::stdsn::shptr_t & o )
{
	s.obj_complete( &o, &type_name() );
}
void *	oess_1::stdsn::shptr_t::oess_serializer_t::cast( const std::string & cast_to, oess_1::stdsn::shptr_t * o ) {
	if( cast_to == type_name() )
		return o;
	void * p = 0;
	if( cast_to == oess_1::stdsn::serializable_t::oess_serializable_t_name() )
		return (oess_1::stdsn::serializable_t *)o;
	return p;
}
const std::string &	oess_1::stdsn::shptr_t::oess_serializer_t::type_name() {
	static std::string name( "oess_1::stdsn::shptr_t" );
	return name;
}
oess_1::stdsn::serializable_t *	oess_1::stdsn::shptr_t::oess_serializer_t::factory() {
	return new oess_1::stdsn::shptr_t();
}
const std::string &	oess_1::stdsn::shptr_t::oess_serializer_t::scheme() {
	static std::string s(
			"{type oess_1::stdsn::shptr_t {attr m_ptr {of"
			" oess_1::stdsn::serializable_t {ptr } } } } "
		);
	return s;
}
void oess_1::stdsn::shptr_t::oess_unpack( oess_1::stdsn::ient_t & s ) {
	oess_pre_unpack();
	oess_serializer_t::unpack( s, *this, 0 );
	oess_serializer_t::unpack_complete( s, *this );
	oess_post_unpack();
}
void oess_1::stdsn::shptr_t::oess_pack( oess_1::stdsn::oent_t & s ) const {
	oess_pre_pack();
	oess_serializer_t::pack( s, *this, 0 );
	oess_serializer_t::pack_complete( s, *this );
	oess_post_pack();
}
void *	oess_1::stdsn::shptr_t::oess_cast( const std::string & cast_to ) {
	return oess_serializer_t::cast( cast_to, this );
}
const std::string & oess_1::stdsn::shptr_t::oess_type_name() const {
	return oess_serializer_t::type_name();
}
const std::string & oess_1::stdsn::shptr_t::oess_scheme() const {
	return oess_serializer_t::scheme();
}
void
oess_1::stdsn::shptr_t::oess_get_subclass_extension_path(
	oess_1::stdsn::subclass_extension_path_t & path,
	const std::string & terminator ) const
	{
		OESS_THROW_PHYSIC(
			oess_1::stdsn::err::c_not_in_subclass_extension_chain,
			oess_type_name() << ", terminator: " << terminator )
	}
//
//--- Завершение автоматически сгенерированного сегмента ---
//

//
// shptr_t
//

shptr_t::shptr_t()
{}

shptr_t::shptr_t(
	serializable_t * ptr )
	:	base_type_t( ptr )
	{}

shptr_t::shptr_t(
	const shptr_t & o )
	:	base_type_t( o )
	{}

shptr_t::~shptr_t()
	{}

} /* namespace stdsn */

} /* namespace oess_1 */

