changeset 17636:738f9aa852a5 draft

(svn r22407) -Document: the "root" driver related stuff
author rubidium <rubidium@openttd.org>
date Sun, 01 May 2011 20:04:09 +0000 (2011-05-01)
parents 41ea7460de25
children 7fce3eb88c81
files src/driver.cpp src/driver.h
diffstat 2 files changed, 55 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/driver.cpp
+++ b/src/driver.cpp
@@ -31,6 +31,12 @@
 
 char *_ini_blitter;         ///< The blitter as stored in the configuration file.
 
+/**
+ * Get a string parameter the list of parameters.
+ * @param parm The parameters.
+ * @param name The parameter name we're looking for.
+ * @return The parameter value.
+ */
 const char *GetDriverParam(const char * const *parm, const char *name)
 {
 	size_t len;
@@ -49,11 +55,24 @@
 	return NULL;
 }
 
+/**
+ * Get a boolean parameter the list of parameters.
+ * @param parm The parameters.
+ * @param name The parameter name we're looking for.
+ * @return The parameter value.
+ */
 bool GetDriverParamBool(const char * const *parm, const char *name)
 {
 	return GetDriverParam(parm, name) != NULL;
 }
 
+/**
+ * Get an integer parameter the list of parameters.
+ * @param parm The parameters.
+ * @param name The parameter name we're looking for.
+ * @param def  The default value if the parameter doesn't exist.
+ * @return The parameter value.
+ */
 int GetDriverParamInt(const char * const *parm, const char *name, int def)
 {
 	const char *p = GetDriverParam(parm, name);
@@ -173,6 +192,9 @@
 
 /**
  * Build a human readable list of available drivers, grouped by type.
+ * @param p The buffer to write to.
+ * @param last The last element in the buffer.
+ * @return The end of the written buffer.
  */
 char *DriverFactoryBase::GetDriversInfo(char *p, const char *last)
 {
--- a/src/driver.h
+++ b/src/driver.h
@@ -20,10 +20,19 @@
 bool GetDriverParamBool(const char * const *parm, const char *name);
 int GetDriverParamInt(const char * const *parm, const char *name, int def);
 
+/** A driver for communicating with the user. */
 class Driver {
 public:
+	/**
+	 * Start this driver.
+	 * @param parm Parameters passed to the driver.
+	 * @return NULL if everything went okay, otherwise an error message.
+	 */
 	virtual const char *Start(const char * const *parm) = 0;
 
+	/**
+	 * Stop this driver.
+	 */
 	virtual void Stop() = 0;
 
 	virtual ~Driver() { }
@@ -37,32 +46,50 @@
 		DT_END,       ///< Helper for iteration
 	};
 
+	/**
+	 * Get the name of this driver.
+	 * @return The name of the driver.
+	 */
 	virtual const char *GetName() const = 0;
 };
 
 DECLARE_POSTFIX_INCREMENT(Driver::Type)
 
 
+/** Base for all driver factories. */
 class DriverFactoryBase {
 private:
-	Driver::Type type;
-	const char *name;
-	int priority;
+	Driver::Type type; ///< The type of driver.
+	const char *name;  ///< The name of the drivers of this factory.
+	int priority;      ///< The priority of this factory.
 
-	typedef std::map<const char *, DriverFactoryBase *, StringCompare> Drivers;
+	typedef std::map<const char *, DriverFactoryBase *, StringCompare> Drivers; ///< Type for a map of drivers.
 
+	/**
+	 * Get the map with drivers.
+	 */
 	static Drivers &GetDrivers()
 	{
 		static Drivers &s_drivers = *new Drivers();
 		return s_drivers;
 	}
 
+	/**
+	 * Get the active driver for the given type.
+	 * @param type The type to get the driver for.
+	 * @return The active driver.
+	 */
 	static Driver **GetActiveDriver(Driver::Type type)
 	{
 		static Driver *s_driver[3] = { NULL, NULL, NULL };
 		return &s_driver[type];
 	}
 
+	/**
+	 * Get the driver type name.
+	 * @param type The type of driver to get the name of.
+	 * @return The name of the type.
+	 */
 	static const char *GetDriverTypeName(Driver::Type type)
 	{
 		static const char * const driver_type_name[] = { "music", "sound", "video" };
@@ -95,11 +122,13 @@
 
 	/**
 	 * Get a nice description of the driver-class.
+	 * @return The description.
 	 */
 	virtual const char *GetDescription() = 0;
 
 	/**
 	 * Create an instance of this driver-class.
+	 * @return The instance.
 	 */
 	virtual Driver *CreateInstance() = 0;
 };