Pyro higlevel API
Public Types | Public Member Functions | List of all members
os_priv::DirKeeper Class Reference
Inheritance diagram for os_priv::DirKeeper:
os::Looper os::Handler

Public Types

enum  {
  M_CHANGE_DIR = 1,
  M_COPY_FILES,
  M_MOVE_FILES,
  M_DELETE_FILES,
  M_RENAME_FILES,
  M_ENTRIES_ADDED,
  M_ENTRIES_REMOVED,
  M_ENTRIES_UPDATED,
  M_LAYOUT_UPDATED
}
 
- Public Types inherited from os::Looper
typedef std::map< int, Handler * > handler_map
 

Public Member Functions

 DirKeeper (const Messenger &cTarget, const String &cPath)
 
virtual void HandleMessage (Message *pcMessage)
 Handle a message targeted at this handler. More...
 
virtual bool Idle ()
 Hook called each time the message queue is drained. More...
 
void Stop ()
 
status_t GetNode (os::String zPath, os::FSNode *pcNode, bool *pbBrokenLink)
 
DirectoryGetCurrentDir ()
 
bool IsReading ()
 
- Public Member Functions inherited from os::Looper
 Looper (const String &cName, int nPriority=NORMAL_PRIORITY, int nPortSize=DEFAULT_PORT_SIZE)
 The looper constructor. More...
 
virtual ~Looper ()
 Looper destructor. More...
 
void SetName (const String &cName)
 Rename the looper. More...
 
String GetName () const
 Get the loopers name. More...
 
bool IsPublic () const
 See if the looper's message port is public. More...
 
void SetPublic (bool bPublic)
 Make port public/private. More...
 
port_id GetMsgPort () const
 Obtain the low-level message port used by this looper. More...
 
thread_id GetThread () const
 Obtain the thread id of the looper thread. More...
 
proc_id GetProcess () const
 Obtain the process ID of the loopers thread. More...
 
status_t Lock ()
 Lock the looper object. More...
 
status_t Lock (bigtime_t nTimeout)
 Lock the looper with a timeout. More...
 
status_t SafeLock ()
 Attempt to lock the looper. More...
 
status_t Unlock ()
 Unlock the looper. More...
 
void SetMutex (Locker *pcMutex)
 Set a custom mutex to be used by the looper. More...
 
LockerGetMutex () const
 Get a pointer to the loopers mutex. More...
 
int GetLockCount () const
 Obtain the number of locks held on the looper. More...
 
thread_id GetLockingThread () const
 Obtaing the owner of the looper lock. More...
 
bool IsLocked () const
 Check if the looper lock is owned by the calling thread. More...
 
virtual thread_id Run ()
 Start and unlock the looper. More...
 
int Wait () const
 Wait for the looper thread to die. More...
 
status_t PostMessage (uint32 nCode)
 Deliver a message to the looper. More...
 
status_t PostMessage (Message *pcMsg)
 Deliver a message to the looper. More...
 
status_t PostMessage (uint32 cCode, Handler *pcHandler, Handler *pcReplyTo=NULL)
 Deliver a message to the looper. More...
 
status_t PostMessage (Message *pcMsg, Handler *pcHandler, Handler *pcReplyTo=NULL)
 Deliver a message to the looper. More...
 
void SpoolMessages ()
 Drain the low-level message port. More...
 
MessageGetCurrentMessage () const
 Obtain the message currently being processed. More...
 
MessageDetachCurrentMessage ()
 Steal the current message. More...
 
virtual void DispatchMessage (Message *pcMessage, Handler *pcHandler)
 The loopers message handling callback. More...
 
virtual void Started ()
 Called by the looper thread before entering the message loop. More...
 
MessageQueueGetMessageQueue () const
 Obtain the internal message queue used by the looper. More...
 
virtual bool OkToQuit ()
 Check if it is ok to break the loop. More...
 
virtual void Quit ()
 Unconditionally terminate the looper. More...
 
void Terminate ()
 Unconditionally terminate the looper. More...
 
void AddTimer (Handler *pcTarget, int nID, bigtime_t nTimeout, bool bOneShot=true)
 Add a timer to the looper. More...
 
bool RemoveTimer (Handler *pcTarget, int nID)
 Delete a timer. More...
 
const handler_mapGetHandlerMap () const
 Get the internal handler list. More...
 
void AddHandler (Handler *pcHandler)
 Add a handler to the looper. More...
 
bool RemoveHandler (Handler *pcHandler)
 Remove a handler previously added by AddHandler() More...
 
HandlerFindHandler (const String &cName) const
 Search the looper for a named handler. More...
 
int GetHandlerCount () const
 Obtain the count of handlers added to this looper. More...
 
void SetDefaultHandler (Handler *pcHandler)
 Set the default target for incomming messages. More...
 
HandlerGetDefaultHandler () const
 Obtain the default handler for the looper. More...
 
void AddCommonFilter (MessageFilter *pcFilter)
 
void RemoveCommonFilter (MessageFilter *pcFilter)
 
const MsgFilterListGetCommonFilterList () const
 
- Public Member Functions inherited from os::Handler
 Handler (const String &cName)
 Construct a handler. More...
 
virtual ~Handler ()
 Destructor. More...
 
virtual void TimerTick (int nID)
 Timer dispatch member. More...
 
String GetName () const
 Get the handlers name. More...
 
void SetName (const String &cName)
 Rename the handler. More...
 
LooperGetLooper () const
 Get a pointer to the looper this handler belongs to. More...
 
void SetNextHandler (Handler *pcNextHandler)
 Set a handler that should handle messages this handler is not interrested in. More...
 
HandlerGetNextHandler () const
 Get the next handler in a handler chain. More...
 
void AddFilter (MessageFilter *pcFilter)
 
void RemoveFilter (MessageFilter *pcFilter)
 
const MsgFilterListGetFilterList () const
 
const uint32 GetToken ()
 Get the handlers token. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from os::Looper
static LooperGetLooperForThread (thread_id hThread)
 
- Protected Member Functions inherited from os::Looper
bool FilterMessage (Message *pcMsg, Handler **ppcTarget, std::list< MessageFilter * > *pcFilterList)
 

Member Enumeration Documentation

anonymous enum
Enumerator
M_CHANGE_DIR 
M_COPY_FILES 
M_MOVE_FILES 
M_DELETE_FILES 
M_RENAME_FILES 
M_ENTRIES_ADDED 
M_ENTRIES_REMOVED 
M_ENTRIES_UPDATED 
M_LAYOUT_UPDATED 

Constructor & Destructor Documentation

DirKeeper::DirKeeper ( const Messenger cTarget,
const String cPath 
)

Member Function Documentation

Directory* os_priv::DirKeeper::GetCurrentDir ( )
inline
status_t DirKeeper::GetNode ( os::String  zPath,
os::FSNode pcNode,
bool *  pbBrokenLink 
)
void DirKeeper::HandleMessage ( Message pcMessage)
virtual
Description:
Overload this member to dispatch messages sendt to this handler. When a looper receives a message for one of it's handlers it will call the taget handlers HandleMessage() to allow the handler to dispatch the message.
The message passed in pcMessage is also available through os::Looper::GetCurrentMessage() and os::Looper::DetachCurrentMessage() until this member returns. This is normally not very usefull for HandleMessage() itself but it can be convinient for other members called from HandleMessage() in case they need data from the message that was not passed on from HandleMessage().
The looper will be locked when this member is called. The default implementation of this member will pass the message on to the next handler if one was set with SetNextHandler().
Note
Never do any lenthy operations in any hook members that are called from the looper thread if the looper is involved with the GUI (for example if the looper is a os::Window). The looper will not be able to dispatch messages until the hook returns so spending a long time in this members will make the GUI feel unresponsive.
Parameters
pcMessageThe message that should be handled. This message will be deleted by the looper when HandleMessage() returns unless you detach it with os::Looper::DetachCurrentMessage(),
See Also
os::Looper::DispatchMessage(), os::Looper::DetachCurrentMessage()
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx)

Reimplemented from os::Handler.

References os::Message::FindInt(), os::Message::FindInt32(), os::Message::FindInt64(), os::Message::FindString(), os::Message::GetCode(), os::FSNode::GetInode(), M_CHANGE_DIR, M_ENTRIES_ADDED, M_ENTRIES_REMOVED, M_ENTRIES_UPDATED, M_LAYOUT_UPDATED, M_NODE_MONITOR, os::Directory::Rewind(), os::NodeMonitor::SetTo(), Stop(), and os::NodeMonitor::Unset().

bool DirKeeper::Idle ( )
virtual
Description:
Normally the looper thread is blocked on the internal message queue waiting for messages. When one or more messages arrive it will wake up and process the messages. When all messages is processed it will first call Idle() and then go back looking for more messages. If Idle() returned false the thread will block until the next message arrive and if Idle() returned true it will just look for new messages without blocking and call Idle() again (after processing new messages if any).
Note:
The looper will not be able to process new messages until Idle() returns so it is very important to not do anything lengthy if the looper is part of for example an os::Window since that will make the application feel "unresponcive" to the user.
Returns
The Idle() function should return true if it want to be called again imediatly after the looper has polled for new messages, or false if it don't want to be called until at least one more message has been processed.
See Also
HandleMessage(), DispatchMessage()
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx)

Reimplemented from os::Looper.

References os::Volumes::GetFSInfo(), os::Volumes::GetMountPoint(), os::Volumes::GetMountPointCount(), os::Directory::GetNextEntry(), LAYOUT_TIME, os::String::Length(), os::Messenger::SendMessage(), and os::String::substr().

bool os_priv::DirKeeper::IsReading ( )
inline
void DirKeeper::Stop ( )