Overview   API Reference  

device_container.hpp

00001 #if !defined(__DEVICE_CONTAINER_HPP__)
00002 #define __DEVICE_CONTAINER_HPP__
00003 
00004 //
00005 // local includes
00006 //
00007 #include "core/common.hpp"
00008 
00012 template <typename DeviceT>
00013 struct device_container : private noncopyable
00014 {
00015     typedef DeviceT device_type;
00016     typedef vector<DeviceT *> collection_type;
00017     typedef typename collection_type::const_iterator const_iterator;
00018 
00019   protected:
00024     const int max_devices;
00025 
00031     const bool dense;
00032 
00036     collection_type devices;
00037 
00041     int num_devices;
00042 
00043   public:
00044     //
00045     // constructor & destructor
00046     //
00047     inline device_container(int max_devices=0, bool dense=true)
00048         : max_devices(max_devices), dense(dense), num_devices(0)
00049     {}
00050 
00051     virtual ~device_container(void);
00052 
00053     //
00054     // (const) iterator functions
00055     //
00059     virtual inline const_iterator begin(void) const
00060     {
00061         return devices.begin();
00062     }
00063 
00067     virtual inline const_iterator end(void) const
00068     {
00069         return devices.end();
00070     }
00071 
00072     //
00073     // device management functions
00074     //
00078     virtual int register_device(DeviceT *device);
00079 
00083     virtual int unregister_device(const DeviceT *device);
00084 
00088     virtual int reset_devices(void);
00089 };
00090 
00091 //
00092 // extern template declarations to prevent implicit instantiations
00093 //
00094 extern template struct device_container<struct device>;
00095 extern template struct device_container<struct pci_device>;
00096 
00097 #endif
00098 
00099 // ***** end of source ***** //
00100 

L4vmm Reference Manual, written by Mario Schwalbe  © 2006-2008