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