/*
 *  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/MgmtTypesXml/MgmtInvokeOperationXml.h"

#include "Doc/MgmtTypesDoc/CMgmtInvokeOperationCollectionDoc.h"
#include "Doc/MgmtTypesDoc/CMgmtInvokeOperationDoc.h"
#include "Xml/XmlUtils/CXmlElement.h"
#include "Doc/DocXml/MgmtTypesXml/MgmtInvokeOperationCollectionXml.h"

using namespace Caf;

void MgmtInvokeOperationCollectionXml::add(
	const SmartPtrCMgmtInvokeOperationCollectionDoc mgmtInvokeOperationCollectionDoc,
	const SmartPtrCXmlElement thisXml) {
	CAF_CM_STATIC_FUNC_VALIDATE("MgmtInvokeOperationCollectionXml", "add");

	CAF_CM_ENTER {
		CAF_CM_VALIDATE_SMARTPTR(mgmtInvokeOperationCollectionDoc);
		CAF_CM_VALIDATE_SMARTPTR(thisXml);

		const std::deque<SmartPtrCMgmtInvokeOperationDoc> invokeOperationVal =
			mgmtInvokeOperationCollectionDoc->getInvokeOperationCollection();
		CAF_CM_VALIDATE_STL(invokeOperationVal);

		if (! invokeOperationVal.empty()) {
			for (TConstIterator<std::deque<SmartPtrCMgmtInvokeOperationDoc> > invokeOperationIter(invokeOperationVal);
				invokeOperationIter; invokeOperationIter++) {
				const SmartPtrCXmlElement invokeOperationXml =
					thisXml->createAndAddElement("invokeOperation");
				MgmtInvokeOperationXml::add(*invokeOperationIter, invokeOperationXml);
			}
		}
	}
	CAF_CM_EXIT;
}

SmartPtrCMgmtInvokeOperationCollectionDoc MgmtInvokeOperationCollectionXml::parse(
	const SmartPtrCXmlElement thisXml) {
	CAF_CM_STATIC_FUNC_VALIDATE("MgmtInvokeOperationCollectionXml", "parse");

	SmartPtrCMgmtInvokeOperationCollectionDoc mgmtInvokeOperationCollectionDoc;

	CAF_CM_ENTER {
		CAF_CM_VALIDATE_SMARTPTR(thisXml);

		const CXmlElement::SmartPtrCElementCollection invokeOperationChildrenXml =
			thisXml->findRequiredChildren("invokeOperation");

		std::deque<SmartPtrCMgmtInvokeOperationDoc> invokeOperationVal;
		if (! invokeOperationChildrenXml.IsNull() && ! invokeOperationChildrenXml->empty()) {
			for (TConstIterator<CXmlElement::CElementCollection> invokeOperationXmlIter(*invokeOperationChildrenXml);
				invokeOperationXmlIter; invokeOperationXmlIter++) {
				const SmartPtrCXmlElement invokeOperationXml = invokeOperationXmlIter->second;
				const SmartPtrCMgmtInvokeOperationDoc invokeOperationDoc =
					MgmtInvokeOperationXml::parse(invokeOperationXml);
				invokeOperationVal.push_back(invokeOperationDoc);
			}
		}

		mgmtInvokeOperationCollectionDoc.CreateInstance();
		mgmtInvokeOperationCollectionDoc->initialize(
			invokeOperationVal);
	}
	CAF_CM_EXIT;

	return mgmtInvokeOperationCollectionDoc;
}

