first cleanup of RDF DOMDataSource in preparation for adding document observers

This commit is contained in:
alecf%netscape.com 1999-09-25 06:21:21 +00:00
Родитель 3ca1ef4519
Коммит 7072a94718
2 изменённых файлов: 36 добавлений и 167 удалений

Просмотреть файл

@ -58,6 +58,7 @@ static NS_DEFINE_CID(kISupportsIID, NS_ISUPPORTS_IID);
nsRDFDOMDataSource::nsRDFDOMDataSource(): nsRDFDOMDataSource::nsRDFDOMDataSource():
mURI(nsnull), mURI(nsnull),
mRDFService(nsnull), mRDFService(nsnull),
mMode(nsIDOMDataSource::modeDOM),
mObservers(nsnull) mObservers(nsnull)
{ {
NS_INIT_REFCNT(); NS_INIT_REFCNT();
@ -80,50 +81,9 @@ nsRDFDOMDataSource::~nsRDFDOMDataSource()
mRDFService); mRDFService);
} }
NS_IMPL_ADDREF(nsRDFDOMDataSource) NS_IMPL_ISUPPORTS2(nsRDFDOMDataSource,
NS_IMPL_RELEASE(nsRDFDOMDataSource) nsIRDFDataSource,
nsIDOMDataSource);
NS_IMETHODIMP
nsRDFDOMDataSource::QueryInterface(const nsIID& iid, void **result)
{
nsresult rv = NS_NOINTERFACE;
if (!result) return NS_ERROR_NULL_POINTER;
void *res=nsnull;
if (iid.Equals(nsIRDFDataSource::GetIID()) ||
iid.Equals(kISupportsIID)) {
res = NS_STATIC_CAST(nsIRDFDataSource*, this);
}
else if(iid.Equals(nsIDOMDataSource::GetIID())) {
res = NS_STATIC_CAST(nsIDOMDataSource*, this);
}
if (res) {
NS_ADDREF(this);
*result = res;
rv = NS_OK;
}
return rv;
}
/* void Init (in string uri); */
NS_IMETHODIMP
nsRDFDOMDataSource::Init(const char *uri)
{
nsresult rv=NS_OK;
if (!mURI || PL_strcmp(uri, mURI) != 0)
mURI = PL_strdup(uri);
rv = getRDFService()->RegisterDataSource(this, PR_FALSE);
if (NS_FAILED(rv)) return rv;
return rv;
}
/* readonly attribute string URI; */ /* readonly attribute string URI; */
@ -427,6 +387,20 @@ nsRDFDOMDataSource::ArcLabelsOut(nsIRDFResource *aSource, nsISimpleEnumerator **
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP
nsRDFDOMDataSource::Change(nsIRDFResource *, nsIRDFResource *,
nsIRDFNode *, nsIRDFNode*)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsRDFDOMDataSource::Move(nsIRDFResource *, nsIRDFResource *,
nsIRDFResource *, nsIRDFNode*)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsISimpleEnumerator GetAllResources (); */ /* nsISimpleEnumerator GetAllResources (); */
NS_IMETHODIMP NS_IMETHODIMP
@ -436,14 +410,6 @@ nsRDFDOMDataSource::GetAllResources(nsISimpleEnumerator **_retval)
} }
/* void Flush (); */
NS_IMETHODIMP
nsRDFDOMDataSource::Flush()
{
return NS_RDF_NO_VALUE;
}
/* nsIEnumerator GetAllCommands (in nsIRDFResource aSource); */ /* nsIEnumerator GetAllCommands (in nsIRDFResource aSource); */
NS_IMETHODIMP NS_IMETHODIMP
nsRDFDOMDataSource::GetAllCommands(nsIRDFResource *aSource, nsIEnumerator **_retval) nsRDFDOMDataSource::GetAllCommands(nsIRDFResource *aSource, nsIEnumerator **_retval)
@ -539,6 +505,7 @@ nsRDFDOMDataSource::unassertEnumFunc(void *aElement, void *aData)
return PR_TRUE; return PR_TRUE;
} }
// nsIDOMDataSource methods
nsresult nsresult
nsRDFDOMDataSource::SetWindow(nsIDOMWindow *window) { nsRDFDOMDataSource::SetWindow(nsIDOMWindow *window) {
nsresult rv; nsresult rv;
@ -550,6 +517,19 @@ nsRDFDOMDataSource::SetWindow(nsIDOMWindow *window) {
return rv; return rv;
} }
nsresult
nsRDFDOMDataSource::SetMode(PRInt32 aMode)
{
mMode = aMode;
return NS_OK;
}
nsresult
nsRDFDOMDataSource::GetMode(PRInt32 *aMode)
{
*aMode = mMode;
return NS_OK;
}
NS_METHOD NS_METHOD

Просмотреть файл

@ -44,123 +44,10 @@ class nsRDFDOMDataSource : public nsIRDFDataSource,
virtual ~nsRDFDOMDataSource(); virtual ~nsRDFDOMDataSource();
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
/* void Init (in string uri); */
NS_IMETHOD Init(const char *uri);
/* readonly attribute string URI; */ NS_DECL_NSIRDFDATASOURCE
NS_IMETHOD GetURI(char * *aURI);
/* nsIRDFResource GetSource (in nsIRDFResource aProperty, NS_DECL_NSIDOMDATASOURCE
in nsIRDFNode aTarget,
in boolean aTruthValue); */
NS_IMETHOD GetSource(nsIRDFResource *aProperty,
nsIRDFNode *aTarget,
PRBool aTruthValue,
nsIRDFResource **_retval);
/* nsISimpleEnumerator GetSources (in nsIRDFResource aProperty,
in nsIRDFNode aTarget,
in boolean aTruthValue); */
NS_IMETHOD GetSources(nsIRDFResource *aProperty,
nsIRDFNode *aTarget,
PRBool aTruthValue,
nsISimpleEnumerator **_retval);
/* nsIRDFNode GetTarget (in nsIRDFResource aSource,
in nsIRDFResource aProperty,
in boolean aTruthValue); */
NS_IMETHOD GetTarget(nsIRDFResource *aSource,
nsIRDFResource *aProperty,
PRBool aTruthValue,
nsIRDFNode **_retval);
/* nsISimpleEnumerator GetTargets (in nsIRDFResource aSource,
in nsIRDFResource aProperty,
in boolean aTruthValue); */
NS_IMETHOD GetTargets(nsIRDFResource *aSource,
nsIRDFResource *aProperty,
PRBool aTruthValue,
nsISimpleEnumerator **_retval);
/* void Assert (in nsIRDFResource aSource,
in nsIRDFResource aProperty,
in nsIRDFNode aTarget,
in boolean aTruthValue); */
NS_IMETHOD Assert(nsIRDFResource *aSource,
nsIRDFResource *aProperty,
nsIRDFNode *aTarget,
PRBool aTruthValue);
/* void Unassert (in nsIRDFResource aSource,
in nsIRDFResource aProperty,
in nsIRDFNode aTarget); */
NS_IMETHOD Unassert(nsIRDFResource *aSource,
nsIRDFResource *aProperty,
nsIRDFNode *aTarget);
/* boolean HasAssertion (in nsIRDFResource aSource,
in nsIRDFResource aProperty,
in nsIRDFNode aTarget,
in boolean aTruthValue); */
NS_IMETHOD HasAssertion(nsIRDFResource *aSource,
nsIRDFResource *aProperty,
nsIRDFNode *aTarget,
PRBool aTruthValue,
PRBool *_retval);
/* void AddObserver (in nsIRDFObserver aObserver); */
NS_IMETHOD AddObserver(nsIRDFObserver *aObserver);
/* void RemoveObserver (in nsIRDFObserver aObserver); */
NS_IMETHOD RemoveObserver(nsIRDFObserver *aObserver);
/* nsISimpleEnumerator ArcLabelsIn (in nsIRDFNode aNode); */
NS_IMETHOD ArcLabelsIn(nsIRDFNode *aNode,
nsISimpleEnumerator **_retval);
/* nsISimpleEnumerator ArcLabelsOut (in nsIRDFResource aSource); */
NS_IMETHOD ArcLabelsOut(nsIRDFResource *aSource,
nsISimpleEnumerator **_retval);
/* nsISimpleEnumerator GetAllResources (); */
NS_IMETHOD GetAllResources(nsISimpleEnumerator **_retval);
/* void Flush (); */
NS_IMETHOD Flush();
/* nsIEnumerator GetAllCommands (in nsIRDFResource aSource); */
NS_IMETHOD GetAllCommands(nsIRDFResource *aSource,
nsIEnumerator **_retval);
/* nsISimpleEnumerator GetAllCmds (in nsIRDFResource aSource); */
NS_IMETHOD GetAllCmds(nsIRDFResource *aSource,
nsISimpleEnumerator **_retval);
/* boolean IsCommandEnabled (in nsISupportsArray aSources,
in nsIRDFResource aCommand,
in nsISupportsArray aArguments); */
NS_IMETHOD IsCommandEnabled(nsISupportsArray *aSources,
nsIRDFResource *aCommand,
nsISupportsArray *aArguments,
PRBool *_retval);
/* void DoCommand (in nsISupportsArray aSources,
in nsIRDFResource aCommand,
in nsISupportsArray aArguments); */
NS_IMETHOD DoCommand(nsISupportsArray *aSources,
nsIRDFResource *aCommand,
nsISupportsArray *aArguments);
NS_IMETHOD SetWindow(nsIDOMWindow *window);
NS_IMETHOD Change(nsIRDFResource*, nsIRDFResource*,
nsIRDFNode*, nsIRDFNode*)
{return NS_ERROR_NOT_IMPLEMENTED;}
NS_IMETHOD Move(nsIRDFResource*, nsIRDFResource*,
nsIRDFResource*, nsIRDFNode*)
{return NS_ERROR_NOT_IMPLEMENTED;}
static NS_METHOD Create(nsISupports* aOuter, static NS_METHOD Create(nsISupports* aOuter,
const nsIID& iid, const nsIID& iid,
@ -179,6 +66,7 @@ class nsRDFDOMDataSource : public nsIRDFDataSource,
PRBool init; PRBool init;
nsIRDFService *mRDFService; nsIRDFService *mRDFService;
PRInt32 mMode;
nsVoidArray *mObservers; nsVoidArray *mObservers;
nsCOMPtr<nsIDOMDocument> mDocument; nsCOMPtr<nsIDOMDocument> mDocument;
@ -188,6 +76,7 @@ class nsRDFDOMDataSource : public nsIRDFDataSource,
nsIRDFResource* kNC_Type; nsIRDFResource* kNC_Type;
nsIRDFResource* kNC_Child; nsIRDFResource* kNC_Child;
nsIRDFResource* kNC_DOMRoot; nsIRDFResource* kNC_DOMRoot;
}; };
#endif #endif