text: #include "uml/impl/AcceptCallActionImpl.hpp"
  
  #ifdef NDEBUG
  	#define DEBUG_MESSAGE(a) /**/
  #else
  	#define DEBUG_MESSAGE(a) a
  #endif
  
  #ifdef ACTIVITY_DEBUG_ON
      #define ACT_DEBUG(a) a
  #else
      #define ACT_DEBUG(a) /**/
  #endif
  
  //#include "util/ProfileCallCount.hpp"
  
  #include <cassert>
  #include <iostream>
  #include <sstream>
  
  #include "abstractDataTypes/Bag.hpp"
  #include "abstractDataTypes/Subset.hpp"
  #include "abstractDataTypes/SubsetUnion.hpp"
  #include "abstractDataTypes/Union.hpp"
  #include "abstractDataTypes/Any.hpp"
  #include "abstractDataTypes/SubsetUnion.hpp"
  #include "ecore/EAnnotation.hpp"
  #include "ecore/EClass.hpp"
  #include "uml/impl/UmlPackageImpl.hpp"
  
  //Forward declaration includes
  #include "persistence/interfaces/XLoadHandler.hpp" // used for Persistence
  #include "persistence/interfaces/XSaveHandler.hpp" // used for Persistence
  #include "uml/UmlFactory.hpp"
  #include "uml/UmlPackage.hpp"
  #include <exception> // used in Persistence
  
  #include "uml/AcceptEventAction.hpp"
  
  #include "uml/Activity.hpp"
  
  #include "uml/ActivityEdge.hpp"
  
  #include "uml/ActivityGroup.hpp"
  
  #include "uml/ActivityNode.hpp"
  
  #include "uml/ActivityPartition.hpp"
  
  #include "uml/Classifier.hpp"
  
  #include "uml/Comment.hpp"
  
  #include "uml/Constraint.hpp"
  
  #include "uml/Dependency.hpp"
  
  #include "ecore/EAnnotation.hpp"
  
  #include "uml/Element.hpp"
  
  #include "uml/ExceptionHandler.hpp"
  
  #include "uml/InputPin.hpp"
  
  #include "uml/InterruptibleActivityRegion.hpp"
  
  #include "uml/Namespace.hpp"
  
  #include "uml/OutputPin.hpp"
  
  #include "uml/RedefinableElement.hpp"
  
  #include "uml/StringExpression.hpp"
  
  #include "uml/StructuredActivityNode.hpp"
  
  #include "uml/Trigger.hpp"
  
  #include "ecore/EcorePackage.hpp"
  #include "ecore/EcoreFactory.hpp"
  #include "uml/UmlPackage.hpp"
  #include "uml/UmlFactory.hpp"
  #include "ecore/EAttribute.hpp"
  #include "ecore/EStructuralFeature.hpp"
  
  using namespace uml;
  
  //*********************************
  // Constructor / Destructor
  //*********************************
  AcceptCallActionImpl::AcceptCallActionImpl()
  {
  	//*********************************
  	// Attribute Members
  	//*********************************
  
  	//*********************************
  	// Reference Members
  	//*********************************
  	//References
  	
  
  	//Init references
  	
  }
  
  AcceptCallActionImpl::~AcceptCallActionImpl()
  {
  #ifdef SHOW_DELETION
  	std::cout << "-------------------------------------------------------------------------------------------------\r\ndelete AcceptCallAction "<< this << "\r\n------------------------------------------------------------------------ " << std::endl;
  #endif
  }
  
  
  //Additional constructor for the containments back reference
  			AcceptCallActionImpl::AcceptCallActionImpl(std::weak_ptr<uml::Activity > par_activity)
  			:AcceptCallActionImpl()
  			{
  			    m_activity = par_activity;
  				m_owner = par_activity;
  			}
  
  
  
  
  
  //Additional constructor for the containments back reference
  			AcceptCallActionImpl::AcceptCallActionImpl(std::weak_ptr<uml::StructuredActivityNode > par_inStructuredNode)
  			:AcceptCallActionImpl()
  			{
  			    m_inStructuredNode = par_inStructuredNode;
  				m_owner = par_inStructuredNode;
  			}
  
  
  
  
  
  //Additional constructor for the containments back reference
  			AcceptCallActionImpl::AcceptCallActionImpl(std::weak_ptr<uml::Namespace > par_namespace)
  			:AcceptCallActionImpl()
  			{
  			    m_namespace = par_namespace;
  				m_owner = par_namespace;
  			}
  
  
  
  
  
  //Additional constructor for the containments back reference
  			AcceptCallActionImpl::AcceptCallActionImpl(std::weak_ptr<uml::Element > par_owner)
  			:AcceptCallActionImpl()
  			{
  			    m_owner = par_owner;
  			}
  
  
  
  
  
  
  AcceptCallActionImpl::AcceptCallActionImpl(const AcceptCallActionImpl & obj):AcceptCallActionImpl()
  {
  	//create copy of all Attributes
  	#ifdef SHOW_COPIES
  	std::cout << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\r\ncopy AcceptCallAction "<< this << "\r\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ " << std::endl;
  	#endif
  	m_isLeaf = obj.getIsLeaf();
  	m_isLocallyReentrant = obj.getIsLocallyReentrant();
  	m_isUnmarshall = obj.getIsUnmarshall();
  	m_name = obj.getName();
  	m_qualifiedName = obj.getQualifiedName();
  	m_visibility = obj.getVisibility();
  
  	//copy references with no containment (soft copy)
  	
  	m_activity  = obj.getActivity();
  
  	std::shared_ptr<Bag<uml::Dependency>> _clientDependency = obj.getClientDependency();
  	m_clientDependency.reset(new Bag<uml::Dependency>(*(obj.getClientDependency().get())));
  
  	m_context  = obj.getContext();
  
  	std::shared_ptr<Union<uml::ActivityGroup>> _inGroup = obj.getInGroup();
  	m_inGroup.reset(new Union<uml::ActivityGroup>(*(obj.getInGroup().get())));
  
  	m_inStructuredNode  = obj.getInStructuredNode();
  
  	std::shared_ptr<Bag<uml::ActivityEdge>> _incoming = obj.getIncoming();
  	m_incoming.reset(new Bag<uml::ActivityEdge>(*(obj.getIncoming().get())));
  
  	m_namespace  = obj.getNamespace();
  
  	std::shared_ptr<Bag<uml::ActivityEdge>> _outgoing = obj.getOutgoing();
  	m_outgoing.reset(new Bag<uml::ActivityEdge>(*(obj.getOutgoing().get())));
  
  	m_owner  = obj.getOwner();
  
  	std::shared_ptr<Union<uml::RedefinableElement>> _redefinedElement = obj.getRedefinedElement();
  	m_redefinedElement.reset(new Union<uml::RedefinableElement>(*(obj.getRedefinedElement().get())));
  
  	std::shared_ptr<Union<uml::Classifier>> _redefinitionContext = obj.getRedefinitionContext();
  	m_redefinitionContext.reset(new Union<uml::Classifier>(*(obj.getRedefinitionContext().get())));
  
  
  	//Clone references with containment (deep copy)
  
  	std::shared_ptr<Bag<ecore::EAnnotation>> _eAnnotationsList = obj.getEAnnotations();
  	for(std::shared_ptr<ecore::EAnnotation> _eAnnotations : *_eAnnotationsList)
  	{
  		this->getEAnnotations()->add(std::shared_ptr<ecore::EAnnotation>(std::dynamic_pointer_cast<ecore::EAnnotation>(_eAnnotations->copy())));
  	}
  	#ifdef SHOW_SUBSET_UNION
  		std::cout << "Copying the Subset: " << "m_eAnnotations" << std::endl;
  	#endif
  	std::shared_ptr<Bag<uml::ExceptionHandler>> _handlerList = obj.getHandler();
  	for(std::shared_ptr<uml::ExceptionHandler> _handler : *_handlerList)
  	{
  		this->getHandler()->add(std::shared_ptr<uml::ExceptionHandler>(std::dynamic_pointer_cast<uml::ExceptionHandler>(_handler->copy())));
  	}
  	#ifdef SHOW_SUBSET_UNION
  		std::cout << "Copying the Subset: " << "m_handler" << std::endl;
  	#endif
  	std::shared_ptr<Bag<uml::InterruptibleActivityRegion>> _inInterruptibleRegionList = obj.getInInterruptibleRegion();
  	for(std::shared_ptr<uml::InterruptibleActivityRegion> _inInterruptibleRegion : *_inInterruptibleRegionList)
  	{
  		this->getInInterruptibleRegion()->add(std::shared_ptr<uml::InterruptibleActivityRegion>(std::dynamic_pointer_cast<uml::InterruptibleActivityRegion>(_inInterruptibleRegion->copy())));
  	}
  	#ifdef SHOW_SUBSET_UNION
  		std::cout << "Copying the Subset: " << "m_inInterruptibleRegion" << std::endl;
  	#endif
  	std::shared_ptr<Bag<uml::ActivityPartition>> _inPartitionList = obj.getInPartition();
  	for(std::shared_ptr<uml::ActivityPartition> _inPartition : *_inPartitionList)
  	{
  		this->getInPartition()->add(std::shared_ptr<uml::ActivityPartition>(std::dynamic_pointer_cast<uml::ActivityPartition>(_inPartition->copy())));
  	}
  	#ifdef SHOW_SUBSET_UNION
  		std::cout << "Copying the Subset: " << "m_inPartition" << std::endl;
  	#endif
  	std::shared_ptr<Bag<uml::Constraint>> _localPostconditionList = obj.getLocalPostcondition();
  	for(std::shared_ptr<uml::Constraint> _localPostcondition : *_localPostconditionList)
  	{
  		this->getLocalPostcondition()->add(std::shared_ptr<uml::Constraint>(std::dynamic_pointer_cast<uml::Constraint>(_localPostcondition->copy())));
  	}
  	#ifdef SHOW_SUBSET_UNION
  		std::cout << "Copying the Subset: " << "m_localPostcondition" << std::endl;
  	#endif
  	std::shared_ptr<Bag<uml::Constraint>> _localPreconditionList = obj.getLocalPrecondition();
  	for(std::shared_ptr<uml::Constraint> _localPrecondition : *_localPreconditionList)
  	{
  		this->getLocalPrecondition()->add(std::shared_ptr<uml::Constraint>(std::dynamic_pointer_cast<uml::Constraint>(_localPrecondition->copy())));
  	}
  	#ifdef SHOW_SUBSET_UNION
  		std::cout << "Copying the Subset: " << "m_localPrecondition" << std::endl;
  	#endif
  	if(obj.getNameExpression()!=nullptr)
  	{
  		m_nameExpression = std::dynamic_pointer_cast<uml::StringExpression>(obj.getNameExpression()->copy());
  	}
  	#ifdef SHOW_SUBSET_UNION
  		std::cout << "Copying the Subset: " << "m_nameExpression" << std::endl;
  	#endif
  	std::shared_ptr<Bag<uml::Comment>> _ownedCommentList = obj.getOwnedComment();
  	for(std::shared_ptr<uml::Comment> _ownedComment : *_ownedCommentList)
  	{
  		this->getOwnedComment()->add(std::shared_ptr<uml::Comment>(std::dynamic_pointer_cast<uml::Comment>(_ownedComment->copy())));
  	}
  	#ifdef SHOW_SUBSET_UNION
  		std::cout << "Copying the Subset: " << "m_ownedComment" << std::endl;
  	#endif
  	std::shared_ptr<Bag<uml::ActivityNode>> _redefinedNodeList = obj.getRedefinedNode();
  	for(std::shared_ptr<uml::ActivityNode> _redefinedNode : *_redefinedNodeList)
  	{
  		this->getRedefinedNode()->add(std::shared_ptr<uml::ActivityNode>(std::dynamic_pointer_cast<uml::ActivityNode>(_redefinedNode->copy())));
  	}
  	#ifdef SHOW_SUBSET_UNION
  		std::cout << "Copying the Subset: " << "m_redefinedNode" << std::endl;
  	#endif
  	std::shared_ptr<Bag<uml::OutputPin>> _resultList = obj.getResult();
  	for(std::shared_ptr<uml::OutputPin> _result : *_resultList)
  	{
  		this->getResult()->add(std::shared_ptr<uml::OutputPin>(std::dynamic_pointer_cast<uml::OutputPin>(_result->copy())));
  	}
  	#ifdef SHOW_SUBSET_UNION
  		std::cout << "Copying the Subset: " << "m_result" << std::endl;
  	#endif
  	if(obj.getReturnInformation()!=nullptr)
  	{
  		m_returnInformation = std::dynamic_pointer_cast<uml::OutputPin>(obj.getReturnInformation()->copy());
  	}
  	#ifdef SHOW_SUBSET_UNION
  		std::cout << "Copying the Subset: " << "m_returnInformation" << std::endl;
  	#endif
  	std::shared_ptr<Bag<uml::Trigger>> _triggerList = obj.getTrigger();
  	for(std::shared_ptr<uml::Trigger> _trigger : *_triggerList)
  	{
  		this->getTrigger()->add(std::shared_ptr<uml::Trigger>(std::dynamic_pointer_cast<uml::Trigger>(_trigger->copy())));
  	}
  	#ifdef SHOW_SUBSET_UNION
  		std::cout << "Copying the Subset: " << "m_trigger" << std::endl;
  	#endif
  
  	
  }
  
  std::shared_ptr<ecore::EObject>  AcceptCallActionImpl::copy() const
  {
  	std::shared_ptr<AcceptCallActionImpl> element(new AcceptCallActionImpl(*this));
  	element->setThisAcceptCallActionPtr(element);
  	return element;
  }
  
  std::shared_ptr<ecore::EClass> AcceptCallActionImpl::eStaticClass() const
  {
  	return UmlPackageImpl::eInstance()->getAcceptCallAction_EClass();
  }
  
  //*********************************
  // Attribute Setter Getter
  //*********************************
  
  //*********************************
  // Operations
  //*********************************
  bool AcceptCallActionImpl::result_pins(Any diagnostics,std::map <   Any, Any >  context)
  {
  	std::cout << __PRETTY_FUNCTION__  << std::endl;
  	throw "UnsupportedOperationException";
  }
  
  bool AcceptCallActionImpl::trigger_call_event(Any diagnostics,std::map <   Any, Any >  context)
  {
  	std::cout << __PRETTY_FUNCTION__  << std::endl;
  	throw "UnsupportedOperationException";
  }
  
  bool AcceptCallActionImpl::unmarshall(Any diagnostics,std::map <   Any, Any >  context)
  {
  	std::cout << __PRETTY_FUNCTION__  << std::endl;
  	throw "UnsupportedOperationException";
  }
  
  //*********************************
  // References
  //*********************************
  std::shared_ptr<uml::OutputPin > AcceptCallActionImpl::getReturnInformation() const
  {
  //assert(m_returnInformation);
      return m_returnInformation;
  }
  void AcceptCallActionImpl::setReturnInformation(std::shared_ptr<uml::OutputPin> _returnInformation)
  {
      m_returnInformation = _returnInformation;
  }
  
  //*********************************
  // Union Getter
  //*********************************
  std::shared_ptr<Union<uml::ActivityGroup>> AcceptCallActionImpl::getInGroup() const
  {
  	return m_inGroup;
  }
  std::shared_ptr<SubsetUnion<uml::OutputPin, uml::Element>> AcceptCallActionImpl::getOutput() const
  {
  	return m_output;
  }
  std::shared_ptr<Union<uml::Element>> AcceptCallActionImpl::getOwnedElement() const
  {
  	return m_ownedElement;
  }
  std::weak_ptr<uml::Element > AcceptCallActionImpl::getOwner() const
  {
  	return m_owner;
  }
  std::shared_ptr<Union<uml::RedefinableElement>> AcceptCallActionImpl::getRedefinedElement() const
  {
  	return m_redefinedElement;
  }
  
  
  std::shared_ptr<AcceptCallAction> AcceptCallActionImpl::getThisAcceptCallActionPtr() const
  {
  	return m_thisAcceptCallActionPtr.lock();
  }
  void AcceptCallActionImpl::setThisAcceptCallActionPtr(std::weak_ptr<AcceptCallAction> thisAcceptCallActionPtr)
  {
  	m_thisAcceptCallActionPtr = thisAcceptCallActionPtr;
  	setThisAcceptEventActionPtr(thisAcceptCallActionPtr);
  }
  std::shared_ptr<ecore::EObject> AcceptCallActionImpl::eContainer() const
  {
  	if(auto wp = m_activity.lock())
  	{
  		return wp;
  	}
  
  	if(auto wp = m_inStructuredNode.lock())
  	{
  		return wp;
  	}
  
  	if(auto wp = m_namespace.lock())
  	{
  		return wp;
  	}
  
  	if(auto wp = m_owner.lock())
  	{
  		return wp;
  	}
  	return nullptr;
  }
  
  //*********************************
  // Structural Feature Getter/Setter
  //*********************************
  Any AcceptCallActionImpl::eGet(int featureID, bool resolve, bool coreType) const
  {
  	switch(featureID)
  	{
  		case UmlPackage::ACCEPTCALLACTION_EREFERENCE_RETURNINFORMATION:
  			return eAny(getReturnInformation()); //13231
  	}
  	return AcceptEventActionImpl::eGet(featureID, resolve, coreType);
  }
  bool AcceptCallActionImpl::internalEIsSet(int featureID) const
  {
  	switch(featureID)
  	{
  		case UmlPackage::ACCEPTCALLACTION_EREFERENCE_RETURNINFORMATION:
  			return getReturnInformation() != nullptr; //13231
  	}
  	return AcceptEventActionImpl::internalEIsSet(featureID);
  }
  bool AcceptCallActionImpl::eSet(int featureID, Any newValue)
  {
  	switch(featureID)
  	{
  		case UmlPackage::ACCEPTCALLACTION_EREFERENCE_RETURNINFORMATION:
  		{
  			// BOOST CAST
  			std::shared_ptr<uml::OutputPin> _returnInformation = newValue->get<std::shared_ptr<uml::OutputPin>>();
  			setReturnInformation(_returnInformation); //13231
  			return true;
  		}
  	}
  
  	return AcceptEventActionImpl::eSet(featureID, newValue);
  }
  
  //*********************************
  // Persistence Functions
  //*********************************
  void AcceptCallActionImpl::load(std::shared_ptr<persistence::interfaces::XLoadHandler> loadHandler)
  {
  	std::map<std::string, std::string> attr_list = loadHandler->getAttributeList();
  	loadAttributes(loadHandler, attr_list);
  
  	//
  	// Create new objects (from references (containment == true))
  	//
  	// get UmlFactory
  	std::shared_ptr<uml::UmlFactory> modelFactory = uml::UmlFactory::eInstance();
  	int numNodes = loadHandler->getNumOfChildNodes();
  	for(int ii = 0; ii < numNodes; ii++)
  	{
  		loadNode(loadHandler->getNextNodeName(), loadHandler, modelFactory);
  	}
  }		
  
  void AcceptCallActionImpl::loadAttributes(std::shared_ptr<persistence::interfaces::XLoadHandler> loadHandler, std::map<std::string, std::string> attr_list)
  {
  
  	AcceptEventActionImpl::loadAttributes(loadHandler, attr_list);
  }
  
  void AcceptCallActionImpl::loadNode(std::string nodeName, std::shared_ptr<persistence::interfaces::XLoadHandler> loadHandler, std::shared_ptr<uml::UmlFactory> modelFactory)
  {
  
  	try
  	{
  		if ( nodeName.compare("returnInformation") == 0 )
  		{
    			std::string typeName = loadHandler->getCurrentXSITypeName();
  			if (typeName.empty())
  			{
  				typeName = "OutputPin";
  			}
  			std::shared_ptr<uml::OutputPin> returnInformation = std::dynamic_pointer_cast<uml::OutputPin>(modelFactory->create(typeName));
  			if (returnInformation != nullptr)
  			{
  				this->setReturnInformation(returnInformation);
  				loadHandler->handleChild(returnInformation);
  			}
  			return;
  		}
  	}
  	catch (std::exception& e)
  	{
  		std::cout << "| ERROR    | " << e.what() << std::endl;
  	}
  	catch (...) 
  	{
  		std::cout << "| ERROR    | " <<  "Exception occurred" << std::endl;
  	}
  
  	AcceptEventActionImpl::loadNode(nodeName, loadHandler, modelFactory);
  }
  
  void AcceptCallActionImpl::resolveReferences(const int featureID, std::list<std::shared_ptr<ecore::EObject> > references)
  {
  	AcceptEventActionImpl::resolveReferences(featureID, references);
  }
  
  void AcceptCallActionImpl::save(std::shared_ptr<persistence::interfaces::XSaveHandler> saveHandler) const
  {
  	saveContent(saveHandler);
  
  	AcceptEventActionImpl::saveContent(saveHandler);
  	
  	ActionImpl::saveContent(saveHandler);
  	
  	ExecutableNodeImpl::saveContent(saveHandler);
  	
  	ActivityNodeImpl::saveContent(saveHandler);
  	
  	ActivityContentImpl::saveContent(saveHandler);
  	RedefinableElementImpl::saveContent(saveHandler);
  	
  	NamedElementImpl::saveContent(saveHandler);
  	
  	ElementImpl::saveContent(saveHandler);
  	
  	ecore::EModelElementImpl::saveContent(saveHandler);
  	ObjectImpl::saveContent(saveHandler);
  	
  	ecore::EObjectImpl::saveContent(saveHandler);
  	
  	
  	
  	
  	
  	
  	
  	
  }
  
  void AcceptCallActionImpl::saveContent(std::shared_ptr<persistence::interfaces::XSaveHandler> saveHandler) const
  {
  	try
  	{
  		std::shared_ptr<uml::UmlPackage> package = uml::UmlPackage::eInstance();
  
  		// Save 'returnInformation'
  		std::shared_ptr<uml::OutputPin > returnInformation = this->getReturnInformation();
  		if (returnInformation != nullptr)
  		{
  			saveHandler->addReference(returnInformation, "returnInformation", returnInformation->eClass() != package->getOutputPin_EClass());
  		}
  	
  
  	}
  	catch (std::exception& e)
  	{
  		std::cout << "| ERROR    | " << e.what() << std::endl;
  	}
  }
  
  