Skip to content

Commit

Permalink
fix: completing method and parameters description
Browse files Browse the repository at this point in the history
  • Loading branch information
LucioDonda committed Aug 13, 2024
1 parent ce05ec6 commit a00b81c
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 77 deletions.
2 changes: 1 addition & 1 deletion src/agent/agent_queue/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ target_include_directories(AgentQueue PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include
target_link_libraries(AgentQueue PUBLIC nlohmann_json::nlohmann_json Boost::asio PRIVATE SQLiteCpp nlohmann_json::nlohmann_json fmt::fmt Boost::asio)

if(BUILD_TESTS)
enable_testing()
enable_testing()
add_subdirectory(tests)
endif()
65 changes: 36 additions & 29 deletions src/agent/agent_queue/include/agent_queue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ class PersistenceFactory
}
};

/**
* @brief
*
*/
class MultiTypeQueue
{
private:
Expand All @@ -59,7 +55,6 @@ class MultiTypeQueue
std::condition_variable m_cv;

public:
// Create a vector with 3 PersistedQueue elements
MultiTypeQueue(int size = DEFAULT_MAX, int timeout = DEFAULT_TIMEOUT_S)
: m_maxItems(size)
, m_timeout(timeout)
Expand All @@ -75,18 +70,29 @@ class MultiTypeQueue
}
}

// Delete copy constructor
/**
* @brief Delete copy constructor
*/
MultiTypeQueue(const MultiTypeQueue&) = delete;

// Delete copy assignment operator
/**
* @brief Delete copy assignment operator
*/
MultiTypeQueue& operator=(const MultiTypeQueue&) = delete;

// Delete move constructor
/**
* @brief Delete move constructor
*/
MultiTypeQueue(MultiTypeQueue&&) = delete;

// Delete move assignment operator
/**
* @brief Delete move assignment operator
*/
MultiTypeQueue& operator=(MultiTypeQueue&&) = delete;

/**
* @brief Destructor.
*/
~MultiTypeQueue() {};

/**
Expand All @@ -109,16 +115,17 @@ class MultiTypeQueue
/**
* @brief pushes a vector of messages
*
* @param messages to be pushed
* @param messages vector of messages to be pushed
* @param shouldWait when true, the function will wait until the message is pushed
* @return int number of messages pushed
*/
int push(std::vector<Message> messages);

/**
* @brief Get the Last Message object
* @brief Get the next Message object
*
* @param type of the queue to be used as source
* @param module module name
* @return Message type object taken from the queue
*/
Message getNext(MessageType type, const std::string module = "");
Expand All @@ -127,17 +134,18 @@ class MultiTypeQueue
* @brief Get the Next Awaitable object
*
* @param type of the queue to be used as source
* @param module module name
* @param moduleName module name
* @param messageQuantity quantity of messages to return
* @return boost::asio::awaitable<Message>
* @return boost::asio::awaitable<Message> awaitable object taken from the queue
*/
boost::asio::awaitable<Message>
getNextNAwaitable(MessageType type, int messageQuantity, const std::string moduleName = "");
getNextNAwaitable(MessageType type, int messageQuantity, const std::string moduleName = "");

/**
* @brief Returns N messages from a queue
*
* @param type Of the queue to be used as source
* @param moduleName
* @param moduleName module name
* @param messageQuantity quantity of messages to return
* @return Message Json data othe messages fetched
*/
Expand All @@ -148,26 +156,26 @@ class MultiTypeQueue
*
* @param type MessageType queue to pop
* @param moduleName
* @return true popped succesfully
* @return false wasn't able to pop message
* @return true when popped succesfully
* @return false if it wasn't able to pop message
*/
bool pop(MessageType type, const std::string moduleName = "");

/**
* @brief
* @brief deletes N messages from a queue
*
* @param type
* @param moduleName
* @param messageQuantity
* @param type MessageType queue to pop
* @param moduleName module name
* @param messageQuantity quantity of messages to pop
* @return Number of messages deleted
*/
int popN(MessageType type, int messageQuantity, const std::string moduleName = "");

/**
* @brief Checks emptyness of a queue
*
* @param type
* @param moduleName
* @param type MessageType
* @param moduleName module name
* @return true when queue empty
* @return false otherwise
*/
Expand All @@ -176,8 +184,8 @@ class MultiTypeQueue
/**
* @brief Checks fullness of a queue
*
* @param type
* @param moduleName
* @param type MessageType
* @param moduleName module name
* @return true when queue is full
* @return false otherwise
*/
Expand All @@ -186,10 +194,9 @@ class MultiTypeQueue
/**
* @brief Get the Items By Type object
*
* @param type
* @param moduleName
* @return true
* @return false
* @param type MessageType
* @param moduleName module name
* @return int number of items in the queue.
*/
int storedItems(MessageType type, const std::string moduleName = "");
};
Expand Down
58 changes: 29 additions & 29 deletions src/agent/agent_queue/include/persistence.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,61 +21,61 @@ class Persistence
virtual ~Persistence() = default;

/**
* @brief
* @brief Store a JSON message in the specified queue.
*
* @param message
* @param queueName
* @param moduleName
* @return int
* @param message The JSON message to be stored.
* @param queueName The name of the queue.
* @param moduleName The name of the module.
* @return int The number of messages stored.
*/
virtual int Store(const json& message, const std::string& queueName, const std::string& moduleName = "") = 0;

/**
* @brief
* @brief Retrieve a JSON message from the specified queue.
*
* @param id
* @param queueName
* @param moduleName
* @return json
* @param id rowid of the message to be retrieved.
* @param queueName The name of the queue.
* @param moduleName The name of the module.
* @return json The retrieved JSON message.
*/
virtual json Retrieve(int id, const std::string& queueName, const std::string& moduleName = "") = 0;

/**
* @brief
* @brief Retrieve multiple JSON messages from the specified queue.
*
* @param n
* @param queueName
* @param moduleName
* @return json
* @param n number of messages to be retrieved.
* @param queueName The name of the queue.
* @param moduleName The name of the module.
* @return json The retrieved JSON messages.
*/
virtual json RetrieveMultiple(int n, const std::string& queueName, const std::string& moduleName = "") = 0;

/**
* @brief
* @brief Remove a JSON message from the specified queue.
*
* @param id
* @param queueName
* @param moduleName
* @return int
* @param id number of messages to be removed.
* @param queueName The name of the queue.
* @param moduleName The name of the module.
* @return int The number of messages removed.
*/
virtual int Remove(int id, const std::string& queueName, const std::string& moduleName = "") = 0;

/**
* @brief
* @brief Remove multiple JSON messages from the specified queue.
*
* @param n
* @param queueName
* @param moduleName
* @return int
* @param n number of messages to be removed.
* @param queueName The name of the queue.
* @param moduleName The name of the module.
* @return int The number of messages removed.
*/
virtual int RemoveMultiple(int n, const std::string& queueName, const std::string& moduleName = "") = 0;

/**
* @brief Get the Element Count object
* @brief Get the quantity of elements stored in the specified queue.
*
* @param queueName
* @param moduleName
* @return int
* @param queueName The name of the queue.
* @param moduleName The name of the module.
* @return int The quantity of elements stored in the specified queue.
*/
virtual int GetElementCount(const std::string& queueName, const std::string& moduleName = "") = 0;
};
Expand Down
2 changes: 1 addition & 1 deletion src/agent/agent_queue/include/shared.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ enum MessageType
};

/**
* @brief Wrapper for Message data and type
* @brief Wrapper for Message, contains the message type, the json data and the module name.
*
*/
class Message
Expand Down
Loading

0 comments on commit a00b81c

Please sign in to comment.