[GME-commit]
GMESRC/GME/ConstraintManager OCLTypeExGMEEC.cpp,1.20,1.21
OCLTypeExGMECM.cpp,1.26,1.27 OCLTypeExBasic.h,1.2,1.3
OCLTypeExBasic.cpp,1.16,1.17 OCLTree.cpp,1.26,1.27
OCLObjectExBasic.h,1.3,1.4 OCLObjectExBasic.cpp,1.6,1.7
OCLObject.h,1.3,1.4 OCLObject.cpp,1.6,1.7
OCLFeatureImplementation.h,1.5,1.6 ConstraintManager.dsp,1.21,1.22
gme-commit at list.isis.vanderbilt.edu
gme-commit at list.isis.vanderbilt.edu
Mon Sep 13 10:14:56 CDT 2004
Update of /var/lib/gme/GMESRC/GME/ConstraintManager
In directory braindrain:/tmp/cvs-serv26600
Modified Files:
OCLTypeExGMEEC.cpp OCLTypeExGMECM.cpp OCLTypeExBasic.h
OCLTypeExBasic.cpp OCLTree.cpp OCLObjectExBasic.h
OCLObjectExBasic.cpp OCLObject.h OCLObject.cpp
OCLFeatureImplementation.h ConstraintManager.dsp
Log Message:
OrderedSet and sortedBy is implemented
CVS User: bogyom
Index: OCLTypeExGMEEC.cpp
===================================================================
RCS file: /var/lib/gme/GMESRC/GME/ConstraintManager/OCLTypeExGMEEC.cpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** OCLTypeExGMEEC.cpp 27 Aug 2004 14:16:31 -0000 1.20
--- OCLTypeExGMEEC.cpp 13 Sep 2004 14:14:53 -0000 1.21
***************
*** 1024,1027 ****
--- 1024,1036 ----
return;
}
+
+ // -- ??
+ if ( strName == "ocl::OrderedSet" || strName == "OrderedSet" ) {
+ StringVector vecSupers;
+ vecSupers.push_back( "ocl::Set" );
+ vecTypes.push_back( new OclMeta::CompoundType( "ocl::OrderedSet", vecSupers, new OclImplementation::AttributeFactory(), new OclImplementation::AssociationFactory(), new OclBasic::TOrderedSet_MethodFactory(),new OclBasic::TOrderedSet_IteratorFactory(), false ) );
+ return;
+ }
+ // --
}
Index: OCLTypeExGMECM.cpp
===================================================================
RCS file: /var/lib/gme/GMESRC/GME/ConstraintManager/OCLTypeExGMECM.cpp,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -d -r1.26 -r1.27
*** OCLTypeExGMECM.cpp 27 Aug 2004 14:16:31 -0000 1.26
--- OCLTypeExGMECM.cpp 13 Sep 2004 14:14:53 -0000 1.27
***************
*** 2282,2285 ****
--- 2282,2294 ----
return;
}
+
+ // -- ??
+ if ( strName == "ocl::OrderedSet" || strName == "OrderedSet" ) {
+ StringVector vecSupers;
+ vecSupers.push_back( "ocl::Set" );
+ vecTypes.push_back( new OclMeta::CompoundType( "ocl::OrderedSet", vecSupers, new OclImplementation::AttributeFactory(), new OclImplementation::AssociationFactory(), new OclBasic::TOrderedSet_MethodFactory(),new OclBasic::TOrderedSet_IteratorFactory(), false ) );
+ return;
+ }
+ // --
}
Index: OCLTypeExBasic.h
===================================================================
RCS file: /var/lib/gme/GMESRC/GME/ConstraintManager/OCLTypeExBasic.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** OCLTypeExBasic.h 23 Oct 2002 14:06:00 -0000 1.2
--- OCLTypeExBasic.h 13 Sep 2004 14:14:53 -0000 1.3
***************
*** 164,167 ****
--- 164,187 ----
//##############################################################################################################################################
//
+ // T Y P E O F ocl::OerderedSet
+ //
+ //##############################################################################################################################################
+
+ class TOrderedSet_MethodFactory
+ : public OclImplementation::MethodFactory
+ {
+ public :
+ virtual void GetFeatures( const OclSignature::Method& signature, OclMeta::MethodVector& vecFeatures );
+ };
+
+ class TOrderedSet_IteratorFactory
+ : public OclImplementation::IteratorFactory
+ {
+ public :
+ virtual void GetFeatures( const OclSignature::Iterator& signature, OclMeta::IteratorVector& vecFeatures );
+ };
+
+ //##############################################################################################################################################
+ //
// G L O B A L F A C T O R I E S
//
Index: OCLTypeExBasic.cpp
===================================================================
RCS file: /var/lib/gme/GMESRC/GME/ConstraintManager/OCLTypeExBasic.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** OCLTypeExBasic.cpp 23 Aug 2004 22:25:48 -0000 1.16
--- OCLTypeExBasic.cpp 13 Sep 2004 14:14:53 -0000 1.17
***************
*** 845,851 ****
//##############################################################################################################################################
! //##############################################################################################################################################
//
! // C O M M O N F E A T U R E S O F ocl::Set , ocl::Bag , ocl::Sequence
//
//##############################################################################################################################################
--- 845,851 ----
//##############################################################################################################################################
! //##############################################################################################################################################
//
! // C O M M O N F E A T U R E S O F ocl::Set , ocl::Bag , ocl::Sequence , ocl::OrderedSet
//
//##############################################################################################################################################
***************
*** 980,985 ****
}
};
!
! ITERATOR( TCollection_Exists )
{
private:
--- 980,999 ----
}
};
!
! // --
! METHOD( TCollection_AsOrderedSet )
! {
! void operator()()
! {
! if ( GetThis().GetTypeName() == "ocl::OrderedSet" ) {
! SetResult( GetThis() );
! return;
! }
! DECL_COLLECTION( collThis, GetThis() );
! SetResult( CREATE_ORDEREDSET( GetTypeManager(), collThis ) );
! }
! };
! // --
! ITERATOR( TCollection_Exists ) // true - if the collection contains at least one element - for which the condition evaluates to true
{
private:
***************
*** 1084,1088 ****
};
! ITERATOR( TCollection_Any )
{
private :
--- 1098,1102 ----
};
! ITERATOR( TCollection_Any ) // returns one element - the condition evaluates to true for that element
{
private :
***************
*** 1118,1122 ****
};
! ITERATOR( TCollection_One )
{
private :
--- 1132,1136 ----
};
! ITERATOR( TCollection_One ) // true - if the collection contains just one element - for which the condition evaluates to true
{
private :
***************
*** 1147,1150 ****
--- 1161,1262 ----
};
+ // --
+ //
+ ITERATOR( TCollection_SortedBy)
+ {
+ private :
+ typedef map<long, OclMeta::Object> TintMap;
+ TintMap intMap;
+ bool isInt;
+ typedef map<double, OclMeta::Object> TrealMap;
+ TrealMap realMap;
+ bool isReal;
+ typedef map<string, OclMeta::Object> TstringMap;
+ TstringMap stringMap;
+ bool isString;
+
+
+ void Initialize()
+ {
+ OclIterator::Initialize();
+ intMap.clear();
+ isInt = false;
+ realMap.clear();
+ isReal = false;
+ stringMap.clear();
+ isString = false;
+ }
+
+ void operator()()
+ {
+ OclMeta::Object keyObj = GetSubResult();
+ if (!keyObj.IsComparable())
+ {
+ ThrowException( "Key must be: Integer or Real or String." );
+ return;
+ }
+ OclMeta::Object store = GetSubOriResult();
+ string keytype = keyObj.GetTypeName();
+
+ if (keytype == "ocl::Integer")
+ {
+ isInt = true;
+ DECL_INTEGER(key, keyObj);
+ intMap.insert(TintMap::value_type(key, store));
+ }
+ else if (keytype == "ocl::Real")
+ {
+ isReal = true;
+ DECL_REAL(key, keyObj);
+ realMap.insert(TrealMap::value_type(key, store));
+ }
+ else if (keytype == "ocl::String")
+ {
+ isString = true;
+ DECL_STRING(key, keyObj);
+ stringMap.insert(TstringMap::value_type(key, store));
+ }
+
+ }
+
+ OclMeta::Object GetResult() const
+ {
+ OclMeta::ObjectVector vecSelecteds;
+ vecSelecteds.clear();
+ if (isInt)
+ {
+ TintMap::const_iterator it = intMap.begin();
+ for (; it != intMap.end(); it++)
+ vecSelecteds.push_back( (*it).second);
+ }
+ else if (isReal)
+ {
+ TrealMap::const_iterator it = realMap.begin();
+ for (; it != realMap.end(); it++)
+ vecSelecteds.push_back( (*it).second);
+ }
+ else if (isString)
+ {
+ TstringMap::const_iterator it = stringMap.begin();
+ for (; it != stringMap.end(); it++)
+ vecSelecteds.push_back( (*it).second);
+ }
+
+ return CREATE_ORDEREDSET( GetTypeManager(), vecSelecteds );
+ }
+
+ void Finalize()
+ {
+ intMap.clear();
+ isInt = false;
+ realMap.clear();
+ isReal = false;
+ stringMap.clear();
+ isString = false;
+ OclIterator::Finalize();
+ }
+ };
+ // --
+
void TCollection_AttributeFactory::GetFeatures( const OclSignature::Attribute& signature, OclMeta::AttributeVector& vecFeatures )
{
***************
*** 1227,1230 ****
--- 1339,1351 ----
}
+ // --
+ if ( ( strName == "asOrderedSet" ) && iCount == 0 ) {
+ vecType.push_back( "ocl::OrderedSet" );
+ vecType.push_back( TYPE_AGGREGATED_OBJECT );
+ vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TCollection_AsOrderedSet(), false ) );
+ return;
+ }
+ // --
+
if ( ( strName == "asSequence" ) && iCount == 0 ) {
vecType.push_back( "ocl::Sequence" );
***************
*** 1269,1272 ****
--- 1390,1401 ----
return;
}
+ // --
+ if ( strName == "sortedBy" ) {
+ vecType.push_back( "ocl::OrderedSet" );
+ vecType.push_back( TYPE_AGGREGATED_OBJECT ); // ??
+ vecFeatures.push_back( new OclMeta::Iterator( strName, "ocl::Any", vecType, new TCollection_SortedBy(), false ) );
+ return;
+ }
+ // --
}
***************
*** 1277,1281 ****
//##############################################################################################################################################
! OPERATOR( TSet_Plus )
{
void operator()()
--- 1406,1410 ----
//##############################################################################################################################################
! OPERATOR( TSet_Plus ) // unio Set
{
void operator()()
***************
*** 1292,1296 ****
};
! OPERATOR( TSet_PlusBag )
{
void operator()()
--- 1421,1425 ----
};
! OPERATOR( TSet_PlusBag ) // unio Bag
{
void operator()()
***************
*** 1304,1308 ****
};
! OPERATOR( TSet_Times )
{
void operator()()
--- 1433,1437 ----
};
! OPERATOR( TSet_Times ) // intersection
{
void operator()()
***************
*** 1314,1318 ****
OclMeta::Object object = spIterator->GetNext();
if ( find( collThis.begin(), collThis.end(), object ) != collThis.end() )
! if ( find( collOut.begin(), collOut.end(), object ) == collOut.end() )
collOut.push_back( object );
}
--- 1443,1447 ----
OclMeta::Object object = spIterator->GetNext();
if ( find( collThis.begin(), collThis.end(), object ) != collThis.end() )
! if ( find( collOut.begin(), collOut.end(), object ) == collOut.end() ) // unnecessary
collOut.push_back( object );
}
***************
*** 1336,1340 ****
};
! OPERATOR( TSet_Percent )
{
void operator()()
--- 1465,1469 ----
};
! OPERATOR( TSet_Percent ) // symmetricdifference
{
void operator()()
***************
*** 1732,1736 ****
}
OclMeta::ObjectVector collOut;
! for ( long i = lFrom ; i < lTo ; i++ )
collOut.push_back( collThis[ i ] );
SetResult( CREATE_SEQUENCE( GetTypeManager(), collOut ) );
--- 1861,1865 ----
}
OclMeta::ObjectVector collOut;
! for ( long i = lFrom ; i <= lTo ; i++ )
collOut.push_back( collThis[ i ] );
SetResult( CREATE_SEQUENCE( GetTypeManager(), collOut ) );
***************
*** 1970,1973 ****
--- 2099,2111 ----
}
+ if ( ( strName == "subSequence" ) && iCount == 2 ) {
+ vecParams.push_back( FP( "pos", "ocl::Integer", true ) );
+ vecParams.push_back( FP( "pos", "ocl::Integer", true ) );
+ vecType.push_back( "ocl::Sequence" );
+ vecType.push_back( TYPE_ARGUMENT_SELF_BASE );
+ vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TSequence_SubSequence(), false ) );
+ return;
+ }
+
if ( ( strName == "first" ) && iCount == 0 ) {
vecType.push_back( TYPE_AGGREGATED_OBJECT );
***************
*** 2055,2059 ****
//##############################################################################################################################################
! OPERATOR( TBag_Plus )
{
void operator()()
--- 2193,2197 ----
//##############################################################################################################################################
! OPERATOR( TBag_Plus ) // unio
{
void operator()()
***************
*** 2067,2071 ****
};
! OPERATOR( TBag_Times )
{
void operator()()
--- 2205,2209 ----
};
! OPERATOR( TBag_Times ) // intersection Bag
{
void operator()()
***************
*** 2086,2090 ****
};
! OPERATOR( TBag_TimesSet )
{
void operator()()
--- 2224,2228 ----
};
! OPERATOR( TBag_TimesSet ) // intersection Set
{
void operator()()
***************
*** 2356,2359 ****
--- 2494,2834 ----
}
}
+
+
+ // -- OrderedSet inserted here
+ //##############################################################################################################################################
+ //
+ // T Y P E O F ocl::OrderedSet
+ //
+ //##############################################################################################################################################
+
+ METHOD( TOrderedSet_Prepend )
+ {
+ void operator()()
+ {
+ DECL_COLLECTION( collThis, GetThis() );
+ collThis.insert( collThis.begin(), GetArgument( 0 ) );
+ SetResult( CREATE_ORDEREDSET( GetTypeManager(), collThis ) );
+ }
+ };
+
+ METHOD( TOrderedSet_Append )
+ {
+ void operator()()
+ {
+ DECL_COLLECTION( collThis, GetThis() );
+ collThis.push_back( GetArgument( 0 ) );
+ SetResult( CREATE_ORDEREDSET( GetTypeManager(), collThis ) );
+ }
+ };
+
+ METHOD( TOrderedSet_SubOrderedSet)
+ {
+ void operator()()
+ {
+ DECL_COLLECTION( collThis, GetThis() );
+ DECL_INTEGER( lFrom, GetArgument( 0 ) );
+ if ( lFrom < 0 ) {
+ ThrowException( "Argument 'from' is less than 0." );
+ return;
+ }
+ if ( lFrom >= collThis.size() ) {
+ ThrowException( "Argument 'from' equals to or is greater than size of OrderedSet." );
+ return;
+ }
+ if ( GetArgumentCount() == 1 ) {
+ OclMeta::ObjectVector collOut;
+ for ( long i = lFrom ; i < collThis.size() ; i++ )
+ collOut.push_back( collThis[ i ] );
+ SetResult( CREATE_ORDEREDSET( GetTypeManager(), collOut ) );
+ return;
+ }
+ DECL_INTEGER( lTo, GetArgument( 1 ) );
+ if ( lTo < lFrom ) {
+ ThrowException( "Argument 'to' greater than Argument 'from'." );
+ return;
+ }
+ if ( lTo >= collThis.size() ) {
+ ThrowException( "Argument 'to' equals to or is greater than size of OrderedSet." );
+ return;
+ }
+ OclMeta::ObjectVector collOut;
+ for ( long i = lFrom ; i <= lTo ; i++ )
+ collOut.push_back( collThis[ i ] );
+ SetResult( CREATE_ORDEREDSET( GetTypeManager(), collOut ) );
+ }
+ };
+
+ METHOD( TOrderedSet_At )
+ {
+ void operator()()
+ {
+ DECL_COLLECTION( collThis, GetThis() );
+ DECL_INTEGER( lAt, GetArgument( 0 ) );
+ if ( lAt < 0 ) {
+ ThrowException( "Argument 'from' is less than 0." );
+ return;
+ }
+ if ( lAt >= collThis.size() ) {
+ ThrowException( "Argument 'from' equals to or is greater than size of OrederedSet." );
+ return;
+ }
+ SetResult( collThis[ lAt ] );
+ }
+ };
+
+ METHOD( TOrderedSet_InsertAt )
+ {
+ void operator()()
+ {
+ DECL_COLLECTION( collThis, GetThis() );
+ DECL_INTEGER( lAt, GetArgument( 0 ) );
+ if ( lAt < 0 )
+ lAt = 0;
+ if ( lAt >= collThis.size() ) {
+ collThis.push_back( GetArgument( 1 ) );
+ SetResult( CREATE_ORDEREDSET( GetTypeManager(), collThis ) );
+ return;
+ }
+ OclMeta::ObjectVector vecOut;
+ for ( int i = 0 ; i < collThis.size() ; i++ ) {
+ if ( i == lAt )
+ vecOut.push_back( GetArgument( 1 ) );
+ vecOut.push_back( collThis[ i ] );
+ }
+ SetResult( CREATE_ORDEREDSET( GetTypeManager(), vecOut ) );
+ }
+ };
+
+ METHOD( TOrderedSet_IndexOf )
+ {
+ void operator()()
+ {
+ DECL_COLLECTION( collThis, GetThis() );
+ for ( int i = 0 ; i < collThis.size() ; i ++ )
+ if ( collThis[ i ] == GetArgument( 0 ) ) {
+ SetResult( CREATE_INTEGER( GetTypeManager(), i ) );
+ return;
+ }
+ SetResult( CREATE_INTEGER( GetTypeManager(), -1 ) );
+ }
+ };
+
+ METHOD( TOrderedSet_First )
+ {
+ void operator()()
+ {
+ DECL_COLLECTION( collThis, GetThis() );
+ if ( collThis.empty() ) {
+ ThrowException( "Sequence is empty." );
+ return;
+ }
+ SetResult( collThis[ 0 ] );
+ }
+ };
+
+ METHOD( TOrderedSet_Last )
+ {
+ void operator()()
+ {
+ DECL_COLLECTION( collThis, GetThis() );
+ if ( collThis.empty() ) {
+ ThrowException( "Sequence is empty." );
+ return;
+ }
+ SetResult( collThis[ collThis.size() - 1 ] );
+ }
+ };
+
+
+ ITERATOR( TOrderedSet_Select )
+ {
+ private :
+ OclMeta::ObjectVector m_vecSelecteds;
+
+ void Initialize()
+ {
+ OclIterator::Initialize();
+ m_vecSelecteds.clear();
+ }
+
+ void operator()()
+ {
+ if ( ! GetSubResult().IsUndefined() ) {
+ DECL_BOOLEAN( bArg, GetSubResult() );
+ if ( bArg )
+ m_vecSelecteds.push_back( GetArgument( 0 ) );
+ }
+ }
+
+ OclMeta::Object GetResult() const
+ {
+ return CREATE_ORDEREDSET( GetTypeManager(), m_vecSelecteds );
+ }
+
+ void Finalize()
+ {
+ m_vecSelecteds.clear();
+ OclIterator::Finalize();
+ }
+ };
+
+ ITERATOR( TOrderedSet_Reject )
+ {
+ private :
+ OclMeta::ObjectVector m_vecSelecteds;
+
+ void Initialize()
+ {
+ OclIterator::Initialize();
+ m_vecSelecteds.clear();
+ }
+
+ void operator()()
+ {
+ if ( ! GetSubResult().IsUndefined() ) {
+ DECL_BOOLEAN( bArg, GetSubResult() );
+ if ( ! bArg )
+ m_vecSelecteds.push_back( GetArgument( 0 ) );
+ }
+ }
+
+ OclMeta::Object GetResult() const
+ {
+ return CREATE_ORDEREDSET( GetTypeManager(), m_vecSelecteds );
+ }
+
+ void Finalize()
+ {
+ m_vecSelecteds.clear();
+ OclIterator::Finalize();
+ }
+ };
+
+ ITERATOR( TOrderedSet_Collect )
+ {
+ private :
+ OclMeta::ObjectVector m_vecSelecteds;
+
+ void Initialize()
+ {
+ OclIterator::Initialize();
+ m_vecSelecteds.clear();
+ }
+
+ void operator()()
+ {
+ m_vecSelecteds.push_back( GetSubResult() );
+ }
+
+ OclMeta::Object GetResult() const
+ {
+ return CREATE_BAG( GetTypeManager(), m_vecSelecteds );
+ }
+
+ void Finalize()
+ {
+ m_vecSelecteds.clear();
+ OclIterator::Finalize();
+ }
+ };
+
+ void TOrderedSet_MethodFactory::GetFeatures( const OclSignature::Method& signature, OclMeta::MethodVector& vecFeatures )
+ {
+ string strName = signature.GetName();
+ int iCount = signature.GetParameterCount();
+ FPV vecParams;
+ TS vecType;
+
+ if ( ( strName == "prepend" ) && iCount == 1 ) {
+ vecParams.push_back( FP( "any", "ocl::Any", true ) );
+ vecType.push_back( "ocl::OrderedSet" );
+ vecType.push_back( TYPE_ARGUMENT_SELF_BASE );
+ vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TOrderedSet_Prepend(), false ) );
+ return;
+ }
+
+ if ( ( strName == "append" ) && iCount == 1 ) {
+ vecParams.push_back( FP( "any", "ocl::Any", true ) );
+ vecType.push_back( "ocl::OrderedSet" );
+ vecType.push_back( TYPE_ARGUMENT_SELF_BASE );
+ vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TOrderedSet_Append(), false ) );
+ return;
+ }
+
+ if ( ( strName == "subOrderedSet" ) && iCount == 2 ) {
+ vecParams.push_back( FP( "pos", "ocl::Integer", true ) );
+ vecParams.push_back( FP( "pos", "ocl::Integer", true ) );
+ vecType.push_back( "ocl::OrderedSet" );
+ vecType.push_back( TYPE_ARGUMENT_SELF_BASE );
+ vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TOrderedSet_SubOrderedSet(), false ) );
+ return;
+ }
+
+ if ( ( strName == "first" ) && iCount == 0 ) {
+ vecType.push_back( TYPE_AGGREGATED_OBJECT );
+ vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TOrderedSet_First(), false ) );
+ return;
+ }
+
+ if ( ( strName == "last" ) && iCount == 0 ) {
+ vecType.push_back( TYPE_AGGREGATED_OBJECT );
+ vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TOrderedSet_Last(), false ) );
+ return;
+ }
+
+ if ( ( strName == "at" ) && iCount == 1 ) {
+ vecParams.push_back( FP( "pos", "ocl::Integer", true ) );
+ vecType.push_back( TYPE_AGGREGATED_OBJECT );
+ vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TOrderedSet_At(), false ) );
+ return;
+ }
+
+ if ( ( strName == "indexOf" ) && iCount == 1 ) {
+ vecParams.push_back( FP( "any", "ocl::Any", true ) );
+ vecType.push_back( "ocl::Integer" );
+ vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TOrderedSet_IndexOf(), false ) );
+ return;
+ }
+
+ if ( ( strName == "insertAt" ) && iCount == 2 ) {
+ vecParams.push_back( FP( "pos", "ocl::Integer", true ) );
+ vecParams.push_back( FP( "any", "ocl::Any", true ) );
+ vecType.push_back( "ocl::OrderedSet" );
+ vecType.push_back( TYPE_ARGUMENT_SELF_BASE );
+ vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TOrderedSet_InsertAt(), false ) );
+ return;
+ }
+
+ }
+
+ void TOrderedSet_IteratorFactory::GetFeatures( const OclSignature::Iterator& signature, OclMeta::IteratorVector& vecFeatures )
+ {
+ string strName = signature.GetName();
+ TS vecType;
+
+ if ( strName == "select" ) {
+ vecType.push_back( "ocl::OrderedSet" );
+ vecType.push_back( TYPE_AGGREGATED_OBJECT );
+ vecFeatures.push_back( new OclMeta::Iterator( strName, "ocl::Boolean", vecType, new TOrderedSet_Select(), false ) );
+ return;
+ }
+
+ if ( strName == "reject" ) {
+ vecType.push_back( "ocl::OrderedSet" );
+ vecType.push_back( TYPE_AGGREGATED_OBJECT );
+ vecFeatures.push_back( new OclMeta::Iterator( strName, "ocl::Boolean", vecType, new TOrderedSet_Reject(), false ) );
+ return;
+ }
+
+ if ( strName == "collect" ) {
+ vecType.push_back( "ocl::OrderedSet" );
+ vecType.push_back( TYPE_EXPRESSION_RETURN );
+ vecFeatures.push_back( new OclMeta::Iterator( strName, "ocl::Any", vecType, new TOrderedSet_Collect(), false ) );
+ return;
+ }
+ }
+
+
//##############################################################################################################################################
Index: OCLTree.cpp
===================================================================
RCS file: /var/lib/gme/GMESRC/GME/ConstraintManager/OCLTree.cpp,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -d -r1.26 -r1.27
*** OCLTree.cpp 17 Aug 2004 21:59:10 -0000 1.26
--- OCLTree.cpp 13 Sep 2004 14:14:53 -0000 1.27
***************
*** 1358,1366 ****
if ( iDeclNum == m_vecDeclarators.size() - 1 ) {
EVALTRY {
! OclMeta::Object spAccu = m_pArgumentNode->Evaluate( context );
if ( ! m_pAccuNode ) {
pIIterator->SetArguments( vecArguments );
pIIterator->SetSubResult( spAccu );
! (*pIIterator)();
if ( pIIterator->DoStop() )
bDoStop = true;
--- 1358,1367 ----
if ( iDeclNum == m_vecDeclarators.size() - 1 ) {
EVALTRY {
! OclMeta::Object spAccu = m_pArgumentNode->Evaluate( context ); // evaluate the argument
if ( ! m_pAccuNode ) {
pIIterator->SetArguments( vecArguments );
pIIterator->SetSubResult( spAccu );
! pIIterator->SetSubOriResult( objectIter );
! (*pIIterator)();
if ( pIIterator->DoStop() )
bDoStop = true;
***************
*** 2674,2678 ****
bool CollectionNodeAdaptor::Check( TypeContext& context, CollectionNode* pNode ) const
{
! if ( pNode->m_strType == "Set" || pNode->m_strType == "Sequence" || pNode->m_strType == "Bag" )
pNode->m_strType = "ocl::" + pNode->m_strType;
--- 2675,2679 ----
bool CollectionNodeAdaptor::Check( TypeContext& context, CollectionNode* pNode ) const
{
! if ( pNode->m_strType == "Set" || pNode->m_strType == "Sequence" || pNode->m_strType == "Bag" || pNode->m_strType == "OrderedSet" )
pNode->m_strType = "ocl::" + pNode->m_strType;
***************
*** 2690,2694 ****
// Check if this adaptor can create Compound Object
! if ( ! ( pNode->m_vecType[ 0 ] == "ocl::Set" || pNode->m_vecType[ 0 ] == "ocl::Sequence" || pNode->m_vecType[ 0 ] == "ocl::Bag" ) ) {
ADDEX( EXCEPTION1( EX_CANNOT_CREATE_COLLECTION, pNode->m_strType, pNode->m_mapPositions[ LID_NODE_START ] ) );
bValid = false;
--- 2691,2695 ----
// Check if this adaptor can create Compound Object
! if ( ! ( pNode->m_vecType[ 0 ] == "ocl::Set" || pNode->m_vecType[ 0 ] == "ocl::Sequence" || pNode->m_vecType[ 0 ] == "ocl::Bag" || pNode->m_vecType[ 0 ] == "ocl::OrderedSet" ) ) {
ADDEX( EXCEPTION1( EX_CANNOT_CREATE_COLLECTION, pNode->m_strType, pNode->m_mapPositions[ LID_NODE_START ] ) );
bValid = false;
***************
*** 2734,2737 ****
--- 2735,2740 ----
if ( pNode->m_vecType[ 0 ] == "ocl::Sequence" )
return CREATE_SEQUENCE( pNode->GetTreeManager()->GetTypeManager(), vecObjects );
+ if ( pNode->m_vecType[ 0 ] == "ocl::OrderedSet" )
+ return CREATE_ORDEREDSET( pNode->GetTreeManager()->GetTypeManager(), vecObjects );
return OclMeta::Object::UNDEFINED;
Index: OCLObjectExBasic.h
===================================================================
RCS file: /var/lib/gme/GMESRC/GME/ConstraintManager/OCLObjectExBasic.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** OCLObjectExBasic.h 11 Nov 2002 04:11:00 -0000 1.3
--- OCLObjectExBasic.h 13 Sep 2004 14:14:53 -0000 1.4
***************
*** 93,106 ****
OclMeta::Object( new OclBasic::Bag( pManager, bagValue ) )
#define DECL_COLLECTION( varName, var2Name ) \
OclMeta::ObjectVector varName; \
if ( ! var2Name.IsUndefined() ) { \
! if ( var2Name.GetTypeName() == "ocl::Set" ) \
( ( OclBasic::Set* ) var2Name.GetImplementation() )->GetValue( varName ); \
else if ( var2Name.GetTypeName() == "ocl::Bag" ) \
( ( OclBasic::Bag* ) var2Name.GetImplementation() )->GetValue( varName ); \
! else \
( ( OclBasic::Sequence* ) var2Name.GetImplementation() )->GetValue( varName ); \
! }
#define DECL_COLLECTION2( varName, var2Name ) \
--- 93,111 ----
OclMeta::Object( new OclBasic::Bag( pManager, bagValue ) )
+ #define CREATE_ORDEREDSET( pManager, osetValue ) \
+ OclMeta::Object( new OclBasic::OrderedSet( pManager, osetValue ) )
+
#define DECL_COLLECTION( varName, var2Name ) \
OclMeta::ObjectVector varName; \
if ( ! var2Name.IsUndefined() ) { \
! if ( var2Name.GetTypeName() == "ocl::Set" ) \
( ( OclBasic::Set* ) var2Name.GetImplementation() )->GetValue( varName ); \
else if ( var2Name.GetTypeName() == "ocl::Bag" ) \
( ( OclBasic::Bag* ) var2Name.GetImplementation() )->GetValue( varName ); \
! else if ( var2Name.GetTypeName() == "ocl::Sequence" ) \
( ( OclBasic::Sequence* ) var2Name.GetImplementation() )->GetValue( varName ); \
! else \
! ( ( OclBasic::OrderedSet* ) var2Name.GetImplementation() )->GetValue( varName ); \
! }
#define DECL_COLLECTION2( varName, var2Name ) \
***************
*** 110,115 ****
else if ( var2Name.GetTypeName() == "ocl::Bag" ) \
( ( OclBasic::Bag* ) var2Name.GetImplementation() )->GetValue( varName ); \
! else \
( ( OclBasic::Sequence* ) var2Name.GetImplementation() )->GetValue( varName ); \
}
--- 115,122 ----
else if ( var2Name.GetTypeName() == "ocl::Bag" ) \
( ( OclBasic::Bag* ) var2Name.GetImplementation() )->GetValue( varName ); \
! else if ( var2Name.GetTypeName() == "ocl::Sequence" ) \
( ( OclBasic::Sequence* ) var2Name.GetImplementation() )->GetValue( varName ); \
+ else \
+ ( ( OclBasic::OrderedSet* ) var2Name.GetImplementation() )->GetValue( varName ); \
}
***************
*** 442,445 ****
--- 449,493 ----
bool operator==( const Sequence& object ) const;
bool operator!=( const Sequence& object ) const;
+
+ virtual void AddObject( const OclMeta::Object& object );
+ virtual OclImplementation::ObjectIterator* GetIterator();
+
+ virtual string Print() const;
+ };
+
+ //##############################################################################################################################################
+ //
+ // C L A S S : OclBasic::OrderedSet <<< + OclBasic::Collection
+ //
+ //==============================================================================================================================================
+ //
+ // D E S C R I P T I O N :
+ //
+ //##############################################################################################################################################
+
+ class OrderedSet
+ : public Set
+ {
+ private :
+ OclMeta::ObjectVector m_vecObjects;
+ void * m_pArgNode;
+
+ protected :
+ OrderedSet( OclMeta::TypeManager* pManager, const string& strTypeName );
+ OrderedSet( OclMeta::TypeManager* pManager, const string& strTypeName, const OclMeta::ObjectVector& vecObjects );
+ public :
+ OrderedSet( OclMeta::TypeManager* pManager );
+ OrderedSet( OclMeta::TypeManager* pManager, const OclMeta::ObjectVector& vecObjects );
+ virtual Any* Clone() const;
+
+ void GetValue( OclMeta::ObjectVector& value ) const;
+ void SetValue( const OclMeta::ObjectVector& value );
+
+ // void SetArgNode(void *arg);
+ // void GetArgNode(void * &arg);
+
+ virtual bool Equals( const Any& object ) const;
+ bool operator==( const OrderedSet& object ) const;
+ bool operator!=( const OrderedSet& object ) const;
virtual void AddObject( const OclMeta::Object& object );
Index: OCLObjectExBasic.cpp
===================================================================
RCS file: /var/lib/gme/GMESRC/GME/ConstraintManager/OCLObjectExBasic.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** OCLObjectExBasic.cpp 18 May 2004 13:30:58 -0000 1.6
--- OCLObjectExBasic.cpp 13 Sep 2004 14:14:53 -0000 1.7
***************
*** 671,673 ****
--- 671,767 ----
}
+ //##############################################################################################################################################
+ //
+ // C L A S S : OclBasic::OrderedSet <<< + OclBasic::Collection
+ //
+ //##############################################################################################################################################
+
+ OrderedSet::OrderedSet( OclMeta::TypeManager* pManager, const string& strTypeName )
+ : Set( pManager, strTypeName )
+ {
+ m_pArgNode = NULL;
+ }
+
+ OrderedSet::OrderedSet( OclMeta::TypeManager* pManager, const string& strTypeName, const OclMeta::ObjectVector& vecObjects )
+ : Set( pManager, strTypeName )
+ {
+ for ( int i = 0 ; i < vecObjects.size() ; i++ )
+ AddObject( vecObjects[ i ] );
+ m_pArgNode = NULL;
+ }
+
+ OrderedSet::OrderedSet( OclMeta::TypeManager* pManager )
+ : Set( pManager, "ocl::OrderedSet" )
+ {
+ m_pArgNode = NULL;
+ }
+
+ OrderedSet::OrderedSet( OclMeta::TypeManager* pManager, const OclMeta::ObjectVector& vecObjects )
+ : Set( pManager, "ocl::OrderedSet" )
+ {
+ for ( int i = 0 ; i < vecObjects.size() ; i++ )
+ AddObject( vecObjects[ i ] );
+ m_pArgNode = NULL;
+ }
+
+ Any* OrderedSet::Clone() const
+ {
+ return new OrderedSet( GetTypeManager(), m_vecObjects );
+ }
+
+ void OrderedSet::GetValue( OclMeta::ObjectVector& value ) const
+ {
+ value = m_vecObjects;
+ }
+
+ void OrderedSet::SetValue( const OclMeta::ObjectVector& value )
+ {
+ for ( int i = 0 ; i < value.size() ; i++ )
+ AddObject( value[ i ] );
+ }
+
+ bool OrderedSet::Equals( const Any& object ) const
+ {
+ if ( GetTypeManager()->IsTypeA( object.GetTypeName(), "ocl::OrderedSet" ) >= 0 ) {
+ OclMeta::ObjectVector vecObjects = ( ( OrderedSet* ) &object )->m_vecObjects;
+ if ( m_vecObjects.size() != vecObjects.size() )
+ return false;
+ for ( int i = 0 ; i < m_vecObjects.size() ; i++ )
+ {
+ if ( m_vecObjects[ i ] != vecObjects[ i ] )
+ return false;
+ }
+ return true;
+ }
+ else
+ return false;
+ }
+
+ bool OrderedSet::operator==( const OrderedSet& object ) const
+ {
+ return Equals( object );
+ }
+
+ bool OrderedSet::operator!=( const OrderedSet& object ) const
+ {
+ return ! ( *this == object );
+ }
+
+ void OrderedSet::AddObject( const OclMeta::Object& object )
+ {
+ OclMeta::ObjectVector::iterator i = find( m_vecObjects.begin(), m_vecObjects.end(), object );
+ if ( i == m_vecObjects.end() )
+ m_vecObjects.push_back( object );
+ }
+
+ OclImplementation::ObjectIterator* OrderedSet::GetIterator()
+ {
+ return new ObjectIterator( m_vecObjects.begin(), m_vecObjects.end() );
+ }
+
+ string OrderedSet::Print() const
+ {
+ return PrintCollection( GetTypeName(), m_vecObjects );
+ }
+
}; // namespace OclBasic
Index: OCLObject.h
===================================================================
RCS file: /var/lib/gme/GMESRC/GME/ConstraintManager/OCLObject.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** OCLObject.h 14 Jun 2004 20:28:23 -0000 1.3
--- OCLObject.h 13 Sep 2004 14:14:53 -0000 1.4
***************
*** 62,65 ****
--- 62,66 ----
void SetStaticTypeName( const string& strStaticTypeName );
bool IsCompound() const;
+ bool IsComparable() const;
bool IsUndefined() const;
OclImplementation::Object* GetImplementation() const;
***************
*** 113,116 ****
--- 114,125 ----
virtual bool IsCompound() const
{
+ return false;
+ }
+
+ virtual bool IsComparable() const
+ {
+ if (m_strTypeName == "ocl::Integer" || m_strTypeName == "ocl::Real" ||
+ m_strTypeName == "ocl::String")
+ return true;
return false;
}
Index: OCLObject.cpp
===================================================================
RCS file: /var/lib/gme/GMESRC/GME/ConstraintManager/OCLObject.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** OCLObject.cpp 14 Jun 2004 20:28:23 -0000 1.6
--- OCLObject.cpp 13 Sep 2004 14:14:53 -0000 1.7
***************
*** 92,95 ****
--- 92,102 ----
}
+ bool Object::IsComparable() const
+ {
+ if ( IsUndefined() )
+ return false;
+ return Ptr()->IsComparable();
+ }
+
bool Object::IsUndefined() const
{
Index: OCLFeatureImplementation.h
===================================================================
RCS file: /var/lib/gme/GMESRC/GME/ConstraintManager/OCLFeatureImplementation.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** OCLFeatureImplementation.h 14 Jun 2004 20:28:23 -0000 1.5
--- OCLFeatureImplementation.h 13 Sep 2004 14:14:53 -0000 1.6
***************
*** 199,202 ****
--- 199,203 ----
private :
OclMeta::Object m_Next;
+ OclMeta::Object m_NextOri;
bool m_bStopped;
bool m_bDoSnapShot;
***************
*** 204,211 ****
public :
virtual void Initialize() { m_bDoSnapShot = false; m_bStopped = false; }
! void SetSubResult( const OclMeta::Object& object ) { m_Next = object; }
! OclMeta::Object GetSubResult() const { return m_Next; }
bool DoSnapshot() const { return m_bDoSnapShot; }
! void SetDoSnapshot( bool bDo ) { m_bDoSnapShot = bDo; }
bool DoStop() const { return m_bStopped; }
void SetDoStop( bool bDo ) { m_bStopped = bDo; }
--- 205,214 ----
public :
virtual void Initialize() { m_bDoSnapShot = false; m_bStopped = false; }
! void SetSubResult( const OclMeta::Object& object ) { m_Next = object; }
! void SetSubOriResult( const OclMeta::Object& oriobject ) { m_NextOri = oriobject; }
! OclMeta::Object GetSubResult() const { return m_Next; }
! OclMeta::Object GetSubOriResult() const { return m_NextOri; }
bool DoSnapshot() const { return m_bDoSnapShot; }
! void SetDoSnapshot( bool bDo ) { m_bDoSnapShot = bDo; }
bool DoStop() const { return m_bStopped; }
void SetDoStop( bool bDo ) { m_bStopped = bDo; }
Index: ConstraintManager.dsp
===================================================================
RCS file: /var/lib/gme/GMESRC/GME/ConstraintManager/ConstraintManager.dsp,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** ConstraintManager.dsp 24 Jul 2004 06:41:53 -0000 1.21
--- ConstraintManager.dsp 13 Sep 2004 14:14:53 -0000 1.22
***************
*** 80,84 ****
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MD /W3 /GX /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_WINDLL" /D "_AFXDLL" /D "_MBCS" /D "_USRDLL" /D "_ATL_STATIC_REGISTRY" /Yu"stdafx.h" /FD /c
! # ADD CPP /nologo /MD /W3 /GX /Zi /O1 /I "../Common" /I "../interfaces" /I "../include/STL" /I "." /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_WINDLL" /D "_AFXDLL" /D "_MBCS" /D "_USRDLL" /D "_ATL_STATIC_REGISTRY" /FD /c
# SUBTRACT CPP /YX /Yc /Yu
# ADD BASE RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL"
--- 80,84 ----
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MD /W3 /GX /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_WINDLL" /D "_AFXDLL" /D "_MBCS" /D "_USRDLL" /D "_ATL_STATIC_REGISTRY" /Yu"stdafx.h" /FD /c
! # ADD CPP /nologo /MD /W3 /GX /Zi /O1 /I "../Common" /I "../interfaces" /I "../include/STL" /I "." /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_WINDLL" /D "_AFXDLL" /D "_MBCS" /D "_USRDLL" /D "_ATL_STATIC_REGISTRY" /FR /FD /c
# SUBTRACT CPP /YX /Yc /Yu
# ADD BASE RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL"
***************
*** 90,94 ****
# ADD BASE LINK32 /nologo /subsystem:windows /dll /machine:I386
# ADD LINK32 /nologo /base:"0x60200000" /subsystem:windows /dll /map /debug /machine:I386
- # SUBTRACT LINK32 /pdbtype:<none>
# Begin Custom Build - Performing registration
OutDir=.\Release
--- 90,93 ----
More information about the GME-commit
mailing list