|
From: Frank V. C. <fr...@us...> - 2001-04-19 03:44:44
|
Update of /cvsroot/corelinux/clfw/src/libs/Persist
In directory usw-pr-cvs1:/tmp/cvs-serv31108/src/libs/Persist
Modified Files:
SchemaAbstractStore.cpp SchemaCatStore.cpp SchemaCatalog.cpp
SchemaStore.cpp
Log Message:
Final step before schemas go persist
Index: SchemaAbstractStore.cpp
===================================================================
RCS file: /cvsroot/corelinux/clfw/src/libs/Persist/SchemaAbstractStore.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** SchemaAbstractStore.cpp 2001/04/15 16:36:08 1.1
--- SchemaAbstractStore.cpp 2001/04/19 03:44:42 1.2
***************
*** 58,62 ****
//
! bool SchemaAbstractStore::operator==( SchemaAbstractStoreCref aSchemaStore ) const
{
return ( this == &aSchemaStore );
--- 58,65 ----
//
! bool SchemaAbstractStore::operator==
! (
! SchemaAbstractStoreCref aSchemaStore
! ) const
{
return ( this == &aSchemaStore );
***************
*** 67,71 ****
//
! SchemaAbstractStoreRef SchemaAbstractStore::operator=( SchemaAbstractStoreCref )
{
return ( *this );
--- 70,77 ----
//
! SchemaAbstractStoreRef SchemaAbstractStore::operator=
! (
! SchemaAbstractStoreCref
! )
{
return ( *this );
***************
*** 88,95 ****
{
REQUIRE( aName != NULLPTR );
! return (Handle) gdbm_open
(
aName,0, GDBM_READER,0666,NULLPTR
! );
}
--- 94,101 ----
{
REQUIRE( aName != NULLPTR );
! return (Handle) (theHandle = gdbm_open
(
aName,0, GDBM_READER,0666,NULLPTR
! ));
}
***************
*** 97,104 ****
{
REQUIRE( aName != NULLPTR );
! return (Handle) gdbm_open
(
aName,0, GDBM_WRCREAT,0666,NULLPTR
! );
}
--- 103,110 ----
{
REQUIRE( aName != NULLPTR );
! return (Handle) ( theHandle = gdbm_open
(
aName,0, GDBM_WRCREAT,0666,NULLPTR
! ));
}
***************
*** 110,114 ****
bool SchemaAbstractStore::hasKey( CharPtr aKey )
{
! datum key ={aKey, strlen(aKey)};
return gdbm_exists( (GDBM_FILE)theHandle, key );
}
--- 116,121 ----
bool SchemaAbstractStore::hasKey( CharPtr aKey )
{
! REQUIRE( theHandle != NULLPTR );
! datum key ={aKey, strlen(aKey)+1};
return gdbm_exists( (GDBM_FILE)theHandle, key );
}
***************
*** 118,124 ****
//
! void SchemaAbstractStore::updateDesc( CharPtr aKey, SchemaDataDescriptorCref aDesc )
{
! datum key = {aKey, strlen(aKey)};
datum keyd = {aDesc.data,aDesc.dataSize};
--- 125,136 ----
//
! void SchemaAbstractStore::updateDesc
! (
! CharPtr aKey,
! SchemaDataDescriptorCref aDesc
! )
{
! REQUIRE( theHandle != NULLPTR );
! datum key = {aKey, strlen(aKey)+1};
datum keyd = {aDesc.data,aDesc.dataSize};
***************
*** 128,137 ****
//
! // Fetch the toc record
//
SchemaDataDescriptor SchemaAbstractStore::fetchDesc( CharPtr aKey )
{
! datum key = { aKey, strlen(aKey) };
datum res = gdbm_fetch((GDBM_FILE)theHandle,key);
--- 140,167 ----
//
! // Fetch a record
//
SchemaDataDescriptor SchemaAbstractStore::fetchDesc( CharPtr aKey )
+ {
+ REQUIRE( theHandle != NULLPTR );
+ datum key = { aKey, strlen(aKey)+1 };
+ datum res = gdbm_fetch((GDBM_FILE)theHandle,key);
+
+ SchemaDataDescriptor ad = { res.dptr,res.dsize };
+ return ad;
+ }
+
+ //
+ // Fetch a record based on key
+ //
+
+ SchemaDataDescriptor SchemaAbstractStore::fetchDesc
+ (
+ SchemaDataDescriptorCref aKey
+ )
{
! REQUIRE( theHandle != NULLPTR );
! datum key = { aKey.data, aKey.dataSize };
datum res = gdbm_fetch((GDBM_FILE)theHandle,key);
***************
*** 140,143 ****
--- 170,196 ----
}
+ 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
+ )
+ {
+ REQUIRE( theHandle != NULLPTR );
+ datum nextKey = gdbm_nextkey
+ (
+ (GDBM_FILE)theHandle,
+ (datum){aKey.data, aKey.dataSize}
+ );
+ SchemaDataDescriptor ad = {nextKey.dptr, nextKey.dsize};
+ return ad;
+ }
+
//
// MetaType information block
Index: SchemaCatStore.cpp
===================================================================
RCS file: /cvsroot/corelinux/clfw/src/libs/Persist/SchemaCatStore.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** SchemaCatStore.cpp 2001/04/17 09:59:43 1.2
--- SchemaCatStore.cpp 2001/04/19 03:44:42 1.3
***************
*** 29,36 ****
--- 29,44 ----
#endif
+ #if !defined(__SCHEMASTORE_HPP)
+ #include INCL_SchemaStore
+ #endif
+
#if !defined(__FRAMEWORKSTRING_HPP)
#include <clfw/FrameworkString.hpp>
#endif
+ #if !defined(__ATTRIBUTE_HPP)
+ #include <clfw/Attribute.hpp>
+ #endif
+
#if !defined(__DESCRIPTORNOTFOUND_HPP)
#include <clfw/DescriptorNotFound.hpp>
***************
*** 45,49 ****
// Key for actual catalog information
! static CharPtr gPrimaryKey = "62c4c5f4-319d-11d5-88a9-00500489272c";
static CatalogDescriptor gDefFirst = {1,0};
--- 53,58 ----
// Key for actual catalog information
! static CharPtr gPrimaryKey = "62c4c5f4-319d-11d5-88a9-00500489272c";
! static UniversalIdentifier gPrimaryUid( gPrimaryKey );
static CatalogDescriptor gDefFirst = {1,0};
***************
*** 206,209 ****
--- 215,220 ----
CollectionPtr SchemaCatStore::read( CollectionPtr aPtr )
{
+ CollectionPtr aCollection = Array::create();
+
//
// Do they want everything read?
***************
*** 212,216 ****
--- 223,268 ----
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
+
+ if( aTst != gPrimaryUid )
+ {
+ SchemaDataDescriptor aDesc =
+ SchemaAbstractStore::fetchDesc( aKey );
+
+ if( aDesc.data != NULLPTR )
+ {
+ AttributePtr aAtt( Attribute::create() );
+ SchemaStorePtr aVal( SchemaStore::create() );
+ aVal->initialize( aDesc );
+
+ aAtt->setKey( new FrameworkString( aKey.data ) );
+ aAtt->setValue( aVal );
+
+ aCollection->put( aAtt );
+ free( aDesc.data );
+ }
+ else
+ {
+ throw NullPointerException( LOCATION );
+ }
+ }
+
+ // Otherwise ignore
+ else
+ {
+ ; // do nothing
+ }
+
+ SchemaDataDescriptor nextKey = SchemaAbstractStore::fetchNextKey(aKey);
+ free(aKey.data);
+ aKey = nextKey;
+ }
}
else
***************
*** 221,229 ****
}
! return aPtr;
}
! void SchemaCatStore::returnReadCollection( CollectionPtr )
{
}
--- 273,302 ----
}
! return aCollection;
}
! //
! // Return the cursor, which is only a collection of attributes where
! // key = String (uuid)
! // value = SchemaStore
! //
! void SchemaCatStore::returnReadCollection( CollectionPtr aPtr )
{
+ if( aPtr != NULLPTR )
+ {
+ Counter maxCnt = aPtr->getSize();
+ for( ElementIndex x = 0; x < maxCnt; ++x )
+ {
+ AttributePtr aAtt( Attribute::castDown(aPtr->getElementAt(x)) );
+ FrameworkString::destroy( FrameworkString::castDown( aAtt->getKey() ));
+ SchemaStore::destroy( SchemaStore::castDown( aAtt->getValue() ));
+ Attribute::destroy(aAtt);
+ }
+ Array::destroy( Array::castDown(aPtr) );
+ }
+ else
+ {
+ ; // do nothing
+ }
}
Index: SchemaCatalog.cpp
===================================================================
RCS file: /cvsroot/corelinux/clfw/src/libs/Persist/SchemaCatalog.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** SchemaCatalog.cpp 2001/04/15 16:36:08 1.6
--- SchemaCatalog.cpp 2001/04/19 03:44:42 1.7
***************
*** 562,569 ****
if( aResult != NULLPTR )
{
Counter maxLoop( aResult->getSize() );
for( Counter x = 0; x < maxLoop; ++x )
{
!
}
theCatalog->returnReadCollection( aResult );
--- 562,571 ----
if( aResult != NULLPTR )
{
+ theSchemas.addAll( *aResult );
+
Counter maxLoop( aResult->getSize() );
for( Counter x = 0; x < maxLoop; ++x )
{
! aResult->remove( theSchemas.getElementAt(x) );
}
theCatalog->returnReadCollection( aResult );
Index: SchemaStore.cpp
===================================================================
RCS file: /cvsroot/corelinux/clfw/src/libs/Persist/SchemaStore.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** SchemaStore.cpp 2001/04/17 09:59:43 1.1
--- SchemaStore.cpp 2001/04/19 03:44:42 1.2
***************
*** 25,28 ****
--- 25,32 ----
#endif
+ #if !defined(__SCHEMA_HPP)
+ #include <clfw/Schema.hpp>
+ #endif
+
#if !defined(__SCHEMASTORE_HPP)
#include INCL_SchemaStore
***************
*** 50,54 ****
SchemaStore::SchemaStore( void )
:
! SchemaAbstractStore()
{
--- 54,59 ----
SchemaStore::SchemaStore( void )
:
! SchemaAbstractStore(),
! theSchema( NULLPTR )
{
***************
*** 61,67 ****
SchemaStore::SchemaStore( SchemaStoreCref aType )
:
! SchemaAbstractStore( aType )
{
! ; // do nothing
}
--- 66,75 ----
SchemaStore::SchemaStore( SchemaStoreCref aType )
:
! SchemaAbstractStore( aType ),
! theSchema( NULLPTR )
{
! theName = aType.getName();
! theLocation = aType.getLocation();
! theSchema = aType.getSchema();
}
***************
*** 91,94 ****
--- 99,133 ----
{
return ( *this );
+ }
+
+ SchemaDataDescriptor SchemaStore::serialize( void ) const
+ {
+ SchemaDataDescriptor ad;
+ return ad;
+ }
+
+ FrameworkStringCref SchemaStore::getName( void ) const
+ {
+ return theName;
+ }
+
+ FrameworkStringCref SchemaStore::getLocation( void ) const
+ {
+ return theLocation;
+ }
+
+ SchemaPtr SchemaStore::getSchema( void ) const
+ {
+ return theSchema;
+ }
+
+ //
+ // Routine to take our information out to a
+ // format for storing
+ //
+
+ void SchemaStore::initialize( SchemaDataDescriptorCref )
+ {
+
}
|