Skip to content

Commit

Permalink
Added Doxygen Documentation
Browse files Browse the repository at this point in the history
Signed-off-by: ZigRazor <zigrazor@gmail.com>
  • Loading branch information
ZigRazor committed May 23, 2024
1 parent 4f3beb9 commit f1609d8
Show file tree
Hide file tree
Showing 6 changed files with 279 additions and 1 deletion.
27 changes: 27 additions & 0 deletions include/AbstractSubscriber.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
/**
* @file AbstractSubscriber.h
* @author ZigRazor (zigrazor@gmail.com)
* @brief Abstract Subscriber
* @version 0.1
* @date 2024-05-23
*
* @copyright Copyright (c) 2024
*
*/
#ifndef DOGBREEDS_JACKRUSSELL_ABSTRACTSUBSCRIBER_H
#define DOGBREEDS_JACKRUSSELL_ABSTRACTSUBSCRIBER_H

Expand All @@ -7,12 +17,29 @@

namespace DogBreeds {
namespace JackRussell {
/**
* @brief Abstract Subscriber Class
*
*/
class AbstractSubscriber {
private:
/**
* @brief Name of the Subscriber
*
*/
std::string m_name;

public:
/**
* @brief Construct a new Abstract Subscriber object
*
* @param name the name of the subscriber
*/
AbstractSubscriber(const std::string& name);
/**
* @brief Destroy the Abstract Subscriber object
*
*/
virtual ~AbstractSubscriber() = default;
};
} // namespace JackRussell
Expand Down
57 changes: 57 additions & 0 deletions include/AbstractTopic.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
/**
* @file AbstractTopic.h
* @author ZigRazor (zigrazor@gmail.com)
* @brief Abstract Topic
* @version 0.1
* @date 2024-05-23
*
* @copyright Copyright (c) 2024
*
*/
#ifndef DOGBREEDS_JACKRUSSELL_ABSTRACTTOPIC_H
#define DOGBREEDS_JACKRUSSELL_ABSTRACTTOPIC_H

Expand All @@ -10,22 +20,69 @@

namespace DogBreeds {
namespace JackRussell {
// Foward Declaration
class TopicManager;
/**
* @brief Abstract Topic Class
*
*/
class AbstractTopic {
friend class TopicManager;

protected:
/**
* @brief The Topic Name
*
*/
std::string m_name;
/**
* @brief Mutex for Subscriber List
*
*/
std::mutex m_subscriberListMutex;
/**
* @brief Subscriber List
*
*/
std::list<std::shared_ptr<AbstractSubscriber>> m_subscriberList;

/**
* @brief Construct a new Abstract Topic object
*
* @param topic_name the topic name
*/
AbstractTopic(std::string topic_name);

public:
/**
* @brief Destroy the Abstract Topic object
*
*/
virtual ~AbstractTopic() = default;

/**
* @brief Get the Name object
*
* @return const std::string& The Topic Name
*/
const std::string& getName() const;
/**
* @brief Add Subscriber
*
* @param sub the shared_ptr of the Subscriber to add
* @return ResultCode OK if the subscriber is added,
* SUBSCRIBER_IS_ALREADY_SUBSCRIBED_TO_TOPIC if the subscriber is already
* subscribed
*/
ResultCode addSubscriber(std::shared_ptr<AbstractSubscriber> sub);
/**
* @brief Remove Subscriber
*
* @param sub the shared_ptr of the Subscriber to Remove
* @return ResultCode OK if the subscriber is removed,
* SUBSCRIBER_NOT_FOUND_IN_TOPIC if the subscriber isn't subscribed to the
* topic
*/
ResultCode removeSubscriber(std::shared_ptr<AbstractSubscriber> sub);
// template<typename T>
// ResultCode publish(std::shared_ptr<T> message);
Expand Down
39 changes: 38 additions & 1 deletion include/ResultCode.h
Original file line number Diff line number Diff line change
@@ -1,17 +1,54 @@
/**
* @file ResultCode.h
* @author ZigRazor (zigrazor@gmail.com)
* @brief Result Code Enumeration
* @version 0.1
* @date 2024-05-23
*
* @copyright Copyright (c) 2024
*
*/
#ifndef DOGBREEDS_JACKRUSSELL_RESULTCODE_H
#define DOGBREEDS_JACKRUSSELL_RESULTCODE_H

namespace DogBreeds {
namespace JackRussell {
/**
* @brief Result Code Enum Class
*
*/
enum class ResultCode {
/**
* @brief Ok
*
*/
OK,
/**
* @brief Generic Error
*
*/
GENERIC_ERROR,
/**
* @brief Topic Not Found Error
*
*/
TOPIC_NOT_FOUND,
/**
* @brief Topic Already Exist Error
*
*/
TOPIC_ALREDY_EXIST,
/**
* @brief Subscriber Not Found in Topic Error
*
*/
SUBSCRIBER_NOT_FOUND_IN_TOPIC,
/**
* @brief Subscriber Is Already Subscribed To Topic Error
*
*/
SUBSCRIBER_IS_ALREADY_SUBSCRIBED_TO_TOPIC
};

}
} // namespace DogBreeds

Expand Down
31 changes: 31 additions & 0 deletions include/Subscriber.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
/**
* @file Subscriber.hpp
* @author ZigRazor (zigrazor@gmail.com)
* @brief Subscriber
* @version 0.1
* @date 2024-05-23
*
* @copyright Copyright (c) 2024
*
*/
#ifndef DOGBREEDS_JACKRUSSELL_SUBSCRIBER_H
#define DOGBREEDS_JACKRUSSELL_SUBSCRIBER_H

Expand All @@ -8,12 +18,33 @@

namespace DogBreeds {
namespace JackRussell {
/**
* @brief Subscriber Class
*
* @tparam T the type of the Subscriber
*/
template <typename T>
class Subscriber : public AbstractSubscriber {
private:
public:
/**
* @brief Construct a new Subscriber object
*
* @param name the subscriber name
*/
Subscriber(const std::string& name) : AbstractSubscriber(name) {}
/**
* @brief Destroy the Subscriber object
*
*/
virtual ~Subscriber() = default;
/**
* @brief Manage the received Callback when a message is sent
*
* this virtual function must be overriden by the derived class
*
* @param message the incoming message
*/
virtual void onMessage(std::shared_ptr<T> message) = 0;
};
} // namespace JackRussell
Expand Down
39 changes: 39 additions & 0 deletions include/Topic.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
/**
* @file Topic.hpp
* @author ZigRazor (zigrazor@gmail.com)
* @brief The Topic
* @version 0.1
* @date 2024-05-23
*
* @copyright Copyright (c) 2024
*
*/
#ifndef DOGBREEDS_JACKRUSSELL_TOPIC_H
#define DOGBREEDS_JACKRUSSELL_TOPIC_H

Expand All @@ -15,14 +25,33 @@

namespace DogBreeds {
namespace JackRussell {
// Foward Declaration
class TopicManager;
/**
* @brief The Topic Class
*
* @tparam T The Topic Type
*/
template <typename T>
class Topic : public AbstractTopic {
friend class TopicManager;

private:
/**
* @brief the Queue where the message are published
*
*/
std::shared_ptr<Labrador::ConcurrentQueue<std::shared_ptr<T>>> queue;
/**
* @brief the Queue processor that process the message published
*
*/
std::unique_ptr<Labrador::QueueProcessor<std::shared_ptr<T>>> queueProcessor;
/**
* @brief Construct a new Topic object
*
* @param topic_name the Topic Name
*/
Topic(std::string topic_name) : AbstractTopic(topic_name) {
queue = std::make_shared<Labrador::ConcurrentQueue<std::shared_ptr<T>>>();
queueProcessor =
Expand All @@ -38,8 +67,18 @@ class Topic : public AbstractTopic {
}

public:
/**
* @brief Destroy the Topic object
*
*/
virtual ~Topic() = default;

/**
* @brief publish a message on topic queue
*
* @param message the message to publish
* @return ResultCode OK if all ok
*/
ResultCode publish(std::shared_ptr<T> message) {
queue->enqueue(message);
return ResultCode::OK;
Expand Down
Loading

0 comments on commit f1609d8

Please sign in to comment.