1 /*---------------------------------------------------------------------------*
2   Project:  NintendoWare
3   File:     snd_Task.h
4 
5   Copyright (C)2009-2011 Nintendo/HAL Laboratory, Inc.  All rights reserved.
6 
7   These coded instructions, statements, and computer programs contain proprietary
8   information of Nintendo and/or its licensed developers and are protected by
9   national and international copyright laws. They may not be disclosed to third
10   parties or copied or duplicated in any form, in whole or in part, without the
11   prior written consent of Nintendo.
12 
13   The content herein is highly confidential and should be handled accordingly.
14 
15   $Revision: 31311 $
16  *---------------------------------------------------------------------------*/
17 
18 #ifndef NW_SND_TASK_H_
19 #define NW_SND_TASK_H_
20 
21 #include <nw/ut/ut_LinkList.h>      // ut::LinkListNode
22 #include <nw/ut/ut_PreProcessor.h>
23 
24 namespace nw {
25 namespace snd {
26 namespace internal {
27 
28 /* ========================================================================
29         Task class
30    ======================================================================== */
31 class TaskManager;
32 
33 class Task
34 {
35     friend class TaskManager;
36 
37 public:
38     enum Status {
39         STATUS_FREE,
40         STATUS_APPEND,
41         STATUS_EXECUTE,
42         STATUS_DONE,
43         STATUS_CANCEL
44     };
45 
46     Task();
47     virtual ~Task();
48 
SetId(u32 id)49     void SetId( u32 id ) { m_Id = id; }
GetStatus()50     Status GetStatus() const { return m_Status; }
51 
Wait()52     void Wait() { m_Event.Wait(); }
53 
54 protected:
55     // タスク処理を実装する
56     // NOTE: Execute関数内で、Taskインスタンスを解放しないこと
57     virtual void Execute() = 0;
58 
59 private:
60     NW_DISALLOW_COPY_AND_ASSIGN( Task );
61 
62     ut::LinkListNode m_TaskLink;
63     nn::os::LightEvent m_Event;
64     Status m_Status;
65     u32 m_Id;
66 };
67 
68 } // namespace nw::snd::internal
69 } // namespace nw::snd
70 } // namespace nw
71 
72 
73 #endif /* NW_SND_TASK_H_ */
74 
75