|
From: Frank V. C. <fr...@us...> - 2001-04-20 11:16:35
|
Update of /cvsroot/corelinux/clfw/src/libs/Persist
In directory usw-pr-cvs1:/tmp/cvs-serv13432/src/libs/Persist
Modified Files:
SchemaCatStore.cpp SchemaCatalog.cpp SchemaStore.cpp Store.cpp
Log Message:
Working catalog (writes schema entry)
Index: SchemaCatStore.cpp
===================================================================
RCS file: /cvsroot/corelinux/clfw/src/libs/Persist/SchemaCatStore.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** SchemaCatStore.cpp 2001/04/19 03:44:42 1.3
--- SchemaCatStore.cpp 2001/04/20 11:16:31 1.4
***************
*** 302,309 ****
}
! //Write one or more objects to a store
! void SchemaCatStore::write( CollectionPtr )
{
}
--- 302,325 ----
}
! // Write one or more objects to a store, we know
! // they are SchemaStore instances in the collection so
! // we serialize them out with the key reference
! void SchemaCatStore::write( CollectionPtr aCollection )
{
+ REQUIRE( aCollection != NULLPTR );
+ SchemaStore *aPtr( NULLPTR );
+ Counter maxCnt( aCollection->getSize() );
+ Char aBuffer[37];
+ SchemaDataDescriptor aSd;
+
+ for( Counter x = 0; x < maxCnt; ++x )
+ {
+ aPtr = SchemaStore::castDown( aCollection->getElementAt(x) );
+ aSd = aPtr->serialize();
+ aPtr->getSchemaUid().getAsString( aBuffer );
+ SchemaAbstractStore::updateDesc( aBuffer, aSd );
+ free(aSd.data);
+ }
}
Index: SchemaCatalog.cpp
===================================================================
RCS file: /cvsroot/corelinux/clfw/src/libs/Persist/SchemaCatalog.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** SchemaCatalog.cpp 2001/04/19 03:44:42 1.7
--- SchemaCatalog.cpp 2001/04/20 11:16:31 1.8
***************
*** 33,36 ****
--- 33,40 ----
#endif
+ #if !defined(__SCHEMASTORE_HPP)
+ #include INCL_SchemaStore
+ #endif
+
#if !defined(__SCHEMACATSTORE_HPP)
#include INCL_SchemaCatStore
***************
*** 160,165 ****
REQUIRE( aCollection != NULLPTR );
! CollectionPtr aSchemaCol( NULLPTR );
! FrameworkString aUid;
//
--- 164,169 ----
REQUIRE( aCollection != NULLPTR );
! FrameworkStringPtr aSchemaCol( NULLPTR );
! FrameworkString aUid;
//
***************
*** 200,204 ****
// Create and assign name and collection
! SchemaPtr aSchema = this->createSchema( aUid, *aName, aSchemaCol );
// Make the catalog entry and persist
--- 204,208 ----
// Create and assign name and collection
! // SchemaPtr aSchema = this->createSchema( aUid, *aName, aSchemaCol );
// Make the catalog entry and persist
***************
*** 219,247 ****
//
! // What we do here to make the entry is:
! // Collection where:
! // UuidAssignment -> uuid
! // EntryInfo -> array
! // Name -> name
! // Location -> location
//
! Array outer;
! Array inner;
! Attribute uid;
! uid.setKey( FrameworkEntityPtr(&Store::getUniqueIdKey()) );
! uid.setValue( FrameworkEntityPtr(&aUid) );
! outer.put( &uid );
! Attribute colInfo;
! colInfo.setKey( FrameworkEntityPtr(&Store::getCollectionKey()) );
! colInfo.setValue( &inner );
! outer.put( &colInfo );
! // Serialize the first part to the location
! this->saveSchema( aSchema );
}
else
--- 223,260 ----
//
! // Setup the in memory reference
//
! SchemaStore *aStore = SchemaStore::create();
! aStore->setName( *aName );
! aStore->setLocation( *aLocation );
! aStore->setCollectionType( *aSchemaCol );
! aStore->setSchemaUid( UniversalIdentifier( aUid.getValue() ) );
! aStore->setSchemaClassId
! (
! Schema::getTypeDescriptor()->getIdentifier()
! );
!
! //
! // Setup the catalog collection entry
! //
! AttributePtr aAttr( Attribute::create() );
! FrameworkStringPtr aKey( FrameworkString::create() );
! aKey->setValue( aName->getValue() );
! aAttr->setKey( aKey );
! aAttr->setValue( aStore );
! theSchemas.put( aAttr );
!
! //
! // Write the entry to the physical world
! //
! Array anArray;
! anArray.put( aStore );
! theCatalog->write( &anArray );
}
else
***************
*** 393,403 ****
//
! CollectionPtr SchemaCatalog::resolveCollectionAssignment
(
CollectionPtr aCollection
)
{
! MetaClassPtr aClass( NULLPTR );
! FrameworkEntityPtr aPtr( NULLPTR );
FrameworkStringPtr aResult
--- 406,415 ----
//
! FrameworkStringPtr SchemaCatalog::resolveCollectionAssignment
(
CollectionPtr aCollection
)
{
! FrameworkStringPtr aPtr( NULLPTR );
FrameworkStringPtr aResult
***************
*** 416,441 ****
if( aResult != NULLPTR )
{
! aClass = Ontology::getClassFor( aResult->getValue() );
}
else
{
! aClass = Ontology::getClassFor( defCollection.getValue() );
}
! //
! // Instantiate it
! //
!
! aClass->dispatch( "Construct" , (void **)NULLPTR,(void *)&aPtr );
! if( aPtr == NULLPTR )
! {
! throw NullPointerException( LOCATION );
! }
! else
! {
! ; // do nothing
! }
!
! return Collection::castDown( aPtr );
}
--- 428,439 ----
if( aResult != NULLPTR )
{
! aPtr = aResult;
}
else
{
! aPtr = (FrameworkStringPtr)&defCollection;
}
! return aPtr ;
}
Index: SchemaStore.cpp
===================================================================
RCS file: /cvsroot/corelinux/clfw/src/libs/Persist/SchemaStore.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** SchemaStore.cpp 2001/04/19 03:44:42 1.2
--- SchemaStore.cpp 2001/04/20 11:16:31 1.3
***************
*** 47,50 ****
--- 47,59 ----
namespace corelinux
{
+ struct __SchemaStoreDesc
+ {
+ Dword version; // class version
+ Dword propcount; // property count
+ char buffer[1]; // repeating for propcount
+ // Key0Value0
+ };
+
+ DECLARE_TYPE( struct __SchemaStoreDesc, SchemaDesc );
//
***************
*** 101,107 ****
--- 110,172 ----
}
+ //
+ // Serialize the object state to a buffer
+ //
+
SchemaDataDescriptor SchemaStore::serialize( void ) const
{
SchemaDataDescriptor ad;
+ Dword totalSize(0);
+ SchemaDescPtr aPtr( NULLPTR );
+ CharPtr aBase( NULLPTR );
+ CharCptr aNam( Store::getNameKey().getValue() );
+ CharCptr aLoc( Store::getLocationKey().getValue() );
+ CharCptr aCol( Store::getCollectionKey().getValue() );
+ CharCptr aUid( Store::getUniqueIdKey().getValue() );
+ CharCptr aCid( Store::getClassIdKey().getValue() );
+
+ totalSize = std::strlen( aNam ) + 2;
+ totalSize += std::strlen( aLoc ) + 2;
+ totalSize += std::strlen( aCol ) + 2;
+ totalSize += (std::strlen( aUid )*2) + 4;
+ totalSize += sizeof( SchemaDesc );
+ totalSize += std::strlen( theName.getValue() );
+ totalSize += std::strlen( theLocation.getValue() );
+ totalSize += std::strlen( theCollection.getValue() );
+ totalSize += 72;
+
+ aPtr = SchemaDescPtr(new char[totalSize]);
+
+ aPtr->propcount = 5;
+
+ aBase = aPtr->buffer;
+
+ std::strcpy( aBase, aNam );
+ aBase += std::strlen( aBase )+1;
+ std::strcpy( aBase, theName.getValue() );
+ aBase += std::strlen( aBase )+1;
+
+ std::strcpy( aBase, aLoc );
+ aBase += std::strlen( aBase )+1;
+ std::strcpy( aBase, theLocation.getValue() );
+ aBase += std::strlen( aBase )+1;
+
+ std::strcpy( aBase, aCol );
+ aBase += std::strlen( aBase )+1;
+ std::strcpy( aBase, theCollection.getValue() );
+ aBase += std::strlen( aBase )+1;
+
+ std::strcpy( aBase, aUid );
+ aBase += std::strlen( aBase )+1;
+ theSchemaUid.getAsString( aBase );
+ aBase += std::strlen( aBase )+1;
+
+ std::strcpy( aBase, aCid );
+ aBase += std::strlen( aBase )+1;
+ theSchemaClassId.getAsString( aBase );
+
+ ad.dataSize = totalSize;
+ ad.data = CharPtr(aPtr);
+
return ad;
}
***************
*** 117,120 ****
--- 182,200 ----
}
+ FrameworkStringCref SchemaStore::getCollectionType( void ) const
+ {
+ return theCollection;
+ }
+
+ UniversalIdentifierCref SchemaStore::getSchemaClassId( void ) const
+ {
+ return theSchemaClassId;
+ }
+
+ UniversalIdentifierCref SchemaStore::getSchemaUid( void ) const
+ {
+ return theSchemaUid;
+ }
+
SchemaPtr SchemaStore::getSchema( void ) const
{
***************
*** 123,133 ****
//
! // Routine to take our information out to a
! // format for storing
//
! void SchemaStore::initialize( SchemaDataDescriptorCref )
{
}
--- 203,284 ----
//
! // Routine to take our information out. In the future this may
! // change to a collection stuffing
//
+
+ void SchemaStore::initialize( SchemaDataDescriptorCref aData )
+ {
+ SchemaDescPtr aDesc( SchemaDescPtr(aData.data) );
+ Dword maxCnt( aDesc->propcount );
+ CharPtr aKey( NULLPTR );
+ CharPtr aValue( NULLPTR );
+ CharPtr aBase( aDesc->buffer );
+
+ for( Dword x = 0; x < maxCnt; ++x )
+ {
+ aKey = aBase;
+ aValue = aBase + (std::strlen( aKey )+1);
! if( Store::getNameKey() == aKey )
! {
! theName = aValue;
! }
! else if( Store::getLocationKey() == aKey )
! {
! theLocation = aValue;
! }
! else if( Store::getCollectionKey() == aKey )
! {
! theCollection = aValue;
! }
! else if( Store::getClassIdKey() == aKey )
! {
! theSchemaClassId = aValue;
! }
! else if( Store::getUniqueIdKey() == aKey )
! {
! theSchemaUid = aValue;
! }
! else
! {
! ; // want store exception of some kind
! }
! aBase = aValue + (std::strlen( aValue )+1);
! }
! }
!
! // Sets the name
!
! void SchemaStore::setName( FrameworkStringCref aRef )
! {
! theName = aRef;
! }
!
! // Set the location for schema
!
! void SchemaStore::setLocation( FrameworkStringCref aRef )
! {
! theLocation = aRef;
! }
!
! // Set the location for schema
!
! void SchemaStore::setCollectionType( FrameworkStringCref aRef )
{
+ theCollection = aRef;
+ }
+ // Set the class id to use in factory
+
+ void SchemaStore::setSchemaClassId( UniversalIdentifierCref aRef )
+ {
+ theSchemaClassId = aRef;
+ }
+
+ // Set the uid for the schema during create
+
+ void SchemaStore::setSchemaUid( UniversalIdentifierCref aRef )
+ {
+ theSchemaUid = aRef;
}
Index: Store.cpp
===================================================================
RCS file: /cvsroot/corelinux/clfw/src/libs/Persist/Store.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** Store.cpp 2001/04/15 16:36:08 1.2
--- Store.cpp 2001/04/20 11:16:31 1.3
***************
*** 52,55 ****
--- 52,57 ----
FrameworkString Store::theUniqueIdKey("GUID");
+ FrameworkString Store::theClassIdKey("Class");
+
FrameworkString Store::theCollectionKey("Collection");
***************
*** 150,153 ****
--- 152,160 ----
{
return theUniqueIdKey;
+ }
+
+ FrameworkStringCref Store::getClassIdKey( void )
+ {
+ return theClassIdKey;
}
|