summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Bergli Heier <snakebite@jvnv.net>2011-01-04 03:17:45 +0100
committerJon Bergli Heier <snakebite@jvnv.net>2011-01-04 03:17:45 +0100
commitf0db6a4e4e6b3059c6553b819ac8788b62486103 (patch)
treec449ef54f745c4a4994d815579c69c0790bc26b1
parent2b03b8ef2b5002f00960d17c8f1f634eb3a3a70f (diff)
Added Doxyfile and documentation comments in various places.
-rw-r--r--.gitignore1
-rw-r--r--Doxyfile12
-rw-r--r--commands.cpp3
-rw-r--r--commands.h2
-rw-r--r--decoder.cpp1
-rw-r--r--decoder.h1
-rw-r--r--encoder.cpp1
-rw-r--r--encoder.h1
-rw-r--r--music.cpp10
-rw-r--r--music.h4
-rw-r--r--telnet_connection.cpp3
11 files changed, 39 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index c2fa971..85183e8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,6 +3,7 @@
*.conf
*.sock
*.vim
+/doc
/audistd
.sconf_temp
.sconsign.dblite
diff --git a/Doxyfile b/Doxyfile
new file mode 100644
index 0000000..f57464b
--- /dev/null
+++ b/Doxyfile
@@ -0,0 +1,12 @@
+PROJECT_NAME = audist
+
+OUTPUT_DIRECTORY = doc
+HTML_OUTPUT = .
+GENERATE_LATEX = NO
+
+TAB_SIZE = 4
+
+QUIET = YES
+
+EXTRACT_ALL = YES
+EXTRACT_PRIVATE = YES
diff --git a/commands.cpp b/commands.cpp
index 3000f31..84c1e5f 100644
--- a/commands.cpp
+++ b/commands.cpp
@@ -78,6 +78,9 @@ Commands::Commands(boost::asio::io_service& io_service_, std::vector<std::string
handlers["update"] = &Commands::update;
}
+/** Invokes the command and returns its results.
+ * Throws CommandException if the command isn't found.
+ */
std::vector<std::string> Commands::operator()() {
assert(args.size());
Handler h = handlers[args[0]];
diff --git a/commands.h b/commands.h
index 084dd02..78ecf48 100644
--- a/commands.h
+++ b/commands.h
@@ -25,9 +25,11 @@ class Commands {
std::map<std::string, Handler> handlers;
typedef boost::function<std::vector<MusicListing::p> (const std::string artist)> FindFunction;
+ //! Handlers for the find command.
std::map<std::string, FindFunction> find_handlers;
boost::asio::io_service& io_service;
+ //! Command arguments.
std::vector<std::string>& args;
std::vector<std::string> ls();
diff --git a/decoder.cpp b/decoder.cpp
index 420d538..f01215b 100644
--- a/decoder.cpp
+++ b/decoder.cpp
@@ -18,6 +18,7 @@ void decoder::init() {
decoder_factories["mpg123"] = boost::factory<boost::shared_ptr<DecoderMpg123> >();
}
+//! Construct a filter with the given decoder.
DecoderFilter::p decoder::get_decoder(const std::string& name) {
return DecoderFilter::p(new DecoderFilter(DecoderBase::p(decoder_factories[name]())));
}
diff --git a/decoder.h b/decoder.h
index c894065..25dbe56 100644
--- a/decoder.h
+++ b/decoder.h
@@ -13,6 +13,7 @@ class DecoderBase {
virtual size_t decode(const uint8_t *input, size_t input_size, uint8_t *output, size_t output_size) = 0;
};
+//! Input filter to hold a decoder in a filter chain.
class DecoderFilter : public boost::iostreams::multichar_input_filter {
private:
DecoderBase::p decoder;
diff --git a/encoder.cpp b/encoder.cpp
index 0c0350a..cd37daa 100644
--- a/encoder.cpp
+++ b/encoder.cpp
@@ -17,6 +17,7 @@ void encoder::init() {
encoder_factories["lame"] = boost::factory<boost::shared_ptr<EncoderLame> >();
}
+//! Construct a filter with the given encoder.
EncoderFilter::p encoder::get_encoder(const std::string& name) {
return EncoderFilter::p(new EncoderFilter(EncoderBase::p(encoder_factories[name]())));
}
diff --git a/encoder.h b/encoder.h
index 14ecfeb..52c50ab 100644
--- a/encoder.h
+++ b/encoder.h
@@ -15,6 +15,7 @@ class EncoderBase {
virtual size_t flush(uint8_t *output, size_t output_size) = 0;
};
+//! Input filter to hold an encoder in a filter chain.
class EncoderFilter : public boost::iostreams::multichar_input_filter {
private:
EncoderBase::p encoder;
diff --git a/music.cpp b/music.cpp
index 3faca9c..eb16226 100644
--- a/music.cpp
+++ b/music.cpp
@@ -24,6 +24,10 @@ void music::init(std::string root) {
root_directory = root;
}
+/** Fetches a MusicListing object from the given path.
+ * Prefixes the given path with the music root directory.
+ * This can be either a track (file) or a directory.
+ */
MusicListing::p music::get(const HTTP::Connection::PathList& path) {
// prefix path with our root_directory
fs::path p = root_directory;
@@ -48,12 +52,18 @@ MusicListing::p music::get(const HTTP::Connection::PathList& path) {
return MusicListing::p();
}
+/** Fetches a MusicListing object from the given path.
+ * Splits the given string and calls the above function.
+ */
MusicListing::p music::get(const std::string& path) {
HTTP::Connection::PathList path_vector;
boost::algorithm::split(path_vector, path, boost::algorithm::is_any_of("/\\"));
return get(path_vector);
}
+/** Fetches a directory.
+ * This is a helper function which returns a null pointer if the fetched MusicListing isn't a directory.
+ */
MusicDirectory::p music::get_directory(const std::string& path) {
MusicListing::p ml = get(path);
if(!ml || !fs::is_directory(ml->path)) {
diff --git a/music.h b/music.h
index c019136..ed47657 100644
--- a/music.h
+++ b/music.h
@@ -9,19 +9,23 @@
namespace fs = boost::filesystem;
+//! Generalized abstract class for music content.
class MusicListing {
public:
typedef boost::shared_ptr<MusicListing> p;
fs::path path;
+ //! Render the content for HTTP transport.
virtual void render(HTTP::Connection::p req) = 0;
};
+//! Represents a track.
class MusicTrack : public MusicListing {
public:
MusicTrack(const fs::path path);
virtual void render(HTTP::Connection::p req);
};
+//! Represents a directory.
class MusicDirectory : public MusicListing {
public:
typedef boost::shared_ptr<MusicDirectory> p;
diff --git a/telnet_connection.cpp b/telnet_connection.cpp
index 2cc723e..8d6675d 100644
--- a/telnet_connection.cpp
+++ b/telnet_connection.cpp
@@ -51,6 +51,9 @@ void telnet::Connection::handle_read(const boost::system::error_code& error, siz
start();
}
+/** Parse a given line and return a vector with its arguments.
+ * Arguments which are surrounded by "quotes" are interpreted as a single argument.
+ */
std::vector<std::string> telnet::Connection::parse_args(std::string& line) {
std::string::const_iterator begin = line.begin();
std::string::const_iterator end = line.end();