/* Code generated by IfcQuery EXPRESS generator, www.ifcquery.com */
#include <sstream>
#include <limits>

#include "ifcpp/model/AttributeObject.h"
#include "ifcpp/model/BuildingException.h"
#include "ifcpp/model/BuildingGuid.h"
#include "ifcpp/reader/ReaderUtil.h"
#include "ifcpp/writer/WriterUtil.h"
#include "ifcpp/IFC4/include/IfcAddress.h"
#include "ifcpp/IFC4/include/IfcAddressTypeEnum.h"
#include "ifcpp/IFC4/include/IfcLabel.h"
#include "ifcpp/IFC4/include/IfcOrganization.h"
#include "ifcpp/IFC4/include/IfcPerson.h"
#include "ifcpp/IFC4/include/IfcText.h"

// ENTITY IfcAddress 
IfcAddress::IfcAddress( int id ) { m_entity_id = id; }
IfcAddress::~IfcAddress() {}
shared_ptr<BuildingObject> IfcAddress::getDeepCopy( BuildingCopyOptions& options )
{
	shared_ptr<IfcAddress> copy_self( new IfcAddress() );
	if( m_Purpose ) { copy_self->m_Purpose = dynamic_pointer_cast<IfcAddressTypeEnum>( m_Purpose->getDeepCopy(options) ); }
	if( m_Description ) { copy_self->m_Description = dynamic_pointer_cast<IfcText>( m_Description->getDeepCopy(options) ); }
	if( m_UserDefinedPurpose ) { copy_self->m_UserDefinedPurpose = dynamic_pointer_cast<IfcLabel>( m_UserDefinedPurpose->getDeepCopy(options) ); }
	return copy_self;
}
void IfcAddress::getStepLine( std::stringstream& stream ) const
{
	stream << "#" << m_entity_id << "= IFCADDRESS" << "(";
	if( m_Purpose ) { m_Purpose->getStepParameter( stream ); } else { stream << "$"; }
	stream << ",";
	if( m_Description ) { m_Description->getStepParameter( stream ); } else { stream << "$"; }
	stream << ",";
	if( m_UserDefinedPurpose ) { m_UserDefinedPurpose->getStepParameter( stream ); } else { stream << "$"; }
	stream << ");";
}
void IfcAddress::getStepParameter( std::stringstream& stream, bool ) const { stream << "#" << m_entity_id; }
const std::wstring IfcAddress::toString() const { return L"IfcAddress"; }
void IfcAddress::readStepArguments( const std::vector<std::wstring>& args, const std::map<int,shared_ptr<BuildingEntity> >& map )
{
	const size_t num_args = args.size();
	if( num_args != 3 ){ std::stringstream err; err << "Wrong parameter count for entity IfcAddress, expecting 3, having " << num_args << ". Entity ID: " << m_entity_id << std::endl; throw BuildingException( err.str().c_str() ); }
	m_Purpose = IfcAddressTypeEnum::createObjectFromSTEP( args[0], map );
	m_Description = IfcText::createObjectFromSTEP( args[1], map );
	m_UserDefinedPurpose = IfcLabel::createObjectFromSTEP( args[2], map );
}
void IfcAddress::getAttributes( std::vector<std::pair<std::string, shared_ptr<BuildingObject> > >& vec_attributes ) const
{
	vec_attributes.emplace_back( std::make_pair( "Purpose", m_Purpose ) );
	vec_attributes.emplace_back( std::make_pair( "Description", m_Description ) );
	vec_attributes.emplace_back( std::make_pair( "UserDefinedPurpose", m_UserDefinedPurpose ) );
}
void IfcAddress::getAttributesInverse( std::vector<std::pair<std::string, shared_ptr<BuildingObject> > >& vec_attributes_inverse ) const
{
	if( !m_OfPerson_inverse.empty() )
	{
		shared_ptr<AttributeObjectVector> OfPerson_inverse_vec_obj( new AttributeObjectVector() );
		for( size_t i=0; i<m_OfPerson_inverse.size(); ++i )
		{
			if( !m_OfPerson_inverse[i].expired() )
			{
				OfPerson_inverse_vec_obj->m_vec.emplace_back( shared_ptr<IfcPerson>( m_OfPerson_inverse[i] ) );
			}
		}
		vec_attributes_inverse.emplace_back( std::make_pair( "OfPerson_inverse", OfPerson_inverse_vec_obj ) );
	}
	if( !m_OfOrganization_inverse.empty() )
	{
		shared_ptr<AttributeObjectVector> OfOrganization_inverse_vec_obj( new AttributeObjectVector() );
		for( size_t i=0; i<m_OfOrganization_inverse.size(); ++i )
		{
			if( !m_OfOrganization_inverse[i].expired() )
			{
				OfOrganization_inverse_vec_obj->m_vec.emplace_back( shared_ptr<IfcOrganization>( m_OfOrganization_inverse[i] ) );
			}
		}
		vec_attributes_inverse.emplace_back( std::make_pair( "OfOrganization_inverse", OfOrganization_inverse_vec_obj ) );
	}
}
void IfcAddress::setInverseCounterparts( shared_ptr<BuildingEntity> )
{
}
void IfcAddress::unlinkFromInverseCounterparts()
{
}
