Commit 746121a6 authored by incardon's avatar incardon
Browse files

Fixing Coverity + documentation

parent a7232f77
......@@ -57,10 +57,14 @@
class no_edge
{
public:
//! type in case of no edge
typedef boost::fusion::vector<> type;
//! empty edge
type data;
//! no properties
static const unsigned int max_prop = 0;
};
......@@ -478,6 +482,8 @@ public:
*
* Constructor
*
* \param n_vertex number of vertex has a graph
*
*/
Graph_CSR(size_t n_vertex) :
Graph_CSR(n_vertex, 16)
......@@ -486,11 +492,14 @@ public:
/*! \brief Constructor
*
* Constructor
* \param n_vertex number of vertices
* \param n_slot number of slots (around how many edge has
* a vertex, it is not fundamental parameter is just
* an indication)
*
*/
Graph_CSR(size_t n_vertex, size_t n_slot) :
v_slot(n_slot)
Graph_CSR(size_t n_vertex, size_t n_slot)
:v_slot(n_slot)
{
//! Creating n_vertex into the graph
v.resize(n_vertex);
......@@ -503,6 +512,8 @@ public:
}
/*! \brief Copy constructor
*
* \param g Graph to copy
*
*/
Graph_CSR(Graph_CSR<V, E, Memory> && g)
......@@ -514,6 +525,8 @@ public:
*
* \param g graph to copy
*
* \return itself
*
*/
Graph_CSR<V, E, Memory> & operator=(Graph_CSR<V, E, Memory> && g)
{
......@@ -528,12 +541,14 @@ public:
/*! \breif Copy the graph
*
* \param g graph to copy
*
*
*/
Graph_CSR<V, E, Memory> & operator=(const Graph_CSR<V, E, Memory> & g)
{
swap(g.duplicate());
v_slot = g.v_slot;
return *this;
}
......@@ -544,6 +559,8 @@ public:
* \tparam i property to access
* \param id of the vertex to access
*
* \return the reference of the property vertex
*
*/
template<unsigned int i> auto vertex_p(size_t id) -> decltype( v.template get<i>(id) )
{
......@@ -553,64 +570,73 @@ public:
/*! \brief Access the vertex
*
* \tparam i property to access
*
* \param id of the vertex to access
*
* \return the reference of the property vertex
*
*/
template<unsigned int i> auto vertex_p(grid_key_dx<1> id) -> decltype( v.template get<i>(id) )
{
return v.template get<i>(id);
}
/*! \brief Function to access the vertexes
/*! \brief Function to access the vertex
*
* \param id of the vertex to access
*
* \return vertex object
*
*/
auto vertex(size_t id) -> decltype( v.get(id) )
{
return v.get(id);
}
/*! \brief operator to access the vertex
*
* operator to access the vertex
/*! \brief Function to access the vertex
*
* \param id of the vertex to access
*
* \return the vertex object
*
*/
auto vertex(grid_key_dx<1> id) -> decltype( v.get(id.get(0)) )
{
return v.get(id.get(0));
}
/*! \brief operator to access the vertex
*
* operator to access the vertex
/*! \brief Fuction to access the vertex
*
* \param id of the vertex to access
*
* \return the vertex object
*
*/
auto vertex(openfpm::vector_key_iterator id) -> decltype( v.get(0) )
{
return v.get(id.get());
}
/*! \brief Function to access the vertexes
/*! \brief Function to access the vertex
*
* \param id of the vertex to access
*
* \return the vertex object
*
*/
auto vertex(size_t id) const -> const decltype( v.get(id) )
{
return v.get(id);
}
/*! \brief operator to access the vertex
/*! \brief Fuction to access the vertex
*
* operator to access the vertex
*
* \param id of the vertex to access
*
* \return the vertex object
*
*/
auto vertex(grid_key_dx<1> id) const -> const decltype( v.get(id.get(0)) )
{
......@@ -618,11 +644,11 @@ public:
}
/*! \brief operator to access the vertex
*
* operator to access the vertex
*
* \param id of the vertex to access
*
* \return the vertex object
*
*/
auto vertex(openfpm::vector_key_iterator id) const -> const decltype( v.get(0) )
{
......@@ -648,6 +674,8 @@ public:
* \tparam i property to access
* \param id of the edge to access
*
* \return a reference to the edge property
*
*/
template<unsigned int i> auto edge_p(grid_key_dx<1> id) -> decltype ( e.template get<i>(id) )
{
......@@ -659,6 +687,8 @@ public:
* \tparam i property to access
* \param id of the edge to access
*
* \return a reference to the edge property
*
*/
template<unsigned int i> auto edge_p(size_t id) -> decltype ( e.template get<i>(id) )
{
......@@ -670,6 +700,8 @@ public:
*
* \param ek key of the edge
*
* \return the edge object
*
*/
auto edge(edge_key ek) const -> const decltype ( e.get(0) )
{
......@@ -677,11 +709,11 @@ public:
}
/*! \brief operator to access the edge
*
* operator to access the edge
*
* \param id of the edge to access
*
* \return the edge object
*
*/
auto edge(size_t id) const -> const decltype ( e.get(id) )
{
......@@ -692,6 +724,8 @@ public:
*
* \param id of the edge to access
*
* \return the edge object
*
*/
auto edge(grid_key_dx<1> id) const -> const decltype ( e.get(id.get(0)) )
{
......@@ -732,6 +766,8 @@ public:
* \param v vertex
* \param v_e edge id
*
* \return the edge object
*
*/
inline auto getChildEdge(size_t v, size_t v_e) -> decltype(e.get(0))
{
......@@ -773,7 +809,6 @@ public:
* \return the target i connected by an edge node, for the node v
*
*/
inline size_t getChild(typename openfpm::vector<V, Memory, layout_v, layout_v_base, grow_p>::iterator_key & v, size_t i)
{
#ifdef SE_CLASS1
......@@ -797,7 +832,6 @@ public:
* \param vrt Vertex properties
*
*/
inline void addVertex(const V & vrt)
{
......@@ -815,7 +849,6 @@ public:
/*! \brief add an empty vertex
*
*/
inline void addVertex()
{
......@@ -832,10 +865,13 @@ public:
/*! \brief add edge on the graph
*
* add an edge on the graph
* \param v1 source edge
* \param v2 destination edge
* \param ed edge object to add
*
* \return edge object
*
*/
template<typename CheckPolicy = NoCheck> inline auto addEdge(size_t v1, size_t v2, const E & ed) -> decltype(e.get(0))
{
long int id_x_end = addEdge_<CheckPolicy>(v1, v2);
......@@ -857,8 +893,9 @@ public:
* \param v1 start vertex
* \param v2 end vertex
*
* \return the edge object
*
*/
template<typename CheckPolicy = NoCheck> inline auto addEdge(size_t v1, size_t v2) -> decltype(e.get(0))
{
//! add an edge
......@@ -878,11 +915,16 @@ public:
* \param v1 start vertex
* \param v2 end vertex
*
* \param srcgid source global id
* \param dstgid destination global id
*
* \tparam sgid property id filled with the source vertex global id
* \tparam dgid property id filled with the destination vertex global id
*
* \return the edge object
*
*/
template<typename CheckPolicy = NoCheck, int sgid, int dgid> inline auto addEdge(size_t v1, size_t v2, size_t srdgid, size_t dstgid) -> decltype(e.get(0))
template<typename CheckPolicy = NoCheck, int sgid, int dgid> inline auto addEdge(size_t v1, size_t v2, size_t srcgid, size_t dstgid) -> decltype(e.get(0))
{
//! add an edge
long int id_x_end = addEdge_<CheckPolicy>(v1, v2);
......@@ -891,7 +933,7 @@ public:
return e_invalid.get(0);
//! set source and destination ids of the edge
e.get(id_x_end).template get<sgid>() = srdgid;
e.get(id_x_end).template get<sgid>() = srcgid;
e.get(id_x_end).template get<dgid>() = dstgid;
//! return the edge to change the properties
......@@ -900,8 +942,9 @@ public:
/*! \brief swap the memory of g with this graph
*
* swap the memory of g with this graph, it is basically used
* for move semantic
* it is basically used for move semantic
*
* \param g graph to swap
*
*/
......@@ -914,15 +957,19 @@ public:
v_l.swap(g.v_l);
e_l.swap(g.e_l);
e_invalid.swap(g.e_invalid);
size_t v_slot_tmp = g.v_slot;
g.v_slot = v_slot;
v_slot = v_slot_tmp;
}
/*! \brief swap the memory of g with this graph
*
* swap the memory of g with this graph, it is basically used
* for move semantic
* it is basically used for move semantic
*
* \param g graph to swap
*
*/
inline void swap(Graph_CSR<V, E> && g)
{
// switch the memory
......@@ -932,6 +979,10 @@ public:
v_l.swap(g.v_l);
e_l.swap(g.e_l);
e_invalid.swap(g.e_invalid);
size_t v_slot_tmp = g.v_slot;
g.v_slot = v_slot;
v_slot = v_slot_tmp;
}
/*! \brief Get the vertex iterator
......
......@@ -119,6 +119,7 @@ class grid_sm
for (size_t i = 1 ; i < N ; i++)
{
/* coverity[dead_error_begin] */
sz_s[i] = sz*sz_s[i-1];
this->sz[i] = sz;
......@@ -149,6 +150,7 @@ class grid_sm
for (size_t i = 1 ; i < N ; i++)
{
/* coverity[dead_error_begin] */
sz_s[i] = sz[i]*sz_s[i-1];
this->sz[i] = sz[i];
......@@ -377,6 +379,7 @@ public:
{
// Check the sum produce a valid key
/* coverity[dead_error_line] */
if (bc[i] == NON_PERIODIC)
{
if (check::valid(gk.k[i] + sum_id[i],sz[i]) == false)
......@@ -426,6 +429,7 @@ public:
mem_id lid = k[0];
for (mem_id i = 1 ; i < N ; i++)
{
/* coverity[dead_error_line] */
lid += k[i] * sz_s[i-1];
}
......@@ -446,6 +450,7 @@ public:
mem_id lid = gk.k[0];
for (mem_id i = 1 ; i < N ; i++)
{
/* coverity[dead_error_begin */
lid += gk.k[i] * sz_s[i-1];
}
......
......@@ -184,6 +184,7 @@ public:
size_t i = 0;
for ( ; i < dim-1 ; i++)
{
/* coverity[dead_error_begin] */
size_t id = gk.get(i);
if (id >= grid_base.size(i))
{
......
......@@ -406,6 +406,7 @@ public:
long int i = 0;
for ( ; i < dim-1 ; i++)
{
/* coverity[dead_error_begin] */
size_t id = this->gk.get(i);
if ((long int)id > gk_stop.get(i))
{
......
......@@ -116,6 +116,7 @@ public:
}
else
{
/* coverity[dead_error_line] */
if ( j < i )
{
k1.set_d(j,A.getLow(j)+1);
......
......@@ -434,6 +434,7 @@ class CellDecomposer_sm
for (size_t s = 1 ; s < dim ; s++)
{
/* coverity[dead_error_begin] */
check_and_print_error(pos,s);
size_t cell_idt = ConvertToID_ns(pos,s);
......@@ -871,6 +872,7 @@ public:
ACTION_ON_ERROR(CELL_DECOMPOSER);
}
#endif
/* coverity[dead_error_line] */
cell_id += gr_cell2.size_s(s-1) * ConvertToID(pos,s);
}
......
......@@ -579,7 +579,7 @@ public:
*
*/
CellList(Box<dim,T> & box, const size_t (&div)[dim], const size_t pad = 1, size_t slot=STARTING_NSLOT)
:Mem_type(slot)
:Mem_type(slot),n_dec(0)
{
SpaceBox<dim,T> sbox(box);
Initialize(sbox,div,pad,slot);
......@@ -610,7 +610,7 @@ public:
*
*/
CellList(CellDecomposer_sm<dim,T,transform> & cd_sm, const Box<dim,T> & box, const size_t pad = 1, size_t slot=STARTING_NSLOT)
:Mem_type(slot)
:Mem_type(slot),n_dec(0)
{
Initialize(cd_sm,box,pad,slot);
}
......@@ -638,6 +638,8 @@ public:
static_cast<CellDecomposer_sm<dim,T,transform> &>(*this).swap(cell);
n_dec = cell.n_dec;
return *this;
}
......@@ -657,6 +659,8 @@ public:
static_cast<CellDecomposer_sm<dim,T,transform> &>(*this) = static_cast<const CellDecomposer_sm<dim,T,transform> &>(cell);
n_dec = cell.n_dec;
return *this;
}
......
......@@ -49,6 +49,12 @@ class Mem_bal
public:
/*! \brief Initialize all to zero
*
* \param slot number of slot (unused)
* \param tot_n_cell total number of cells
*
*/
inline void init_to_zero(size_t slot, size_t tot_n_cell)
{
//resize the vector to needed number of cells
......@@ -56,6 +62,13 @@ public:
cl_base.resize(tot_n_cell);
}
/*! \brief Copy mem balanced
*
* \param cell memory to copy
*
* \return itself
*
*/
inline Mem_bal & operator=(const Mem_bal & cell)
{
cl_base = cell.cl_base;
......@@ -63,6 +76,12 @@ public:
return *this;
}
/*! \brief Add an element to the cell
*
* \param cell_id id of the cell
* \param ele element to add
*
*/
inline void addCell(size_t cell_id, typename base::value_type ele)
{
//add another neighbor element
......@@ -70,41 +89,90 @@ public:
cl_base.get(cell_id).add(ele);
}
/*! \brief Add an element to the cell
*
* \param cell_id id of the cell
* \param ele element to add
*
*/
inline void add(size_t cell_id, typename base::value_type ele)
{
this->addCell(cell_id,ele);
}
/*! \brief Remove an element from the cell
*
* \param cell_id id of the cell
* \param ele element to remove
*
*/
inline void remove(size_t cell, size_t ele)
{
cl_base.get(cell).remove(ele);
}
/*! \brief Get the number of elements in the cell
*
* \param cell_id id of the cell
*
* \return the number of elements in the cell
*
*/
inline size_t getNelements(const size_t cell_id) const
{
return cl_base.get(cell_id).size();
}
/*! \brief Return an element from the cell
*
* \param cell id of the cell
* \param ele element id
*
* \return reference to the element
*
*/
inline auto get(size_t cell, size_t ele) -> decltype(cl_base.get(0).get(0)) &
{
return cl_base.get(cell).get(ele);
}
/*! \brief Return an element from the cell
*
* \param cell id of the cell
* \param ele element id
*
* \return reference to the element
*
*/
inline auto get(size_t cell, size_t ele) const -> decltype(cl_base.get(0).get(0)) &
{
return cl_base.get(cell).get(ele);
}
/*! \brief Swap two Mem_bal
*
* \param cl element to swap with
*
*/
inline void swap(Mem_bal & cl)
{
cl_base.swap(cl.cl_base);
}
/*! \brief Swap two Mem_bal
*
* \param cl element to swap with
*
*/
inline void swap(Mem_bal && cell)
{
cl_base.swap(cell.cl_base);
}
/*! \brief Reset the object
*
*
*/
inline void clear()
{
for (size_t i = 0 ; i < cl_base.size() ; i++)
......@@ -135,6 +203,7 @@ public:
public:
inline Mem_bal(size_t slot)
:invalid(0)
{}
inline void set_slot(size_t slot)
......
......@@ -179,10 +179,21 @@ public:
public:
/*! \brief constructor
*
* \param slot number of slots (unused)
*
*/
inline Mem_mw(size_t slot)
:invalid(0)
{
}
/*! \brief Set the number of slots
*
* \param slot unused
*
*/
inline void set_slot(size_t slot)
{}
......
......@@ -151,7 +151,7 @@ public:
const openfpm::vector<size_t> & dom_cell,
const openfpm::vector<subsub_lin<dim>> & anom_dom_cell,
const long int (& NNc_sym)[openfpm::math::pow(3,dim)/2+1])
:cid(0),