Timetabler
Classes | Macros | Enumerations | Functions
utils.h File Reference
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include "data.h"
#include "global.h"
#include "mtl/Vec.h"
Include dependency graph for utils.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  Utils::Log
 Perform logging. More...
 

Macros

#define LOG(x)   Utils::Log(Utils::x)
 
#define LOG_DEBUG(x)   Utils::Log(Utils::x, true)
 
#define LOG_FIXED(x)   Utils::Log(Utils::x, false, 80)
 
#define LOG_FIXED_DEBUG(x)   Utils::Log(Utils::x, true, 80)
 
#define DISPLAY()   LOG(EMPTY)
 
#define DISPLAY_DEBUG()   LOG_DEBUG(EMPTY)
 
#define DISPLAY_FIXED()   LOG_FIXED(EMPTY)
 
#define DISPLAY_FIXED_DEBUG()   LOG_FIXED_DEBUG(EMPTY)
 
#define DEBUG()   LOG_DEBUG(INFO)
 

Enumerations

enum  Utils::Severity { EMPTY = 0, ERROR = 1, WARNING = 2, INFO = 3 }
 Specify severity levels for logging.
 
enum  Utils::DisplayColour { NORMAL = 0, RED = 31, YELLOW = 33 }
 Define values for colours in ASCII, to be used when logging.
 

Functions

template<typename T >
vec< T > Utils::convertVectorToVec (std::vector< T > inputs)
 Converts a std::vector to a NSPACE::vec. More...
 
template<typename T >
std::vector< T > Utils::convertVecToVector (vec< T > inputs)
 Converts a NSPACE::vec to a std::vector. More...
 
template<typename T >
std::vector< T > Utils::convertVecDataToVector (T *data, unsigned size)
 Converts given data and size, a NSPACE::vec to a std::vector. More...
 
template<typename T >
std::vector< T > Utils::flattenVector (std::vector< std::vector< T >> inputs)
 Converts a two dimensional vector to a one dimensional vector. More...
 
template<typename T >
std::vector< T > Utils::flattenVector (std::vector< std::vector< std::vector< T >>> inputs)
 Converts a three dimensional vector to a one dimensional vector. More...
 
std::string Utils::getFieldTypeName (FieldType fieldType)
 Gets the field type name as a string. More...
 
std::string Utils::getPredefinedConstraintName (const PredefinedClauses clauseType)
 Gets the predefined constraint name as a string. More...
 
std::string Utils::getFieldName (FieldType fieldType, int index, Data &data)
 Gets the field name in the Data of a given FieldType at a given index. More...
 

Function Documentation

◆ convertVecDataToVector()

template<typename T >
std::vector<T> Utils::convertVecDataToVector ( T *  data,
unsigned  size 
)

Converts given data and size, a NSPACE::vec to a std::vector.

Parameters
dataThe data pointer
[in]sizeThe size
Template Parameters
TThe type of the vec
Returns
The resultant vector

Definition at line 65 of file utils.h.

References Utils::convertVecDataToVector().

Referenced by Utils::convertVecDataToVector().

◆ convertVectorToVec()

template<typename T >
vec<T> Utils::convertVectorToVec ( std::vector< T >  inputs)

Converts a std::vector to a NSPACE::vec.

Parameters
[in]inputsThe input vector
Template Parameters
TThe type of the vector
Returns
The resultant vec

Definition at line 28 of file utils.h.

References Utils::convertVectorToVec().

Referenced by Utils::convertVectorToVec().

◆ convertVecToVector()

template<typename T >
std::vector<T> Utils::convertVecToVector ( vec< T >  inputs)

Converts a NSPACE::vec to a std::vector.

Parameters
[in]inputsThe input vec
Template Parameters
TThe type of the vec
Returns
The resultant vector

Definition at line 46 of file utils.h.

References Utils::convertVecToVector().

Referenced by Utils::convertVecToVector().

◆ flattenVector() [1/2]

template<typename T >
std::vector<T> Utils::flattenVector ( std::vector< std::vector< T >>  inputs)

Converts a two dimensional vector to a one dimensional vector.

This is done by concatenating all the rows.

Parameters
[in]inputsThe input vector
Template Parameters
TThe type of the vector
Returns
The resultant vector

Definition at line 85 of file utils.h.

References Utils::flattenVector().

Referenced by Utils::flattenVector().

◆ flattenVector() [2/2]

template<typename T >
std::vector<T> Utils::flattenVector ( std::vector< std::vector< std::vector< T >>>  inputs)

Converts a three dimensional vector to a one dimensional vector.

This is done by concatenating all the rows.

Parameters
[in]inputsThe input vector
Template Parameters
TThe type of the vector
Returns
The resultant vector

Definition at line 106 of file utils.h.

References Utils::flattenVector(), Utils::getFieldName(), Utils::getFieldTypeName(), and Utils::getPredefinedConstraintName().

◆ getFieldName()

std::string Utils::getFieldName ( FieldType  fieldType,
int  index,
Data data 
)

Gets the field name in the Data of a given FieldType at a given index.

Parameters
[in]fieldTypeThe FieldType member
[in]indexThe index
dataThe Data object
Returns
The field name as a string

Definition at line 79 of file utils.cpp.

References Utils::getFieldName().

Referenced by Utils::flattenVector(), and Utils::getFieldName().

◆ getFieldTypeName()

std::string Utils::getFieldTypeName ( FieldType  fieldType)

Gets the field type name as a string.

For example, the name of FieldType::instructor is "Instructor".

Parameters
[in]fieldTypeThe FieldType member
Returns
The field type name.

Definition at line 19 of file utils.cpp.

References Utils::getFieldTypeName().

Referenced by Utils::flattenVector(), and Utils::getFieldTypeName().

◆ getPredefinedConstraintName()

std::string Utils::getPredefinedConstraintName ( const PredefinedClauses  clauseType)

Gets the predefined constraint name as a string.

For example, the name of PredefinedClauses::instructorSingleCourseAtATime is "instructorSingleCourseAtATime".

Parameters
[in]clauseTypeThe PredefinedClauses member
Returns
The predefined constraint name.

Definition at line 40 of file utils.cpp.

References Utils::getPredefinedConstraintName().

Referenced by Utils::flattenVector(), and Utils::getPredefinedConstraintName().