// This file is part of the Coral project.
// Please read the copyright notice in the LICENSE file.

#include <coral/core/DCE_UUID.h>

#include <iostream>
#include <coral/lib/assert.h>
#include <coral/coral.h>

namespace coral {

	DCE_UUID::DCE_UUID() : uniqueID("") {
		;
	}

	DCE_UUID::~DCE_UUID() throw () {
		;
	}

	const uuid_t& DCE_UUID::__XMIid__() const {
		/* Generate XMI id:s on the fly. */
		if (this->uniqueID.size() == 0) {
			MUST_WORK(this->uniqueID = getUniqueID());
		}
		return this->uniqueID;
	}

	void DCE_UUID::__setXMIid__(const std::string& newID) {
		MUST_WORK(this->uniqueID = newID);
	}

	void DCE_UUID::__resetXMIid__() throw () {
		this->uniqueID.clear();
	}

	void DCE_UUID::swapXMIid(std::string& newID) throw () {
		/* Make sure it is generated. Probably unnecessary. */
		(void) this->__XMIid__();
		this->uniqueID.swap(newID);
	}
}
