source: flair-src/trunk/lib/FlairCore/src/cvmatrix_descriptor.cpp@ 2

Last change on this file since 2 was 2, checked in by Sanahuja Guillaume, 6 years ago

flaircore

File size: 1.9 KB
Line 
1// %flair:license{
2// This file is part of the Flair framework distributed under the
3// CECILL-C License, Version 1.0.
4// %flair:license}
5// created: 2014/02/05
6// filename: cvmatrix_descriptor.cpp
7//
8// author: Guillaume Sanahuja
9// Copyright Heudiasyc UMR UTC/CNRS 7253
10//
11// version: $Id: $
12//
13// purpose: Class describing cvmatrix elements, for log and graphs purpose
14//
15/*********************************************************************/
16
17#include "cvmatrix_descriptor.h"
18#include "FrameworkManager.h"
19
20using std::string;
21
22namespace flair { namespace core {
23
24cvmatrix_descriptor::cvmatrix_descriptor(uint32_t rows, uint32_t cols) {
25 this->rows=rows;
26 this->cols=cols;
27
28 if(rows==0 || cols==0) getFrameworkManager()->Err("rows and cols must be >0\n");
29
30 element_names=(string**)malloc(rows*cols*sizeof(string*));
31 for(uint32_t i=0; i<rows*cols; i++) {
32 element_names[i]=new string();
33 }
34}
35
36cvmatrix_descriptor::~cvmatrix_descriptor() {
37 for(uint32_t i=0; i<rows*cols; i++) {
38 delete element_names[i];
39 }
40 free(element_names);
41}
42
43void cvmatrix_descriptor::SetElementName(uint32_t row, uint32_t col,string name) {
44 if(row>=rows || col>=cols) {
45 getFrameworkManager()->Err("index out of bound %s (%i,%i), range (%i,%i)\n",name.c_str(),row,col,rows-1,cols-1);
46 return;
47 }
48 *element_names[row*cols+col]=name;
49}
50
51string cvmatrix_descriptor::ElementName(uint32_t row, uint32_t col) const {
52 if(row>=rows || col>=cols) {
53 getFrameworkManager()->Err("index out of bound (%i,%i), range (%i,%i)\n",row,col,rows-1,cols-1);
54 return *element_names[0];//safe value...
55 }
56 return *element_names[row*cols+col];
57}
58
59uint32_t cvmatrix_descriptor::Rows() const {
60 return rows;
61}
62
63uint32_t cvmatrix_descriptor::Cols() const {
64 return cols;
65}
66
67} // end namespace core
68} // end namespace flair
Note: See TracBrowser for help on using the repository browser.