|
From: Frank V. C. <fr...@us...> - 2001-04-21 21:39:06
|
Update of /cvsroot/corelinux/clfw/src/libs/Persist
In directory usw-pr-cvs1:/tmp/cvs-serv16775/src/libs/Persist
Modified Files:
SchemaAbstractStore.cpp SchemaCatStore.cpp SchemaCatalog.cpp
SchemaStore.cpp
Log Message:
Creates actual schema db now, although no content. Cleaning, testing, and embellishing
Index: SchemaAbstractStore.cpp
===================================================================
RCS file: /cvsroot/corelinux/clfw/src/libs/Persist/SchemaAbstractStore.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** SchemaAbstractStore.cpp 2001/04/19 03:44:42 1.2
--- SchemaAbstractStore.cpp 2001/04/21 21:39:01 1.3
***************
*** 91,94 ****
--- 91,109 ----
}
+ bool SchemaAbstractStore::exists( CharPtr aName )
+ {
+ GDBM_FILE aTst = gdbm_open(aName,0,GDBM_READER,0666,NULLPTR);
+ if( aTst != 0 )
+ {
+ gdbm_close( aTst );
+ }
+ else
+ {
+ ; // do nothing
+ }
+
+ return aTst;
+ }
+
Handle SchemaAbstractStore::openRead( CharPtr aName )
{
Index: SchemaCatStore.cpp
===================================================================
RCS file: /cvsroot/corelinux/clfw/src/libs/Persist/SchemaCatStore.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** SchemaCatStore.cpp 2001/04/20 11:16:31 1.4
--- SchemaCatStore.cpp 2001/04/21 21:39:01 1.5
***************
*** 58,63 ****
static CatalogDescriptor gDefFirst = {1,0};
-
-
//
// Constructor
--- 58,61 ----
***************
*** 89,92 ****
--- 87,95 ----
{
SchemaAbstractStore::closeStore();
+
+ //
+ // Iterate through the in memory catalog,
+ // and remove all the instances
+ //
}
***************
*** 129,132 ****
--- 132,139 ----
Store::resolveValueAssignment( aPtr, &Store::getModeKey() );
+ //
+ // Some fundemental things are needed eh?
+ //
+
if( aBase != NULLPTR && aName != NULLPTR )
{
***************
*** 242,246 ****
aVal->initialize( aDesc );
! aAtt->setKey( new FrameworkString( aKey.data ) );
aAtt->setValue( aVal );
--- 249,253 ----
aVal->initialize( aDesc );
! aAtt->setKey( new FrameworkString( aVal->getName() ) );
aAtt->setValue( aVal );
***************
*** 281,284 ****
--- 288,292 ----
// value = SchemaStore
//
+
void SchemaCatStore::returnReadCollection( CollectionPtr aPtr )
{
***************
*** 322,325 ****
--- 330,343 ----
free(aSd.data);
}
+
+ }
+
+ //
+ // Get rid of an entry, which in turn does a full
+ // delete on the schema it may refer to
+ //
+
+ void SchemaCatStore::remove( CollectionPtr )
+ {
}
Index: SchemaCatalog.cpp
===================================================================
RCS file: /cvsroot/corelinux/clfw/src/libs/Persist/SchemaCatalog.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -r1.8 -r1.9
*** SchemaCatalog.cpp 2001/04/20 11:16:31 1.8
--- SchemaCatalog.cpp 2001/04/21 21:39:01 1.9
***************
*** 153,157 ****
Counter SchemaCatalog::getCount( void ) const
{
! return 0;
}
--- 153,157 ----
Counter SchemaCatalog::getCount( void ) const
{
! return theSchemas.getSize();
}
***************
*** 226,230 ****
//
! SchemaStore *aStore = SchemaStore::create();
aStore->setName( *aName );
--- 226,230 ----
//
! SchemaStorePtr aStore = SchemaStore::create();
aStore->setName( *aName );
***************
*** 299,308 ****
if( aName != NULLPTR )
{
! Attribute srchAttr;
srchAttr.setKey(aName);
! if( theSchemas.containsElement( &srchAttr ) == true )
{
!
}
else
--- 299,314 ----
if( aName != NULLPTR )
{
! Attribute srchAttr;
! ElementIndex index;
!
srchAttr.setKey(aName);
! if( ( index = theSchemas.indexOf( &srchAttr ) ) >= 0 )
{
! AttributePtr anEntry
! (
! Attribute::castDown( theSchemas.getElementAt( index ) )
! );
! aSchm = SchemaStore::castDown( anEntry->getValue() )->getSchema();
}
else
***************
*** 338,341 ****
--- 344,359 ----
}
+ Iterator<FrameworkEntityPtr> *SchemaCatalog::createCatalogIterator( void )
+ {
+ Iterator<FrameworkEntityPtr> *aItr( NULLPTR );
+ return aItr;
+ }
+
+ /// Destroy the iterator over the catalog entries
+
+ void SchemaCatalog::destroyIterator( Iterator<FrameworkEntityPtr> * )
+ {
+
+ }
//
Index: SchemaStore.cpp
===================================================================
RCS file: /cvsroot/corelinux/clfw/src/libs/Persist/SchemaStore.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** SchemaStore.cpp 2001/04/20 11:16:31 1.3
--- SchemaStore.cpp 2001/04/21 21:39:01 1.4
***************
*** 25,34 ****
#endif
#if !defined(__SCHEMA_HPP)
#include <clfw/Schema.hpp>
#endif
! #if !defined(__SCHEMASTORE_HPP)
! #include INCL_SchemaStore
#endif
--- 25,38 ----
#endif
+ #if !defined(__ONTOLOGY_HPP)
+ #include <clfw/Ontology.hpp>
+ #endif
+
#if !defined(__SCHEMA_HPP)
#include <clfw/Schema.hpp>
#endif
! #if !defined(__ATTRIBUTE_HPP)
! #include <clfw/Attribute.hpp>
#endif
***************
*** 45,48 ****
--- 49,57 ----
#endif
+ #if !defined(__SCHEMASTORE_HPP)
+ #include INCL_SchemaStore
+ #endif
+
+
namespace corelinux
{
***************
*** 57,60 ****
--- 66,71 ----
DECLARE_TYPE( struct __SchemaStoreDesc, SchemaDesc );
+ const FrameworkString schemaMode("Write");
+
//
// Constructor
***************
*** 64,68 ****
:
SchemaAbstractStore(),
! theSchema( NULLPTR )
{
--- 75,80 ----
:
SchemaAbstractStore(),
! theSchema( NULLPTR ),
! theCreatedFlag( false )
{
***************
*** 76,84 ****
:
SchemaAbstractStore( aType ),
! theSchema( NULLPTR )
{
theName = aType.getName();
theLocation = aType.getLocation();
! theSchema = aType.getSchema();
}
--- 88,99 ----
:
SchemaAbstractStore( aType ),
! theSchema( NULLPTR ),
! theCreatedFlag( false )
{
theName = aType.getName();
theLocation = aType.getLocation();
! theCollection = aType.getCollectionType();
! theSchemaClassId = aType.getSchemaClassId();
! theSchemaUid = aType.getSchemaUid();
}
***************
*** 172,175 ****
--- 187,194 ----
}
+ //
+ // Accessors for attributes
+ //
+
FrameworkStringCref SchemaStore::getName( void ) const
{
***************
*** 196,206 ****
return theSchemaUid;
}
! SchemaPtr SchemaStore::getSchema( void ) const
{
return theSchema;
}
//
// Routine to take our information out. In the future this may
// change to a collection stuffing
--- 215,327 ----
return theSchemaUid;
}
+
+ //
+ // Accessor for underlying schema.
+ //
! SchemaPtr SchemaStore::getSchema( void )
{
+ //
+ // If we don't have it in memory
+ //
+
+ if( theSchema == NULLPTR )
+ {
+ //
+ // If we don't have a store for it
+ //
+
+ Array anArray;
+ Attribute aName;
+ Attribute aLocation;
+ Attribute aMode;
+
+ aName.setKey( FrameworkEntityPtr(&Store::getNameKey()) );
+ aName.setValue( &theName );
+
+ aLocation.setKey( FrameworkEntityPtr(&Store::getLocationKey()) );
+ aLocation.setValue( &theLocation );
+
+ aMode.setKey( FrameworkEntityPtr(&Store::getModeKey()) );
+ aMode.setValue( FrameworkEntityPtr(&schemaMode) );
+
+ anArray.put( &aName );
+ anArray.put( &aLocation );
+ anArray.put( &aMode );
+
+ FrameworkString aDbm(theLocation);
+ aDbm += "/";
+ aDbm += theName;
+
+ //
+ // We will want to initialize something in this
+ // first if just being created
+ //
+
+ if( this->exists( aDbm.getValue() ) == false )
+ {
+ theCreatedFlag = true;
+ }
+ else
+ {
+ ; // do nothing
+ }
+
+ this->open( &anArray );
+
+ anArray.removeAll();
+
+ //
+ // Now we initialize the actual Schema instance
+ //
+
+ if( theCreatedFlag == true )
+ {
+ theSchema = this->createSchema();
+ }
+ else
+ {
+ ; // do nothing
+ }
+
+ }
+ else
+ {
+ ; // do nothing and return it
+ }
+
return theSchema;
}
//
+ // Mutators for attributes
+ //
+
+ void SchemaStore::setName( FrameworkStringCref aRef )
+ {
+ theName = aRef;
+ }
+
+ void SchemaStore::setLocation( FrameworkStringCref aRef )
+ {
+ theLocation = aRef;
+ }
+
+ void SchemaStore::setCollectionType( FrameworkStringCref aRef )
+ {
+ theCollection = aRef;
+ }
+
+ void SchemaStore::setSchemaClassId( UniversalIdentifierCref aRef )
+ {
+ theSchemaClassId = aRef;
+ }
+
+ void SchemaStore::setSchemaUid( UniversalIdentifierCref aRef )
+ {
+ theSchemaUid = aRef;
+ }
+
+ //
// Routine to take our information out. In the future this may
// change to a collection stuffing
***************
*** 248,286 ****
}
- // 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;
- }
-
//
// Open the gdbm storage for the catalog
--- 369,372 ----
***************
*** 321,340 ****
result = SchemaAbstractStore::openWrite( aDbm.getValue() );
}
-
- //
- // If we open, we need to resolve the existing descriptor
- // or create one if there aren't any found. The exception
- // for the creating would be to check to see if there
- // are actual entites whereas we need a rebuild
- // capability
- //
! if( result != NULLPTR )
{
! SchemaDataDescriptor aSd;
}
else
{
! throw NullPointerException( aDbm.getValue(), LOCATION );
}
}
--- 407,418 ----
result = SchemaAbstractStore::openWrite( aDbm.getValue() );
}
! if( result == NULLPTR )
{
! throw NullPointerException( aDbm.getValue(), LOCATION );
}
else
{
! ; // do nothing
}
}
***************
*** 386,390 ****
}
! //Write one or more objects to a store
void SchemaStore::write( CollectionPtr )
--- 464,468 ----
}
! // Write one or more objects to a store
void SchemaStore::write( CollectionPtr )
***************
*** 392,395 ****
--- 470,543 ----
}
+
+ //
+ // Get rid of an entry, which in turn does a full
+ // delete on the schema it may refer to
+ //
+
+ void SchemaStore::remove( CollectionPtr )
+ {
+
+ }
+
+ SchemaPtr SchemaStore::createSchema( void )
+ {
+ FrameworkEntityPtr aPtr( NULLPTR );
+ SchemaPtr aScm( NULLPTR );
+
+ MetaClassPtr aClass( Ontology::getClassFor( theSchemaClassId ) );
+ aClass->dispatch( "Construct" , (void **)NULLPTR,(void *)&aPtr );
+
+ //
+ // Using the schema class type, instantiate
+ // an instance
+ //
+
+ if( aPtr == NULLPTR )
+ {
+ throw NullPointerException( LOCATION );
+ }
+ else
+ {
+ aScm = Schema::castDown( aPtr );
+ }
+
+ //
+ // Assign the know uuid
+ //
+
+ aScm->setOid( theSchemaUid );
+
+ //
+ // Instantiate the collection type
+ //
+
+ 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
+ }
+ }
+
+ return aScm;
+ }
+
//
|