|
From: Frank V. C. <fr...@us...> - 2001-04-22 14:30:54
|
Update of /cvsroot/corelinux/clfw/src/libs/Persist
In directory usw-pr-cvs1:/tmp/cvs-serv13712/src/libs/Persist
Modified Files:
Makefile.am SchemaAbstractStore.cpp SchemaCatStore.cpp
SchemaCatalog.cpp SchemaStore.cpp
Added Files:
SchemaDataDescriptor.cpp
Log Message:
Refined schema store operations and objects
***** Error reading new file: [Errno 2] No such file or directory: 'SchemaDataDescriptor.cpp'
Index: Makefile.am
===================================================================
RCS file: /cvsroot/corelinux/clfw/src/libs/Persist/Makefile.am,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** Makefile.am 2001/04/17 09:59:43 1.6
--- Makefile.am 2001/04/22 14:30:51 1.7
***************
*** 14,25 ****
noinst_LTLIBRARIES = libclfwp.la
! libclfwp_la_SOURCES = \
! StoreSponsor.cpp \
! StoreCatalog.cpp \
! Store.cpp \
! SchemaSponsor.cpp \
! SchemaCatalog.cpp \
! SchemaAbstractStore.cpp \
! SchemaCatStore.cpp \
SchemaStore.cpp
--- 14,26 ----
noinst_LTLIBRARIES = libclfwp.la
! libclfwp_la_SOURCES = \
! StoreSponsor.cpp \
! StoreCatalog.cpp \
! Store.cpp \
! SchemaDataDescriptor.cpp \
! SchemaSponsor.cpp \
! SchemaCatalog.cpp \
! SchemaAbstractStore.cpp \
! SchemaCatStore.cpp \
SchemaStore.cpp
Index: SchemaAbstractStore.cpp
===================================================================
RCS file: /cvsroot/corelinux/clfw/src/libs/Persist/SchemaAbstractStore.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** SchemaAbstractStore.cpp 2001/04/21 21:39:01 1.3
--- SchemaAbstractStore.cpp 2001/04/22 14:30:51 1.4
***************
*** 148,162 ****
REQUIRE( theHandle != NULLPTR );
datum key = {aKey, strlen(aKey)+1};
! datum keyd = {aDesc.data,aDesc.dataSize};
gdbm_store((GDBM_FILE)theHandle,key,keyd,GDBM_REPLACE);
}
//
// Fetch a record
//
! SchemaDataDescriptor SchemaAbstractStore::fetchDesc( CharPtr aKey )
{
REQUIRE( theHandle != NULLPTR );
--- 148,180 ----
REQUIRE( theHandle != NULLPTR );
datum key = {aKey, strlen(aKey)+1};
! datum keyd = {aDesc.getBuffer(), aDesc.getBufferSize()};
gdbm_store((GDBM_FILE)theHandle,key,keyd,GDBM_REPLACE);
}
+ void SchemaAbstractStore::updateDesc
+ (
+ CharPtr aKey,
+ Int aSize,
+ CharPtr aBuffer
+ )
+ {
+ REQUIRE( theHandle != NULLPTR );
+ datum key = {aKey, strlen(aKey)+1};
+ datum keyd = {aBuffer,aSize};
+
+ gdbm_store((GDBM_FILE)theHandle,key,keyd,GDBM_REPLACE);
+ }
+
//
// Fetch a record
//
! void SchemaAbstractStore::fetchDesc
! (
! CharPtr aKey,
! SchemaDataDescriptorRef ad
! )
{
REQUIRE( theHandle != NULLPTR );
***************
*** 164,169 ****
datum res = gdbm_fetch((GDBM_FILE)theHandle,key);
! SchemaDataDescriptor ad = { res.dptr,res.dsize };
! return ad;
}
--- 182,186 ----
datum res = gdbm_fetch((GDBM_FILE)theHandle,key);
! ad.setDescriptor( res.dsize, res.dptr );
}
***************
*** 172,199 ****
//
! SchemaDataDescriptor SchemaAbstractStore::fetchDesc
(
! SchemaDataDescriptorCref aKey
)
{
REQUIRE( theHandle != NULLPTR );
! datum key = { aKey.data, aKey.dataSize };
datum res = gdbm_fetch((GDBM_FILE)theHandle,key);
!
! SchemaDataDescriptor ad = { res.dptr,res.dsize };
! return ad;
}
! SchemaDataDescriptor SchemaAbstractStore::fetchFirstKey( void )
{
REQUIRE( theHandle != NULLPTR );
datum key = gdbm_firstkey( (GDBM_FILE)theHandle );
! SchemaDataDescriptor ad = {key.dptr, key.dsize};
! return ad;
}
! SchemaDataDescriptor SchemaAbstractStore::fetchNextKey
(
! SchemaDataDescriptorCref aKey
)
{
--- 189,216 ----
//
! void SchemaAbstractStore::fetchDesc
(
! SchemaDataDescriptorCref aKey,
! SchemaDataDescriptorRef ad
!
)
{
REQUIRE( theHandle != NULLPTR );
! datum key = { aKey.getBuffer(), aKey.getBufferSize() };
datum res = gdbm_fetch((GDBM_FILE)theHandle,key);
! ad.setDescriptor( res.dsize, res.dptr );
}
! void SchemaAbstractStore::fetchFirstKey( SchemaDataDescriptorRef ad )
{
REQUIRE( theHandle != NULLPTR );
datum key = gdbm_firstkey( (GDBM_FILE)theHandle );
! ad.setDescriptor( key.dsize, key.dptr );
}
! void SchemaAbstractStore::fetchNextKey
(
! SchemaDataDescriptorCref aKey,
! SchemaDataDescriptorRef ad
)
{
***************
*** 202,209 ****
(
(GDBM_FILE)theHandle,
! (datum){aKey.data, aKey.dataSize}
);
! SchemaDataDescriptor ad = {nextKey.dptr, nextKey.dsize};
! return ad;
}
--- 219,225 ----
(
(GDBM_FILE)theHandle,
! (datum){aKey.getBuffer(), aKey.getBufferSize()}
);
! ad.setDescriptor( nextKey.dsize, nextKey.dptr );
}
Index: SchemaCatStore.cpp
===================================================================
RCS file: /cvsroot/corelinux/clfw/src/libs/Persist/SchemaCatStore.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** SchemaCatStore.cpp 2001/04/21 21:39:01 1.5
--- SchemaCatStore.cpp 2001/04/22 14:30:51 1.6
***************
*** 168,176 ****
if( this->hasKey( gPrimaryKey ) == true )
{
! aSd = SchemaAbstractStore::fetchDesc( gPrimaryKey );
! if( aSd.data != NULLPTR )
{
! theDescriptor = *(CatalogDescriptorPtr(aSd.data));
! std::free( aSd.data );
}
else
--- 168,175 ----
if( this->hasKey( gPrimaryKey ) == true )
{
! SchemaAbstractStore::fetchDesc( gPrimaryKey, aSd );
! if( aSd.getBuffer() != NULLPTR )
{
! theDescriptor = *(CatalogDescriptorPtr(aSd.getBuffer()));
}
else
***************
*** 187,193 ****
else
{
! aSd.data = CharPtr(&gDefFirst);
! aSd.dataSize = sizeof( CatalogDescriptor );
! SchemaAbstractStore::updateDesc( gPrimaryKey,aSd );
}
}
--- 186,195 ----
else
{
! SchemaAbstractStore::updateDesc
! (
! gPrimaryKey,
! sizeof( CatalogDescriptor ),
! CharPtr(&gDefFirst)
! );
}
}
***************
*** 230,238 ****
if( aPtr == NULLPTR || aPtr->isEmpty() == true )
{
! SchemaDataDescriptor aKey = SchemaAbstractStore::fetchFirstKey();
! while( aKey.data != NULLPTR )
{
UniversalIdentifier aTst;
! aTst = aKey.data;
// if we have a true schema key
--- 232,241 ----
if( aPtr == NULLPTR || aPtr->isEmpty() == true )
{
! SchemaDataDescriptor aKey;
! SchemaAbstractStore::fetchFirstKey(aKey);
! while( aKey.getBuffer() != NULLPTR )
{
UniversalIdentifier aTst;
! aTst = aKey.getBuffer();
// if we have a true schema key
***************
*** 240,247 ****
if( aTst != gPrimaryUid )
{
! SchemaDataDescriptor aDesc =
! SchemaAbstractStore::fetchDesc( aKey );
! if( aDesc.data != NULLPTR )
{
AttributePtr aAtt( Attribute::create() );
--- 243,250 ----
if( aTst != gPrimaryUid )
{
! SchemaDataDescriptor aDesc;
! SchemaAbstractStore::fetchDesc( aKey, aDesc );
! if( aDesc.getBuffer() != NULLPTR )
{
AttributePtr aAtt( Attribute::create() );
***************
*** 253,257 ****
aCollection->put( aAtt );
- free( aDesc.data );
}
else
--- 256,259 ----
***************
*** 268,273 ****
}
! SchemaDataDescriptor nextKey = SchemaAbstractStore::fetchNextKey(aKey);
! free(aKey.data);
aKey = nextKey;
}
--- 270,275 ----
}
! SchemaDataDescriptor nextKey;
! SchemaAbstractStore::fetchNextKey(aKey,nextKey);
aKey = nextKey;
}
***************
*** 328,332 ****
aPtr->getSchemaUid().getAsString( aBuffer );
SchemaAbstractStore::updateDesc( aBuffer, aSd );
- free(aSd.data);
}
--- 330,333 ----
Index: SchemaCatalog.cpp
===================================================================
RCS file: /cvsroot/corelinux/clfw/src/libs/Persist/SchemaCatalog.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -r1.9 -r1.10
*** SchemaCatalog.cpp 2001/04/21 21:39:01 1.9
--- SchemaCatalog.cpp 2001/04/22 14:30:51 1.10
***************
*** 79,82 ****
--- 79,177 ----
//
+ // Local iterator
+ //
+
+ class SchemaCatItr : public Iterator<FrameworkEntityPtr>
+ {
+ public:
+
+ SchemaCatItr( SetCollectionPtr aSet )
+ :
+ Iterator<FrameworkEntityPtr>(),
+ theSet( aSet ),
+ theCurrent( 0 ),
+ theEnd( theSet->getSize() )
+ {
+ ; // do nothing
+ }
+
+ virtual ~SchemaCatItr( void )
+ {
+ theSet = NULLPTR;
+ theCurrent = theEnd = 0;
+ }
+
+ virtual bool isValid( void ) const
+ {
+ return ( theCurrent < theEnd && theCurrent >= 0 );
+ }
+
+ virtual FrameworkEntityPtr getElement( void ) const
+ throw(IteratorBoundsException)
+ {
+ AttributePtr anAttr( NULLPTR );
+
+ if( this->isValid() == true )
+ {
+ anAttr = Attribute::castDown( theSet->getElementAt( theCurrent ) );
+ }
+ else
+ {
+ throw IteratorBoundsException( LOCATION );
+ }
+
+ return anAttr->getKey();
+ }
+
+ virtual void setFirst( void )
+ {
+ theCurrent = 0;
+ }
+
+ virtual void setNext( void ) throw (IteratorBoundsException)
+ {
+ if( theCurrent+1 > theEnd )
+ {
+ throw IteratorBoundsException( LOCATION );
+ }
+ else
+ {
+ ++theCurrent;
+ }
+ }
+
+ virtual void setPrevious( void ) throw (IteratorBoundsException)
+ {
+ if( theCurrent-1 < 0 )
+ {
+ throw IteratorBoundsException( LOCATION );
+ }
+ else
+ {
+ --theCurrent;
+ }
+ }
+
+ virtual void setLast( void ) throw (IteratorBoundsException)
+ {
+ if( theEnd == 0 )
+ {
+ throw IteratorBoundsException( LOCATION );
+ }
+ else
+ {
+ theCurrent = theEnd - 1;
+ }
+ }
+
+ private:
+
+ SetCollectionPtr theSet;
+ Counter theCurrent;
+ Counter theEnd;
+
+ };
+
+ //
// Constructor
//
***************
*** 344,358 ****
}
Iterator<FrameworkEntityPtr> *SchemaCatalog::createCatalogIterator( void )
{
! Iterator<FrameworkEntityPtr> *aItr( NULLPTR );
return aItr;
}
! /// Destroy the iterator over the catalog entries
! void SchemaCatalog::destroyIterator( Iterator<FrameworkEntityPtr> * )
{
!
}
--- 439,459 ----
}
+ //
+ // The iterator over the catalog
+ //
+
Iterator<FrameworkEntityPtr> *SchemaCatalog::createCatalogIterator( void )
{
! Iterator<FrameworkEntityPtr> *aItr( new SchemaCatItr(&theSchemas) );
return aItr;
}
! //
! // Destroy the catalog iterator
! //
! void SchemaCatalog::destroyIterator( Iterator<FrameworkEntityPtr> *aPtr )
{
! delete aPtr;
}
Index: SchemaStore.cpp
===================================================================
RCS file: /cvsroot/corelinux/clfw/src/libs/Persist/SchemaStore.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** SchemaStore.cpp 2001/04/21 21:39:01 1.4
--- SchemaStore.cpp 2001/04/22 14:30:51 1.5
***************
*** 181,186 ****
theSchemaClassId.getAsString( aBase );
! ad.dataSize = totalSize;
! ad.data = CharPtr(aPtr);
return ad;
--- 181,185 ----
theSchemaClassId.getAsString( aBase );
! ad.setDescriptor( totalSize, CharPtr(aPtr) );
return ad;
***************
*** 276,282 ****
//
if( theCreatedFlag == true )
{
! theSchema = this->createSchema();
}
else
--- 275,283 ----
//
+ theSchema = this->createSchema();
+
if( theCreatedFlag == true )
{
! this->write( NULLPTR );
}
else
***************
*** 330,334 ****
void SchemaStore::initialize( SchemaDataDescriptorCref aData )
{
! SchemaDescPtr aDesc( SchemaDescPtr(aData.data) );
Dword maxCnt( aDesc->propcount );
CharPtr aKey( NULLPTR );
--- 331,335 ----
void SchemaStore::initialize( SchemaDataDescriptorCref aData )
{
! SchemaDescPtr aDesc( SchemaDescPtr(aData.getBuffer()) );
Dword maxCnt( aDesc->propcount );
CharPtr aKey( NULLPTR );
***************
*** 442,451 ****
{
//
! // Do they want everything read?
//
if( aPtr == NULLPTR || aPtr->isEmpty() == true )
{
!
}
else
--- 443,453 ----
{
//
! // Do they want just the first part read?
//
+ ArrayPtr anArray( Array::create() );
if( aPtr == NULLPTR || aPtr->isEmpty() == true )
{
! NEVER_GET_HERE;
}
else
***************
*** 454,472 ****
// Perform selected read
//
}
! return aPtr;
}
! void SchemaStore::returnReadCollection( CollectionPtr )
{
}
// Write one or more objects to a store
void SchemaStore::write( CollectionPtr )
{
}
--- 456,554 ----
// Perform selected read
//
+ Counter maxCnt( aPtr->getSize() );
+ for( Counter x = 0; x < maxCnt; ++x )
+ {
+ FrameworkStringPtr aKey
+ (
+ FrameworkString::castDown( aPtr->getElementAt(x) )
+ );
+
+ SchemaDataDescriptorPtr aD(SchemaDataDescriptor::create());
+ this->fetchDesc( aKey->getValue(), *aD );
+ if( aD->getBufferSize() == 0 )
+ {
+ SchemaDataDescriptor::destroy( aD );
+ }
+ else
+ {
+ anArray->put( aD );
+ }
+ }
}
! return anArray;
}
! // Here we just destroy the collection
!
! void SchemaStore::returnReadCollection( CollectionPtr aPtr )
{
+ REQUIRE( aPtr != NULLPTR );
+ Counter maxCnt( aPtr->getSize() );
+ ArrayPtr anArray( Array::castDown( aPtr ) );
+ for( Counter x = 0; x < maxCnt; ++x )
+ {
+ SchemaDataDescriptorPtr aD
+ (
+ SchemaDataDescriptor::castDown( anArray->getElementAt(x) )
+ );
+ SchemaDataDescriptor::destroy( aD );
+ }
+
+ Array::destroy( anArray );
+
}
+ //
// Write one or more objects to a store
+ // Because we have one schema per Schema Store
+ // and that the only user of SchemaStore is
+ // schema catalog, we can ignore the collection
void SchemaStore::write( CollectionPtr )
{
+ //
+ // While we know about theProperties attribute
+ // of Schema, we really should check for other
+ // aspects that have been defined in the instance
+ //
+
+ //
+ // Our collection identifier (Oid) is a key, so we get it
+ // out along with it's type identifier
+ //
+
+ SchemaDataDescriptor ad;
+ CharPtr aPtr( NULLPTR );
+ CollectionPtr aCol( theSchema->getProperties() );
+ Counter aSize( aCol->getSize() );
+ Char key[37];
+
+ Int dSize(sizeof( Dword ) + (sizeof(UniqueId) * 2));
+ ad.setDescriptor(dSize,::new char[dSize]);
+
+
+ // Prepare key
+
+ theSchema->getOid().getAsString( key );
+
+ // And the record
+
+ aPtr = ad.getBuffer();
+
+ *(UniqueIdPtr(aPtr)) = aCol->getOid().getUniqueId();
+ aPtr += sizeof(UniqueId);
+
+ *(UniqueIdPtr(aPtr)) = aCol->getType()->getIdentifier().getUniqueId();
+ aPtr += sizeof(UniqueId);
+
+ *(CounterPtr(aPtr)) = aSize;
+
+ // write this puppy
+
+ this->updateDesc( key, ad );
+
}
***************
*** 514,538 ****
FrameworkEntityPtr aCollection( NULLPTR );
! aClass = Ontology::getClassFor( theCollection.getValue() );
! aClass->dispatch( "Construct" , (void **)NULLPTR,(void *)&aCollection );
!
! if( aCollection == NULLPTR )
{
! throw NullPointerException( theCollection.getValue(), LOCATION );
}
else
{
! aScm->setProperties( Collection::castDown( aCollection ) );
! if( theCreatedFlag == true )
{
! UniversalIdentifier aCID;
! UniversalIdentifier::setNewUid( aCID );
! aCollection->setOid( aCID );
}
else
{
! ; // do nothing, will get read in
}
}
--- 596,670 ----
FrameworkEntityPtr aCollection( NULLPTR );
+ UniversalIdentifier aCID;
! //
! // If we are in for the first time, we construct the
! // collection from the provided (or default) collection
! // type information
! //
!
! if( theCreatedFlag == true )
{
! aClass = Ontology::getClassFor( theCollection.getValue() );
! aClass->dispatch( "Construct" , (void **)NULLPTR,(void *)&aCollection );
!
! UniversalIdentifier::setNewUid( aCID );
}
+
+ //
+ // Otherwise, we read the record from the top
+ // to instantiate the collection
+ //
+
else
{
! Char key[37];
! Array anArray;
! FrameworkString aKey;
!
! theSchemaUid.getAsString(key);
!
! aKey = key;
! anArray.put(&aKey);
! CollectionPtr aResult( this->read(&anArray) );
!
! if( aResult->getSize() == 1 )
{
! UniversalIdentifier aColClass;
! SchemaDataDescriptorPtr aD;
! Counter aSize(0);
!
! aD = SchemaDataDescriptor::castDown( aResult->getElementAt(0) );
!
! CharPtr aColPtr( aD->getBuffer() );
!
! aCID = UniqueIdPtr(aColPtr);
! aColPtr += sizeof(UniqueId);
!
! aColClass = UniqueIdPtr(aColPtr);
! aColPtr += sizeof(UniqueId);
!
! aSize = *(CounterPtr(aColPtr));
!
! aClass = Ontology::getClassFor( aColClass );
! aClass->dispatch( "Construct" , (void **)NULLPTR,(void *)&aCollection );
! this->returnReadCollection( aResult );
}
else
{
! this->returnReadCollection( aResult );
! throw NullPointerException( LOCATION );
}
+
+ }
+
+ if( aCollection == NULLPTR )
+ {
+ throw NullPointerException( LOCATION );
+ }
+ else
+ {
+ aCollection->setOid( aCID );
+ aScm->setProperties( Collection::castDown( aCollection ) );
}
|