Browse Source

Update doxygen properties in code.

tags/version/0.1.15
Kai Kretschmann 5 months ago
parent
commit
6c9e2cbf5e
4 changed files with 66 additions and 65 deletions
  1. 3
    22
      MeasureBase.cpp
  2. 34
    11
      MeasureBase.h
  3. 3
    24
      MeasureEntropy.cpp
  4. 26
    8
      MeasureEntropy.h

+ 3
- 22
MeasureBase.cpp View File

@@ -2,13 +2,9 @@
* @file MeasureBase.h
* @author Kai KRETSCHMANN
*
* @section LICENSE
* @license SPDX-License-Identifier: MIT
*
* SPDX-License-Identifier: MIT
*
* @section DESCRIPTION
*
* Base class for doing measurements.
* @brief Base class for doing measurements.
*
**/

@@ -23,34 +19,19 @@ using namespace std;

namespace jastacry {

/**
* Constructor for base class.
*
* @param filename String by reference of file to read.
*
*/
MeasureBase::MeasureBase(const string& filename) : _filename(filename), _filesize(0) {
spdlog::debug("CTOR MeasureBase normal");
readFile();
}

/**
* Getter function for filename.
*/
std::string& MeasureBase::getFilename() {
return _filename;
}
/**
* Getter function for filesize.
*/

size_t MeasureBase::getFilesize() {
return _filesize;
}

/**
* Main action to read the given file.
* Child classes then can measure values out of it.
*/
bool MeasureBase::readFile() {
ifstream file(_filename, ios::binary);
if (file.fail()) {

+ 34
- 11
MeasureBase.h View File

@@ -2,13 +2,9 @@
* @file MeasureBase.h
* @author Kai KRETSCHMANN
*
* @section LICENSE
* @copyright SPDX-License-Identifier: MIT
*
* SPDX-License-Identifier: MIT
*
* @section DESCRIPTION
*
* Base class for doing measurements.
* @brief Base class for doing measurements.
*
**/

@@ -23,31 +19,58 @@
namespace jastacry {

/**
* MeasureBase class.
* @brief MeasureBase class.
*/
class MeasureBase {
private:
/**
* @brief Main action to read the given file. Child classes then can measure values out of it.
* @return bool status of read action.
*/
bool readFile();
std::string _filename;
size_t _filesize;
protected:
std::vector<unsigned char> _buffer; /*!< Buffer to read file into */

/**
* @brief Getter function for filename.
* @return String reference to file name.
*/
std::string& getFilename();

/**
* @brief Getter function for file size.
* @return size_t file size.
*/
size_t getFilesize();

public:
explicit MeasureBase(const std::string& f);
/**
* @brief Constructor for base class.
*
* @param filename [in] - String by reference of file to read.
*
*/
explicit MeasureBase(const std::string& filename);

/**
* @brief Destructor default implementation.
*/
virtual ~MeasureBase() = default;

/**
* Abstract base function.
* @brief Abstract base function.
*/
virtual void measure() = 0;

/**
* Abstract base function.
* @brief Abstract base function.
*/
virtual void printResult() = 0;

/**
* Abstract base function.
* @brief Abstract base function.
*/
virtual double getResult() = 0;
};

+ 3
- 24
MeasureEntropy.cpp View File

@@ -2,15 +2,12 @@
* @file MeasureEntropy.h
* @author Kai KRETSCHMANN
*
* @section LICENSE
* @license SPDX-License-Identifier: MIT
*
* SPDX-License-Identifier: MIT
*
* @section DESCRIPTION
*
* Real entropy calculation class for doing measurements.
* @brief Real entropy calculation class for doing measurements.
*
**/

#include <string>
#include <map>
#include <iostream>
@@ -24,27 +21,15 @@ using namespace std;

namespace jastacry {

/**
* Constructor for class.
*
* @param filename String by reference of file to read.
*
*/
MeasureEntropy::MeasureEntropy(const string& f) :
MeasureBase(f), _infocontent(0.0) {
spdlog::debug("CTOR MeasureEntropy normal");
}

/**
* Internal log function.
*/
double MeasureEntropy::log2(const double number) {
return log(number) / log(2);
}

/**
* Main measure function. Reads from file buffer and sets internal property to entropy value.
*/
void MeasureEntropy::measure() {
char* data = (char*)_buffer.data();
std::string teststring(data, getFilesize());
@@ -58,16 +43,10 @@ void MeasureEntropy::measure() {
}
}

/**
* Print entropy to logging.
*/
void MeasureEntropy::printResult() {
spdlog::info("The information content of {} is {}", getFilename(), _infocontent);
}

/**
* Return entropy as double.
*/
double MeasureEntropy::getResult() {
spdlog::info("Return result of {}", _infocontent);
return _infocontent;

+ 26
- 8
MeasureEntropy.h View File

@@ -2,13 +2,9 @@
* @file MeasureEntropy.h
* @author Kai KRETSCHMANN
*
* @section LICENSE
* @copyright SPDX-License-Identifier: MIT
*
* SPDX-License-Identifier: MIT
*
* @section DESCRIPTION
*
* Real entropy calculation class for doing measurements.
* @brief Real entropy calculation class for doing measurements.
*
**/

@@ -21,18 +17,40 @@
namespace jastacry {

/**
* MeasureBase class.
* @brief MeasureEntropy class.
*/
class MeasureEntropy: public MeasureBase {
private:
/**
* @brief Internal log function.
* @param number [in] - double to calculate log2 on.
* @return double as result.
*/
double log2(const double number);
double _infocontent;
public:
explicit MeasureEntropy(const std::string& f);
/**
* @brief Constructor for class.
*
* @param filename [in] - String by reference of file to read.
*
*/
explicit MeasureEntropy(const std::string& filename);
virtual ~MeasureEntropy() = default;

/**
* @brief Main measure function. Reads from file buffer and sets internal property to entropy value.
*/
virtual void measure() override;

/**
* @brief Print entropy to logging.
*/
virtual void printResult() override;

/**
* @brief Return entropy as double.
*/
virtual double getResult() override;
};


Loading…
Cancel
Save
Social stuff:
Mastodon