1 #ifndef INCLUDED_AUDIOIO_MANAGER_H
2 #define INCLUDED_AUDIOIO_MANAGER_H
3 
4 #include <string>
5 #include <list>
6 
7 class AUDIO_IO;
8 
9 /**
10  * Virtual base class for implementing audio object managers.
11  *
12  * Key tasks of an object manager are to recognize
13  * AUDIO_IO objects that are of the type it manages,
14  * provide a communication platform for inter-object
15  * communication, and tracking of objects.
16  *
17  * Related design patterns:
18  *     - Mediator (GoF273)
19  *
20  *�@author Kai Vehmanen
21  */
22 class AUDIO_IO_MANAGER : public DYNAMIC_OBJECT<std::string> {
23 
24  public:
25 
26   /** @name Public API */
27   /*@{*/
28 
29   /**
30    * Object name used to identify the object type. In most
31    * cases, object name is same for all class instances.
32    * Must be implemented in all subclasses.
33    */
34   virtual std::string name(void) const = 0;
35 
36   /**
37    * More verbose description of the manager type.
38    */
39   virtual std::string description(void) const = 0;
40 
41   /**
42    * Whether 'aobj' is of the type handled by this
43    * manager object?
44    *
45    * @pre aobj != 0
46    */
47   virtual bool is_managed_type(const AUDIO_IO* aobj) const = 0;
48 
49   /**
50    * Registers a new managed object.
51    *
52    * Ownership of the object is not transfered to this
53    * manager object. It's therefore important to release
54    * all managed objects before they are allocated.
55    * Otherwise the manager object could end up referencing
56    * invalid memory regions.
57    *
58    * @pre aobj != 0
59    * @post is_managed_type(aobj) == true
60    */
61   virtual void register_object(AUDIO_IO* aobj) = 0;
62 
63   /**
64    * Gets an integer id of the registered object 'aobj'.
65    *
66    * @return -1 if not a registered object
67    *
68    * @pre is_managed_type(aobj) == true
69    * @pre aobj != 0
70    */
71   virtual int get_object_id(const AUDIO_IO* aobj) const = 0;
72 
73   /**
74    * Returns a list of all registered object ids.
75    */
76   virtual std::list<int> get_object_list(void) const = 0;
77 
78   /**
79    * Unregisters object identified by 'id'.
80    *
81    * @post std::count(get_object_list().begin(), get_object_list().end(), id) == 0
82    */
83   virtual void unregister_object(int id) = 0;
84 
~AUDIO_IO_MANAGER(void)85   virtual ~AUDIO_IO_MANAGER(void) {}
86 
87   /*@}*/
88 
89 };
90 
91 #endif
92