Add all of the doxygen documentation, fix lots of code nits.
authorbruceperens <bruceperens@01035d8c-6547-0410-b346-abe4f91aad63>
Thu, 16 Jan 2014 05:27:55 +0000 (05:27 +0000)
committerbruceperens <bruceperens@01035d8c-6547-0410-b346-abe4f91aad63>
Thu, 16 Jan 2014 05:27:55 +0000 (05:27 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@1356 01035d8c-6547-0410-b346-abe4f91aad63

13 files changed:
freedv-server/CMakeLists.txt
freedv-server/examples/.gitignore [new file with mode: 0644]
freedv-server/source/audio_sink.cpp
freedv-server/source/big_main.cpp
freedv-server/source/blank_panel.cpp
freedv-server/source/codec_noop.cpp
freedv-server/source/driver_manager.cpp
freedv-server/source/drivers.h
freedv-server/source/keying_sink.cpp
freedv-server/source/modem_noop.cpp
freedv-server/source/ptt_constant.cpp
freedv-server/source/text_constant.cpp
freedv-server/source/tone.cpp

index a01d54fed6ea7f09b26244ae9c8d4c9842a9a875..bc630b448c5d409e9da3bae038c4d43635db7ae9 100644 (file)
@@ -30,6 +30,8 @@ set(CMAKE_DISABLE_SOURCE_CHANGES ON)
 set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
 project(freedv-server)
 
+include(cmake/UseDoxygen.cmake)
+
 # Parameters are stored as .txt files in the parameters/ subdirectory.
 # They use semicolon to separate arguments, because this is what cmake uses
 # in its list type. Thus, parameters/version.txt looks like this:
diff --git a/freedv-server/examples/.gitignore b/freedv-server/examples/.gitignore
new file mode 100644 (file)
index 0000000..e69de29
index 0410d5786b621f4f8f07f8aac849a637a8945c06..0394bd69f7b26b29d61c0ed822fc16d621424213 100644 (file)
@@ -1,22 +1,24 @@
 #include "drivers.h"
 
-// Audio output "sink", discards the audio, for testing.
-
 namespace FreeDV {
+  /// Audio output "sink", discards the audio, for testing.
   class AudioSink : public AudioOutput {
   public:
 
+       /// Instantiate the audio sink.
                AudioSink(const char * parameters);
                ~AudioSink();
 
-       // Get the current audio level, normalized to the range of 0.0 to 1.0.
-       float   level();
+       /// Get the current audio level, normalized to the range of 0.0 to 1.0.
+       virtual float
+               level();
 
-       // Set the current audio level within the range of 0.0 to 1.0.
-       float   level(float value);
+       /// Set the current audio level within the range of 0.0 to 1.0.
+       virtual void
+               level(float value);
 
-        // Write audio into the "short" type.
-       std::size_t
+        /// Write audio into the "short" type.
+       virtual std::size_t
                write16(const int16_t * array, std::size_t length);
   };
 
@@ -35,10 +37,9 @@ namespace FreeDV {
     return 0;
   }
 
-  float
+  void
   AudioSink::level(float value)
   {
-    return value;
   }
 
   // Write audio into the "short" type.
index 59cd0fe105a77af7a2156e9e99441d0c711f7940..7e22f45eb7224c232dabdfdd062ed3ff9c25460a 100644 (file)
@@ -1,14 +1,13 @@
 #ifndef NO_INITIALIZERS
-/*
- * This is the main program for applications that are not space-limited.
- * Any application that is space limited should have its own main that
- * wires drivers to the Interfaces class without using DriverManager.
- * Thus, you can get rid of all of the STL template use, etc.
- *
- * For the sake of correctness and optimization, I have written whatever I
- * can to be without side-effects, a style inherited from functional programming.
- * Thus, the excessive use of "const". - Bruce
- */
+/// This is the main program for applications that are not space-limited.
+/// Any application that is space limited should have its own main that
+/// wires drivers to the Interfaces class without using DriverManager.
+/// Thus, you can get rid of all of the STL template use, etc.
+///
+/// For the sake of correctness and optimization, I have written whatever I
+/// can to be without side-effects, a style inherited from functional
+/// programming. Thus, the excessive use of "const". - Bruce
+
 #include <stdlib.h>
 #include <string.h>
 #include <iostream>
@@ -20,6 +19,7 @@
 
 using namespace std;
 namespace FreeDV {
+  /// Run the main loop of the program, this is called after arguments are set.
   extern int run(struct Interfaces *);
 }
 using namespace FreeDV;
index b2da0171025a42192a8c01198bde1822c95460a6..81cb7a25129a5510f92205c6fe2533f28e77be93 100644 (file)
@@ -1,8 +1,11 @@
 #include "drivers.h"
 
 namespace FreeDV {
+  /// This is control-less GUI driver, for testing.
   class BlankPanel : public UserInterface {
   public:
+
+    /// Instantiate the blank panel GUI driver.
                        BlankPanel(const char * parameter, Interfaces * interfaces);
     virtual            ~BlankPanel();
     
index 74dab64e1cdbe48db0439efe8221360f05f94937..3ad767f8de9480de7d735387af1f2e813257a19f 100644 (file)
@@ -1,10 +1,11 @@
 #include "drivers.h"
 
-// Codec "no-op", just copies its input to its output. For plain SSB voice, and for testing.
 namespace FreeDV {
+  /// Codec "no-op", just copies its input to its output. For plain SSB voice, and for testing.
   class CodecNoOp : public Codec {
   public:
 
+       /// Instantiate the no-op codec.
                CodecNoOp(const char *);
                ~CodecNoOp();
 
@@ -14,6 +15,8 @@ namespace FreeDV {
        /// \param i The array of audio samples to be encoded, in an array
        /// of signed 16-bit integers.
        /// \param o The encoded data, in an array of unsigned 8-bit integers.
+       /// \param length The number of audio samples to be encoded.
+       ///  This  must be a multiple of frame_size().
        /// \return The number of uint8_t elements in the encoded array.
        virtual std::size_t
                encode16(const int16_t * i, uint8_t * o, \
index f6442267c7de15f8c343d4fb793b6ed6feb8413e..324e5e43c391cb6700ad718ef7bb3b3c28bc1923 100644 (file)
@@ -188,7 +188,9 @@ namespace FreeDV {
     user_interface_drivers[driver] = creator;
   }
 
-  // This has to be a function to get around the static initalization order problem.
+  /// Automatic initializer for the driver manager.
+  /// This has to be a function to get around the static initalization order
+  /// problem.
   DriverManager &
   init_driver_manager()
   {
@@ -196,6 +198,7 @@ namespace FreeDV {
     return manager;
   }
 
+  /// Global reference to the driver manager instance.
   DriverManager & driver_manager = init_driver_manager();
 }
 #endif
index 3f91c7b78493766f818bf794e35e856f2d371c93..53f368f494d2dd49d75b3c6110bc2d80ab010f29 100644 (file)
@@ -64,7 +64,7 @@ namespace FreeDV {
 
        /// Set the current audio level.
        /// The value must be within the range of 0.0 to 1.0.
-       virtual float   level(float value) = 0;
+       virtual void    level(float value) = 0;
 
         /// Write audio from an array of the signed 16-bit integer type.
        virtual std::size_t
@@ -88,6 +88,7 @@ namespace FreeDV {
        /// \param i The array of audio samples to be encoded, in an array
        /// of signed 16-bit integers.
        /// \param o The encoded data, in an array of unsigned 8-bit integers.
+       /// \param length The number of audio samples to be encoded.
        /// \return The number of uint8_t elements in the encoded array.
        virtual std::size_t
                        encode16(const int16_t * i, uint8_t * o, \
@@ -140,7 +141,11 @@ namespace FreeDV {
        /// This is a simplification on all of the values that POSIX
        /// poll() can return. Events that aren't read or write are mapped
        /// to one of those.
+
+       /// File being monitored is readable or has read error.
        const unsigned int Read = 1;
+
+       /// File being monitored is writable or has write error.
        const unsigned int Write = 2;
 
        /// Create an event handler instance.
@@ -150,6 +155,9 @@ namespace FreeDV {
                        }
        virtual         ~EventHandler() = 0;
 
+       /// If set_exit() has been called, return true once.
+       /// \return True if set_exit has been called. The next and subsequent
+       ///  calls will return false until set_exit() is called again.
        inline bool     get_exit() {
                          if ( do_exit ) {
                            do_exit = false;
@@ -167,6 +175,7 @@ namespace FreeDV {
        /// implementation of loop() must not call iterate().
        void            iterate();
 
+       /// Cause get_exit() to return true the next time it is called.
        inline void     set_exit() { do_exit = true; }
   public:
        /// Return true if this object is owned by a UserInterface object.
@@ -240,17 +249,21 @@ namespace FreeDV {
   /// Push-to-talk input driver.
   class PTTInput {
   private:
+       /// Coroutine to be called when the sense of the push-to-talk switch
+       /// changes.
        void    (*callback)(bool);
 
   protected:
-       // The driver calls this member to inform FreeDV that the PTT switch value has changed.
-       // the value is true for key-down, false for key-up.
+       /// The driver calls this member to inform FreeDV that the PTT switch
+       /// sense has changed. The value is true for key-down,
+       /// false for key-up.
+       /// \param value True for key-down, false for key-up.
        void            changed(bool value);
 
        /// Create a push-to-talk switch instance.
        /// \param parameters Driver-specific configuration parameters.
-
                        PTTInput(const char * parameters);
+
        virtual         ~PTTInput() = 0;
 
   public:
@@ -263,13 +276,15 @@ namespace FreeDV {
        virtual bool const
                        captive() const;
 
+       /// Set the function that will be called when the push-to-talk input
+       /// changes its value.
        void            set_callback(void (*value)(bool));
   };
 
   /// Driver for the text message source function.
   class TextInput {
   protected:
-       // The driver calls this member to set the text.
+       /// The child class calls this member in its parent to set the text.
        void            set(const char * text);
 
 
@@ -326,17 +341,29 @@ namespace FreeDV {
                        {
                        }
 
+    /// The voice codec in use.
     Codec *            codec;
+    /// The event loop handler. This is specific to a GUI, or POSIX.
     EventHandler *     event_handler;
+    /// The output used to key the transmitter.
     Keying *           keying_output;
+    /// The audio output which drives the loudspeaker or headphone.
     AudioOutput *      loudspeaker;
+    /// The audio input from the microphone.
     AudioInput *       microphone;
+    /// The softmodem.
     Modem *            modem;
+    /// The PTT input that indicates the transmission is to be digital audio.
     PTTInput *         ptt_input_digital;
+    /// The PTT input that indicates the transmission is to be SSB.
     PTTInput *         ptt_input_ssb;
+    /// The text to be transmitted in our text side-channel.
     TextInput *                text;
+    /// The audio output that drives the transmitter.
     AudioOutput *      transmitter;
+    /// The audio input from the receiver.
     AudioInput *       receiver;
+    /// The user interface driver. Used for GUIs.
     UserInterface *    user_interface;
   };
 }
@@ -361,32 +388,90 @@ namespace FreeDV {
                        std::map<std::string, TextInput *(*)(const char *)> text_input_drivers;
                        std::map<std::string, UserInterface *(*)(const char *, Interfaces *)> user_interface_drivers;
   public:
+
+       /// Initialize the driver manager.
                        DriverManager();
                        ~DriverManager();
 
-        void           print(std::ostream &);
+       /// Print the available drivers to the argument stream.
+       /// \param stream A reference to an instance of ostream on which the
+       ///  information is to be printed.
+        void           print(std::ostream & stream);
 
-       AudioInput *    audio_input(const char * driver, const char * parameter);
-       AudioOutput *   audio_output(const char * driver, const char * parameter);
-       Codec *         codec(const char * driver, const char * parameter);
-       Keying *        keying_output(const char * driver, const char * parameter);
-       Modem *         modem(const char * driver, const char * parameter);
-       PTTInput *      ptt_input(const char * driver, const char * parameter);
-       TextInput *     text_input(const char * driver, const char * parameter);
-       UserInterface * user_interface(const char * driver, const char * parameter, Interfaces * interfaces);
+       /// Instantiate an AudioInput driver.
+       /// \param driver The name of the driver.
+       /// \param parameters Driver-specific configuration parameters.
+       AudioInput *    audio_input(const char * driver, const char * parameters);
+       /// Instantiate an AudioOutput driver.
+       /// \param driver The name of the driver.
+       /// \param parameters Driver-specific configuration parameters.
+       AudioOutput *   audio_output(const char * driver, const char * parameters);
+       /// Instantiate a Codec.
+       /// \param driver The name of the driver.
+       /// \param parameters Driver-specific configuration parameters.
+       Codec *         codec(const char * driver, const char * parameters);
+       /// Instantiate a Keying driver.
+       /// \param driver The name of the driver.
+       /// \param parameters Driver-specific configuration parameters.
+       Keying *        keying_output(const char * driver, const char * parameters);
+       /// Instantiate a softmodem.
+       /// \param driver The name of the driver.
+       /// \param parameters Driver-specific configuration parameters.
+       Modem *         modem(const char * driver, const char * parameters);
+       /// Instantiate a PTT input driver.
+       /// \param driver The name of the driver.
+       /// \param parameters Driver-specific configuration parameters.
+       PTTInput *      ptt_input(const char * driver, const char * parameters);
+       /// Instantiate a text input driver.
+       /// \param driver The name of the driver.
+       /// \param parameters Driver-specific configuration parameters.
+       TextInput *     text_input(const char * driver, const char * parameters);
+       /// Instantiate a user interface driver.
+       /// \param driver The name of the driver.
+       /// \param parameters Driver-specific configuration parameters.
+       /// \param interfaces Interfaces object used to hold all of the
+       ///  current device driver instances.
+       UserInterface * user_interface(const char * driver, const char * parameters, Interfaces * interfaces);
 
+       /// Register an audio input driver.
+       /// \param driver The name of the driver.
+       /// \param creator The coroutine that will instantiate the driver.
        void            register_audio_input(const char * driver, AudioInput * (*creator)(const char *));
+       /// Register an audio input driver.
+       /// \param driver The name of the driver.
+       /// \param creator The coroutine that will instantiate the driver.
        void            register_audio_output(const char * driver, AudioOutput * (*creator)(const char *));
+       /// Register an audio input driver.
+       /// \param driver The name of the driver.
+       /// \param creator The coroutine that will instantiate the driver.
        void            register_codec(const char * driver, Codec * (*creator)(const char *));
+       /// Register an audio input driver.
+       /// \param driver The name of the driver.
+       /// \param creator The coroutine that will instantiate the driver.
        void            register_keying_output(const char * driver, Keying * (*creator)(const char *));
+       /// Register an audio input driver.
+       /// \param driver The name of the driver.
+       /// \param creator The coroutine that will instantiate the driver.
        void            register_modem(const char * driver, Modem * (*creator)(const char *));
+       /// Register an audio input driver.
+       /// \param driver The name of the driver.
+       /// \param creator The coroutine that will instantiate the driver.
        void            register_ptt_input(const char * driver, PTTInput * (*creator)(const char *));
+       /// Register an audio input driver.
+       /// \param driver The name of the driver.
+       /// \param creator The coroutine that will instantiate the driver.
        void            register_text_input(const char * driver, TextInput * (*creator)(const char *));
+       /// Register an audio input driver.
+       /// \param driver The name of the driver.
+       /// \param creator The coroutine that will instantiate the driver.
        void            register_user_interface(const char * driver, UserInterface * (*creator)(const char *, Interfaces *));
   };
 
+  /// Global reference to the driver manager.
   extern DriverManager & driver_manager;
-  // This version has to be called from static initializers.
+
+  /// Return a reference to the driver manager instance.
+  /// This is a function because it is called in static initializers.
   extern DriverManager & init_driver_manager();
 #endif
 }
index 8f8cf9f423b71b1d1429792c652673ed748bac76..ad6bfa5ff549954cf22d5b28b3824a7e6a87e915 100644 (file)
@@ -1,14 +1,16 @@
 #include "drivers.h"
 
-// Keying output "sink", doesn't key anything. For testing or use with VOX.
 namespace FreeDV {
+  /// Keying output "sink", doesn't key anything. For testing or use with VOX.
   class KeyingSink : public Keying {
   public:
 
+       /// Instantiate keying sink driver.
                KeyingSink(const char *);
-               ~KeyingSink();
+       virtual ~KeyingSink();
 
-       void    key(bool value);
+       virtual void
+               key(bool value);
 
   };
 
index 4ce4dc2576c57df4f754f848222b9781e5541e11..ceea431d4bbd6e96bf26472827a6fcfe225703a1 100644 (file)
@@ -1,15 +1,14 @@
 #include "drivers.h"
 
-// Modem "no-op", just copies its input to its output. For plain SSB voice, and for testing.
 namespace FreeDV {
+  /// Modem "no-op", just copies its input to its output.
+  /// For plain SSB voice, and for testing.
   class ModemNoOp : public Modem {
   public:
 
+       /// Instantiate the no-op modem.
                ModemNoOp(const char *);
-               ~ModemNoOp();
-
-       void    key(bool value);
-
+       virtual ~ModemNoOp();
   };
 
   ModemNoOp::ModemNoOp(const char * parameters)
index 4f3ac4c66e142ebe9a5977b22299c4f306e5140a..82eae6ff3c25f9c3f86bb5c9c40b58919db35a4d 100644 (file)
@@ -1,9 +1,10 @@
 #include "drivers.h"
 
-// PTT driver that is constant transmit or constant receive. For testing.
 namespace FreeDV {
+   /// PTT driver that is constant transmit or constant receive. For testing.
   class PTTConstant : public PTTInput {
   public:
+    /// Instantiate push-to-talk source with constant input, for testing.
                        PTTConstant(const char * parameters);
     virtual            ~PTTConstant();
     
index ea5fa14e80b88264dfa39c3bdbea1debe5ac9379..d493bc6d61b67be9d9f3b5d6a974e3d55f4bae5a 100644 (file)
@@ -1,9 +1,10 @@
 #include "drivers.h"
 
-// This is a test driver that provides tones.
 namespace FreeDV {
+  /// This driver provides constant text.
   class TextConstant : public TextInput {
   public:
+    /// Instantiate the constant text driver.
                        TextConstant(const char * parameter);
     virtual            ~TextConstant();
     
index 464315180e264fda18dce907e69880d46ce2dac2..1412b70308a64525bcfde105937a895bbb9acda8 100644 (file)
@@ -1,9 +1,10 @@
 #include "drivers.h"
 
-// This is a test driver that provides tones.
 namespace FreeDV {
+  /// This is a test driver that provides tones.
   class Tone : public AudioInput {
   public:
+    /// Instantiate the tone driver.
                        Tone(const char * parameter);
     virtual            ~Tone();