/*
 *  Author: bwilliams
 *  Created: April 6, 2012
 *
 *  Copyright (C) 2012-2016 VMware, Inc.  All rights reserved. -- VMware Confidential
 *
 *  This code was generated by the script "build/dev/codeGen/genCppXml". Please
 *  speak to Brian W. before modifying it by hand.
 *
 */

#include "stdafx.h"

#include "Doc/DocXml/MultiPmeMgmtRequestXml/MultiPmeMgmtBatchXml.h"

#include "Doc/MultiPmeMgmtRequestDoc/CMultiPmeMgmtBatchCollectionDoc.h"
#include "Doc/MultiPmeMgmtRequestDoc/CMultiPmeMgmtBatchDoc.h"
#include "Xml/XmlUtils/CXmlElement.h"
#include "Doc/DocXml/MultiPmeMgmtRequestXml/MultiPmeMgmtBatchCollectionXml.h"

using namespace Caf;

void MultiPmeMgmtBatchCollectionXml::add(
	const SmartPtrCMultiPmeMgmtBatchCollectionDoc multiPmeMgmtBatchCollectionDoc,
	const SmartPtrCXmlElement thisXml) {
	CAF_CM_STATIC_FUNC_VALIDATE("MultiPmeMgmtBatchCollectionXml", "add");

	CAF_CM_ENTER {
		CAF_CM_VALIDATE_SMARTPTR(multiPmeMgmtBatchCollectionDoc);
		CAF_CM_VALIDATE_SMARTPTR(thisXml);

		const std::deque<SmartPtrCMultiPmeMgmtBatchDoc> multiPmeBatchVal =
			multiPmeMgmtBatchCollectionDoc->getMultiPmeBatch();
		CAF_CM_VALIDATE_STL(multiPmeBatchVal);

		if (! multiPmeBatchVal.empty()) {
			for (TConstIterator<std::deque<SmartPtrCMultiPmeMgmtBatchDoc> > multiPmeBatchIter(multiPmeBatchVal);
				multiPmeBatchIter; multiPmeBatchIter++) {
				const SmartPtrCXmlElement multiPmeBatchXml =
					thisXml->createAndAddElement("multiPmeBatch");
				MultiPmeMgmtBatchXml::add(*multiPmeBatchIter, multiPmeBatchXml);
			}
		}
	}
	CAF_CM_EXIT;
}

SmartPtrCMultiPmeMgmtBatchCollectionDoc MultiPmeMgmtBatchCollectionXml::parse(
	const SmartPtrCXmlElement thisXml) {
	CAF_CM_STATIC_FUNC_VALIDATE("MultiPmeMgmtBatchCollectionXml", "parse");

	SmartPtrCMultiPmeMgmtBatchCollectionDoc multiPmeMgmtBatchCollectionDoc;

	CAF_CM_ENTER {
		CAF_CM_VALIDATE_SMARTPTR(thisXml);

		const CXmlElement::SmartPtrCElementCollection multiPmeBatchChildrenXml =
			thisXml->findRequiredChildren("multiPmeBatch");

		std::deque<SmartPtrCMultiPmeMgmtBatchDoc> multiPmeBatchVal;
		if (! multiPmeBatchChildrenXml.IsNull() && ! multiPmeBatchChildrenXml->empty()) {
			for (TConstIterator<CXmlElement::CElementCollection> multiPmeBatchXmlIter(*multiPmeBatchChildrenXml);
				multiPmeBatchXmlIter; multiPmeBatchXmlIter++) {
				const SmartPtrCXmlElement multiPmeBatchXml = multiPmeBatchXmlIter->second;
				const SmartPtrCMultiPmeMgmtBatchDoc multiPmeBatchDoc =
					MultiPmeMgmtBatchXml::parse(multiPmeBatchXml);
				multiPmeBatchVal.push_back(multiPmeBatchDoc);
			}
		}

		multiPmeMgmtBatchCollectionDoc.CreateInstance();
		multiPmeMgmtBatchCollectionDoc->initialize(
			multiPmeBatchVal);
	}
	CAF_CM_EXIT;

	return multiPmeMgmtBatchCollectionDoc;
}

