From 40f95bbe2fa62316df627cab294cd03c957862d6 Mon Sep 17 00:00:00 2001 From: "guha%netscape.com" Date: Tue, 1 Dec 1998 23:43:06 +0000 Subject: [PATCH] Comments, fix for MSVC 4.2 --- rdf/src/nsBookmarkDataSource.cpp | 2 ++ rdf/src/nsRDFElement.cpp | 12 +++++++----- rdf/src/nsRDFElement.h | 8 ++++---- rdf/src/nsSimpleDataBase.cpp | 32 +++++++++++++++++++------------- 4 files changed, 32 insertions(+), 22 deletions(-) diff --git a/rdf/src/nsBookmarkDataSource.cpp b/rdf/src/nsBookmarkDataSource.cpp index 480c034b71b8..94d26339bc64 100644 --- a/rdf/src/nsBookmarkDataSource.cpp +++ b/rdf/src/nsBookmarkDataSource.cpp @@ -434,6 +434,8 @@ const char* nsBookmarkDataSource::kBookmarksFilename = "bookmarks.html"; nsBookmarkDataSource::nsBookmarkDataSource(void) { + // XXX rvg there should be only one instance of this class. + // this is actually true of all datasources. NS_INIT_REFCNT(); ReadBookmarks(); // XXX do or die, eh? Initialize(kURI_bookmarks); diff --git a/rdf/src/nsRDFElement.cpp b/rdf/src/nsRDFElement.cpp index a1a875e90d9c..42c237c41398 100644 --- a/rdf/src/nsRDFElement.cpp +++ b/rdf/src/nsRDFElement.cpp @@ -757,7 +757,8 @@ nsRDFElement::ChildCount(PRInt32& aResult) const { nsresult rv; if (!mChildren) { - if (NS_FAILED(rv = GenerateChildren())) + nsRDFElement* unconstThis = const_cast(this); + if (NS_FAILED(rv = unconstThis->GenerateChildren())) return rv; } @@ -770,7 +771,8 @@ nsRDFElement::ChildAt(PRInt32 aIndex, nsIContent*& aResult) const { nsresult rv; if (!mChildren) { - if (NS_FAILED(rv = GenerateChildren())) + nsRDFElement* unconstThis = const_cast(this); + if (NS_FAILED(rv = unconstThis->GenerateChildren())) return rv; } @@ -1243,7 +1245,7 @@ nsRDFElement::GetProperty(const nsString& aPropertyURI, nsString& rValue) const // would do the work of transforming it for presentation.) // nsresult -nsRDFElement::GenerateChildren(void) const +nsRDFElement::GenerateChildren(void) { nsresult rv; @@ -1350,7 +1352,7 @@ done: nsresult nsRDFElement::CreateChild(nsIRDFNode* value, - nsIRDFContent*& result) const + nsIRDFContent*& result) { // XXX I wish that we could avoid doing it "by hand" like this // (i.e., use interface methods so that we could extend to other @@ -1380,7 +1382,7 @@ nsRDFElement::CreateChild(nsIRDFNode* value, nsresult nsRDFElement::CreateChild(nsIRDFNode* property, nsIRDFNode* value, - nsIRDFContent*& result) const + nsIRDFContent*& result) { nsresult rv; nsRDFElement* child = NULL; diff --git a/rdf/src/nsRDFElement.h b/rdf/src/nsRDFElement.h index fe32b63c34ad..43d2661c289f 100644 --- a/rdf/src/nsRDFElement.h +++ b/rdf/src/nsRDFElement.h @@ -127,14 +127,14 @@ protected: PRInt32 mNameSpaceId; void* mScriptObject; nsIRDFNode* mResource; - mutable nsISupportsArray* mChildren; + nsISupportsArray* mChildren; nsIContent* mParent; - nsresult GenerateChildren(void) const; - nsresult CreateChild(nsIRDFNode* value, nsIRDFContent*& result) const; + nsresult GenerateChildren(void); + nsresult CreateChild(nsIRDFNode* value, nsIRDFContent*& result); nsresult CreateChild(nsIRDFNode* property, nsIRDFNode* value, - nsIRDFContent*& result) const; + nsIRDFContent*& result); }; #endif // nsRDFElement_h___ diff --git a/rdf/src/nsSimpleDataBase.cpp b/rdf/src/nsSimpleDataBase.cpp index 90eb035df3cb..8bbb49891470 100644 --- a/rdf/src/nsSimpleDataBase.cpp +++ b/rdf/src/nsSimpleDataBase.cpp @@ -26,26 +26,25 @@ /* + XXX --- chris, are you happy with this (I rewrote it). + A simple "database" implementation. An RDF database is just a "strategy" pattern for combining individual data sources into a collective graph. - This implementation is pretty much lifted straight out of the old C - RDF implementation. As such, it inheirits some horrible problems. - 1) A database is a hard-coded collection of data sources. What you'd - really like would be fore data sources to be discovered at - runtime, and added in to the database as needed. + 1) A database is a sequence of data sources. The set of data sources + can be specified during creation of the database. Data sources + can also be added/deleted from a database later. - 2) The aggregation mechanism is horribly ad hoc, specifically, with - respect to negative assertions. It works something like this. - Check the "first" data source for a negative assertion. If it has - one, then return it. Otherwise, check the "rest" of the data - sources for a positive assertion. + 2) The aggregation mechanism is based on simple super-positioning of + the graphs from the datasources. If there is a conflict (i.e., + data source A has a true arc from foo to bar while data source B + has a false arc from foo to bar), the data source that it earlier + in the sequence wins. - 3) Related to the above, there are no clear semantics for ordering - or precedence. Things all depend on the order that you said "add - this data source". + The implementation below doesn't really do this and needs to be + fixed. */ @@ -173,6 +172,8 @@ MultiCursor::HasMoreElements(PRBool& result) return rv; // See if data source zero has the negation + // XXX --- this needs to be fixed so that we look at all the prior + // data sources for negations PRBool hasNegation; if (NS_FAILED(rv = HasNegation(mDataSource0, mNextResult, @@ -336,6 +337,8 @@ dbArcCursorImpl::HasNegation(nsIRDFDataSource* ds0, //////////////////////////////////////////////////////////////////////// // nsSimpleDataBase +// XXX --- shouldn't this take a char** argument indicating the data sources +// we want to aggregate? nsSimpleDataBase::nsSimpleDataBase(void) { @@ -622,6 +625,9 @@ nsSimpleDataBase::Flush() //////////////////////////////////////////////////////////////////////// // nsIRDFDataBase methods +// XXX We should make this take an additional argument specifying where +// in the sequence of data sources (of the db), the new data source should +// fit in. Right now, the new datasource gets stuck at the end. NS_IMETHODIMP nsSimpleDataBase::AddDataSource(nsIRDFDataSource* source)