wpQueryRefreshFlags
This method is specific to Version 4, or higher, of the OS/2 operating system.
This instance method queries the refresh flags for a file system object. The refresh flags consist of a **DIRTYBIT** and a **FOUNDBIT** that are used to allow refresh to detect deleted files and new files after asking a folder to re-populate.
Syntax
_wpQueryRefreshFlags(somSelf)
Parameters
- somSelf (WPFileSystem *) - input
- Pointer to the object on which the method is being invoked.
- Points to an object of class WPFileSystem.
Returns
- rc (ULONG) - returns
- Refresh flags.
- **DIRTYBIT** (**0x80000000**) Used for refreshing the views of pre-existing objects.
- **FOUNDBIT** (**0x40000000**) Used for refreshing the views of new and deleted objects.
How to Override
This method is generally not overridden.
Usage
This method can be called at any time to retrieve the refresh flags for a file system object.
Example Code
#define INCL_WINWORKPLACE #include <os2.h> WPFileSystem *somSelf; /* Pointer to the object on which the method is being invoked. */ ULONG rc; /* Refresh flags. */ rc = _wpQueryRefreshFlags(somSelf);
Remarks
The refresh flags consist of a **DIRTYBIT** and a **FOUNDBIT** that are used to detect deleted files and new files when refreshing the contents of a folder.
For example, if you develop a subclass of **WPFolder** which contains objects that represent entries in a database (where the database may get updated independently from your objects), you might want to resynchronize your folder full of objects with the contents of the database. One possible technique follows:
- 1. Loop through all of the objects in the folder and turn on the **DIRTYBIT** and turn off the **FOUNDBIT** for all of your objects.
- 2. Loop through the database. For every entry in the database, find the corresponding object.
* a. If the object exists, turn on the **FOUNDBIT** for the object. * b. If the object doesn't exist, create a new object with the **FOUNDBIT** turned on and the **DIRTYBIT** turned off.
- 3. Loop through the objects in the folder again. For any object that has the **FOUNDBIT** turned off, delete the object (since there is no longer a corresponding entry in the database). For any object that has the **DIRTYBIT** turned on, update the view with the current contents of the object and turn its **DIRTYBIT** off.
This kind of technique can be implemented using private flags, or by using the flags provided by the **wpQueryRefreshFlags** and **wpSetRefreshFlags** methods.
Example Code
This example shows how you can use the refresh flags to synchronize the contents of a folder with the contents of a data base. somSelf is the pointer to the folder containing the objects corresponding to the items in the database.
MyObject *Object,*NextObject;
/* Mark all existing objects as not found */
Object = (MyObject*)_wpQueryContent(somSelf,NULL,QC_FIRST);
while (Object)
{
_wpSetRefreshFlags(Object,0);
Object = (MyObject*)_wpQueryContent(somSelf,Object,QC_NEXT);
}
/* Loop through the data base. For each item in the data base, find the
* corresponding object and call the wpSetRefreshFlags method for the
* object to set FOUNDBIT on. For any item that does not have a
* corresponding object, create the object and call the wpSetRefreshFlags
* method for the new object to set the FOUNDBIT on. */
/***** The code for the above described loop goes here *****/
/* Remove all objects corresponding to data base entries that have been
* deleted from the data base */
Object = (MyObject*)_wpQueryContent(somSelf,NULL,QC_FIRST);
while (Object)
{
NextObject = (MyObject*)_wpQueryContent(somSelf,Object,QC_NEXT);
ulFlags = _wpQueryRefreshFlags(Object);
if (!(ulFlags & FOUNDBIT))
{
Object->wpDelete(0);
}
Object = NextObject;
}