
/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

/*  This code generated by: 
 *      Author : thomas
 *      Date   : Fri Aug 07 2003
 */

#include <kdebug.h>
#include "ownedhierarchicalcodeblock.h"
#include "association.h"
#include "umldoc.h"
#include "umlobject.h"
#include "umlrole.h"
#include "codedocument.h"
#include "codegenerator.h"

// Constructors/Destructors
//  

OwnedHierarchicalCodeBlock::OwnedHierarchicalCodeBlock ( UMLObject *parent, CodeDocument * doc, QString start, QString end, QString comment) 
   : HierarchicalCodeBlock ( doc, start, end, comment), OwnedCodeBlock(parent)
{

} 

OwnedHierarchicalCodeBlock::~OwnedHierarchicalCodeBlock ( ) { }

//  
// Methods
//  


// Accessor methods
//  

// Other methods
//  

void OwnedHierarchicalCodeBlock::release () {
	OwnedCodeBlock::release();
        HierarchicalCodeBlock::release();
}

void OwnedHierarchicalCodeBlock::setAttributesFromObject (TextBlock * obj) {

        HierarchicalCodeBlock::setAttributesFromObject(obj);
        OwnedCodeBlock::setAttributesFromObject(obj);
}

void OwnedHierarchicalCodeBlock::setAttributesOnNode (QDomDocument & doc, QDomElement & elem ) {

        // set super-class attributes
        HierarchicalCodeBlock::setAttributesOnNode(doc, elem);
        OwnedCodeBlock::setAttributesOnNode(doc, elem);

        // set local class attributes
        elem.setAttribute("parent_id",QString::number(getParentObject()->getID()));

        // setting ID's takes special treatment
        // as UMLRoles arent properly stored in the XMI right now.
        // (change would break the XMI format..save for big version change )
        UMLRole * role = dynamic_cast<UMLRole*>(getParentObject());
        if(role)
                elem.setAttribute("role_id",role->getRoleID());
        else
                elem.setAttribute("role_id","-1");

}

/** set the class attributes of this object from
 * the passed element node.
 */
void OwnedHierarchicalCodeBlock::setAttributesFromNode ( QDomElement & root)
{

        // set attributes from the XMI
        HierarchicalCodeBlock::setAttributesFromNode(root); // superclass load
        OwnedCodeBlock::setAttributesFromNode(root); // superclass load

}

CodeDocument * OwnedHierarchicalCodeBlock::getParentDocument() {
	return TextBlock::getParentDocument();
}

/**
 */
void OwnedHierarchicalCodeBlock::syncToParent ( ) {

        if(getContentType() != CodeBlock::AutoGenerated)
                return;

        updateContent();
}


#include "ownedhierarchicalcodeblock.moc"
