diff -r 514d98f21c43 -r 4ea6f81c838a widgetmodel/alfwidgetmodel/src/alfattributecontainer.cpp --- a/widgetmodel/alfwidgetmodel/src/alfattributecontainer.cpp Mon Jun 21 16:15:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,162 +0,0 @@ -/* -* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Implements the Container class for atrributes. -* -*/ - - -#include -#include -#include -#include "alf/alfattribute.h" -#include "alf/alfattributecontainer.h" -#include -#include -#include // from libc - -namespace Alf - { - - -/** - * Attribute container implementation. - */ -class AlfAttributeContainerImpl - { -public: - osncore::AlfPtrVector mAttributes; - AlfAttributeContainer::Type mType; - uint mTime; - }; - -// ======== MEMBER FUNCTIONS ======== - -// --------------------------------------------------------------------------- -// Constructor. -// --------------------------------------------------------------------------- -// - -OSN_EXPORT AlfAttributeContainer::AlfAttributeContainer(Type aType) : - mData(new (EMM) AlfAttributeContainerImpl()) - { - mData->mType = aType; - mData->mTime = 0; - } - -// --------------------------------------------------------------------------- -// Destructor. -// --------------------------------------------------------------------------- -// -OSN_EXPORT AlfAttributeContainer::~AlfAttributeContainer() - { - - } - -// --------------------------------------------------------------------------- -// Gets the type of the container. -// --------------------------------------------------------------------------- -// -OSN_EXPORT AlfAttributeContainer::Type AlfAttributeContainer::type() const - { - return mData->mType; - } - -// --------------------------------------------------------------------------- -// Adds a new attribute to the container. -// --------------------------------------------------------------------------- -// -OSN_EXPORT void AlfAttributeContainer::addAttribute(AlfAttribute* aAttribute) - { - mData->mAttributes.resize(mData->mAttributes.count() +1 ); - mData->mAttributes.insert(mData->mAttributes.count(), aAttribute); - } - -// --------------------------------------------------------------------------- -// Returns the attribute count. -// --------------------------------------------------------------------------- -// -OSN_EXPORT unsigned int AlfAttributeContainer::attributeCount()const - { - return mData->mAttributes.count(); - } - -// --------------------------------------------------------------------------- -// Returns the attribute. -// --------------------------------------------------------------------------- -// -OSN_EXPORT AlfAttribute& AlfAttributeContainer::getAttribute( - unsigned int aIndex) const - { - // invariant - assert(aIndex < mData->mAttributes.count()); - if (aIndex >= mData->mAttributes.count()) - { - ALF_THROW(AlfDataException,EInvalidAttribute,"AlfAttributeContainer") - } - - return *(mData->mAttributes[aIndex]); - } - -// --------------------------------------------------------------------------- -// Returns the attribute. -// --------------------------------------------------------------------------- -// -OSN_EXPORT AlfAttribute& AlfAttributeContainer::getAttributeByName( - const char * aName) const - { - for (TInt i=0; i < mData->mAttributes.count(); i++) - { - if (!strcmp(mData->mAttributes[i]->name(), aName)) - { - return *(mData->mAttributes[i]); - } - } - ALF_THROW(AlfDataException,EInvalidAttribute,"AlfAttributeContainer") - } - -// --------------------------------------------------------------------------- -// Removes the attribute. -// --------------------------------------------------------------------------- -// -OSN_EXPORT void AlfAttributeContainer::removeAttribute(unsigned int aIndex) - { - assert(aIndex < mData->mAttributes.count()); - if (aIndex >= mData->mAttributes.count()) - { - ALF_THROW(AlfDataException,EInvalidAttribute,"AlfAttributeContainer") - } - - mData->mAttributes.remove(aIndex); - } - -// --------------------------------------------------------------------------- -// Sets the animation time of the attribute container. -// --------------------------------------------------------------------------- -// -OSN_EXPORT void AlfAttributeContainer::setTime(unsigned int aTime) - { - mData->mTime = aTime; - } - -// --------------------------------------------------------------------------- -// Returns the animation time of the attribute container. -// --------------------------------------------------------------------------- -// -OSN_EXPORT unsigned int AlfAttributeContainer::getTime()const - { - return mData->mTime; - } - - } // Alf -