/* 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/IfcActorSelect.h"
#include "ifcpp/IFC4/include/IfcBenchmarkEnum.h"
#include "ifcpp/IFC4/include/IfcConstraintEnum.h"
#include "ifcpp/IFC4/include/IfcDateTime.h"
#include "ifcpp/IFC4/include/IfcExternalReferenceRelationship.h"
#include "ifcpp/IFC4/include/IfcLabel.h"
#include "ifcpp/IFC4/include/IfcMetric.h"
#include "ifcpp/IFC4/include/IfcMetricValueSelect.h"
#include "ifcpp/IFC4/include/IfcReference.h"
#include "ifcpp/IFC4/include/IfcResourceConstraintRelationship.h"
#include "ifcpp/IFC4/include/IfcText.h"

// ENTITY IfcMetric 
IfcMetric::IfcMetric( int id ) { m_entity_id = id; }
IfcMetric::~IfcMetric() {}
shared_ptr<BuildingObject> IfcMetric::getDeepCopy( BuildingCopyOptions& options )
{
	shared_ptr<IfcMetric> copy_self( new IfcMetric() );
	if( m_Name ) { copy_self->m_Name = dynamic_pointer_cast<IfcLabel>( m_Name->getDeepCopy(options) ); }
	if( m_Description ) { copy_self->m_Description = dynamic_pointer_cast<IfcText>( m_Description->getDeepCopy(options) ); }
	if( m_ConstraintGrade ) { copy_self->m_ConstraintGrade = dynamic_pointer_cast<IfcConstraintEnum>( m_ConstraintGrade->getDeepCopy(options) ); }
	if( m_ConstraintSource ) { copy_self->m_ConstraintSource = dynamic_pointer_cast<IfcLabel>( m_ConstraintSource->getDeepCopy(options) ); }
	if( m_CreatingActor ) { copy_self->m_CreatingActor = dynamic_pointer_cast<IfcActorSelect>( m_CreatingActor->getDeepCopy(options) ); }
	if( m_CreationTime ) { copy_self->m_CreationTime = dynamic_pointer_cast<IfcDateTime>( m_CreationTime->getDeepCopy(options) ); }
	if( m_UserDefinedGrade ) { copy_self->m_UserDefinedGrade = dynamic_pointer_cast<IfcLabel>( m_UserDefinedGrade->getDeepCopy(options) ); }
	if( m_Benchmark ) { copy_self->m_Benchmark = dynamic_pointer_cast<IfcBenchmarkEnum>( m_Benchmark->getDeepCopy(options) ); }
	if( m_ValueSource ) { copy_self->m_ValueSource = dynamic_pointer_cast<IfcLabel>( m_ValueSource->getDeepCopy(options) ); }
	if( m_DataValue ) { copy_self->m_DataValue = dynamic_pointer_cast<IfcMetricValueSelect>( m_DataValue->getDeepCopy(options) ); }
	if( m_ReferencePath ) { copy_self->m_ReferencePath = dynamic_pointer_cast<IfcReference>( m_ReferencePath->getDeepCopy(options) ); }
	return copy_self;
}
void IfcMetric::getStepLine( std::stringstream& stream ) const
{
	stream << "#" << m_entity_id << "= IFCMETRIC" << "(";
	if( m_Name ) { m_Name->getStepParameter( stream ); } else { stream << "$"; }
	stream << ",";
	if( m_Description ) { m_Description->getStepParameter( stream ); } else { stream << "$"; }
	stream << ",";
	if( m_ConstraintGrade ) { m_ConstraintGrade->getStepParameter( stream ); } else { stream << "$"; }
	stream << ",";
	if( m_ConstraintSource ) { m_ConstraintSource->getStepParameter( stream ); } else { stream << "$"; }
	stream << ",";
	if( m_CreatingActor ) { m_CreatingActor->getStepParameter( stream, true ); } else { stream << "$" ; }
	stream << ",";
	if( m_CreationTime ) { m_CreationTime->getStepParameter( stream ); } else { stream << "$"; }
	stream << ",";
	if( m_UserDefinedGrade ) { m_UserDefinedGrade->getStepParameter( stream ); } else { stream << "$"; }
	stream << ",";
	if( m_Benchmark ) { m_Benchmark->getStepParameter( stream ); } else { stream << "$"; }
	stream << ",";
	if( m_ValueSource ) { m_ValueSource->getStepParameter( stream ); } else { stream << "$"; }
	stream << ",";
	if( m_DataValue ) { m_DataValue->getStepParameter( stream, true ); } else { stream << "$" ; }
	stream << ",";
	if( m_ReferencePath ) { stream << "#" << m_ReferencePath->m_entity_id; } else { stream << "$"; }
	stream << ");";
}
void IfcMetric::getStepParameter( std::stringstream& stream, bool ) const { stream << "#" << m_entity_id; }
const std::wstring IfcMetric::toString() const { return L"IfcMetric"; }
void IfcMetric::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 != 11 ){ std::stringstream err; err << "Wrong parameter count for entity IfcMetric, expecting 11, having " << num_args << ". Entity ID: " << m_entity_id << std::endl; throw BuildingException( err.str().c_str() ); }
	m_Name = IfcLabel::createObjectFromSTEP( args[0], map );
	m_Description = IfcText::createObjectFromSTEP( args[1], map );
	m_ConstraintGrade = IfcConstraintEnum::createObjectFromSTEP( args[2], map );
	m_ConstraintSource = IfcLabel::createObjectFromSTEP( args[3], map );
	m_CreatingActor = IfcActorSelect::createObjectFromSTEP( args[4], map );
	m_CreationTime = IfcDateTime::createObjectFromSTEP( args[5], map );
	m_UserDefinedGrade = IfcLabel::createObjectFromSTEP( args[6], map );
	m_Benchmark = IfcBenchmarkEnum::createObjectFromSTEP( args[7], map );
	m_ValueSource = IfcLabel::createObjectFromSTEP( args[8], map );
	m_DataValue = IfcMetricValueSelect::createObjectFromSTEP( args[9], map );
	readEntityReference( args[10], m_ReferencePath, map );
}
void IfcMetric::getAttributes( std::vector<std::pair<std::string, shared_ptr<BuildingObject> > >& vec_attributes ) const
{
	IfcConstraint::getAttributes( vec_attributes );
	vec_attributes.emplace_back( std::make_pair( "Benchmark", m_Benchmark ) );
	vec_attributes.emplace_back( std::make_pair( "ValueSource", m_ValueSource ) );
	vec_attributes.emplace_back( std::make_pair( "DataValue", m_DataValue ) );
	vec_attributes.emplace_back( std::make_pair( "ReferencePath", m_ReferencePath ) );
}
void IfcMetric::getAttributesInverse( std::vector<std::pair<std::string, shared_ptr<BuildingObject> > >& vec_attributes_inverse ) const
{
	IfcConstraint::getAttributesInverse( vec_attributes_inverse );
}
void IfcMetric::setInverseCounterparts( shared_ptr<BuildingEntity> ptr_self_entity )
{
	IfcConstraint::setInverseCounterparts( ptr_self_entity );
}
void IfcMetric::unlinkFromInverseCounterparts()
{
	IfcConstraint::unlinkFromInverseCounterparts();
}
