aboutsummaryrefslogtreecommitdiffstats
path: root/src/virtualkeyboard/3rdparty/lipi-toolkit/src/common/LTKTrace.cpp
blob: 3625ce50a6596ed930be60e48748d5162f4c92d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
/******************************************************************************
* Copyright (c) 2006 Hewlett-Packard Development Company, L.P.
* Permission is hereby granted, free of charge, to any person obtaining a copy 
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights 
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
* copies of the Software, and to permit persons to whom the Software is 
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 
* SOFTWARE
********************************************************************************/

/******************************************************************************
 * SVN MACROS
 *
 * $LastChangedDate: 2011-01-11 13:48:17 +0530 (Tue, 11 Jan 2011) $
 * $Revision: 827 $
 * $Author: mnab $
 *
 ************************************************************************/
/************************************************************************
 * FILE DESCR: implementation of LTKTrace which holds series of points 
 *			   from a pen down event to the next immediate pen up event
 *
 * CONTENTS: 
 *	getNumberOfPoints
 *	getPointAt
 *	getChannelValues
 *	getChannelValues (overloaded)
 *	getChannelValueAt
 *	setChannelValues
 *	addPoint
  *	getChannelNames
 *	addChannel
 *	getChannelIndex
 *
 * AUTHOR:     Balaji R.
 *
 * DATE:       December 23, 2004
 * CHANGE HISTORY:
 * Author		Date			Description of change
 ************************************************************************/

#include "LTKTrace.h"
#include "LTKMacros.h"
#include "LTKTraceFormat.h"
#include "LTKErrors.h"
#include "LTKErrorsList.h"
#include "LTKChannel.h"
#include "LTKException.h"
#include "LTKLoggerUtil.h"


/******************************************************************************
* AUTHOR		: Balaji R.
* DATE			: 23-DEC-2004
* NAME			: LTKTrace
* DESCRIPTION	: Default Constructor
* ARGUMENTS		: 
* RETURNS		: 
* NOTES			:
* CHANGE HISTROY
* Author			Date				Description of change
******************************************************************************/

LTKTrace::LTKTrace()
{
	LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
	"Entering: LTKTrace::LTKTrace()"<<endl;
	
	floatVector emptyChannel;
	
	m_traceChannels.assign(2,emptyChannel);
    
    LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
	"Exiting: LTKTrace::LTKTrace()"<<endl;
}

/******************************************************************************
* AUTHOR		: Balaji R.
* DATE			: 23-DEC-2004
* NAME			: LTKTrace
* DESCRIPTION	: Initialization constructor
* ARGUMENTS		: inputStream - incoming data 
*				  traceFormat - format of the incoming data
* RETURNS		: 
* NOTES			:
* CHANGE HISTROY
* Author			Date				Description of change
******************************************************************************/

LTKTrace::LTKTrace(const floatVector& inputStream, 
                   const LTKTraceFormat& traceFormat)
{

	LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
	"Entering: LTKTrace::LTKTrace(const floatVector&,const LTKTraceFormat& )"<<endl;

	int inputStreamSize     = inputStream.size();
	int numChannels         = traceFormat.getNumChannels();

	floatVector tempChannel;

	if(numChannels == 0)
	{
			LOG( LTKLogger::LTK_LOGLEVEL_ERR) << 
			"Error: "<<EZERO_CHANNELS <<": "<<
			getErrorMessage(EZERO_CHANNELS) <<
			"LTKTrace::LTKTrace(const floatVector&,const LTKTraceFormat&() "<<endl;

		throw LTKException(EZERO_CHANNELS);
	}

	if(inputStreamSize==0 || ((inputStreamSize % numChannels) != 0))
	{
		
			LOG( LTKLogger::LTK_LOGLEVEL_ERR) << 
			"Error: "<<EINVALID_INPUT_STREAM <<": "<<
			getErrorMessage(EINVALID_INPUT_STREAM) <<
			"LTKTrace::LTKTrace(const floatVector&,const LTKTraceFormat&() "<<endl;

		throw LTKException(EINVALID_INPUT_STREAM);
	}

	m_traceFormat = traceFormat;

	/*
	 * values of individual channels are separated from contiguous channel values. 
	 * vector<float> of these individual channels is computed, and such vectors  
	 * for all channels are collected into another vector.
	 */

	for(int channelIndex = 0; channelIndex < numChannels; ++channelIndex)
	{
        for(int inputIndex = channelIndex; inputIndex < inputStreamSize; 
			inputIndex += numChannels)
		{
			tempChannel.push_back(inputStream[inputIndex]);
		}

		m_traceChannels.push_back(tempChannel); 

		tempChannel.clear();
	}

	LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
	"Exiting: LTKTrace::LTKTrace(const floatVector&,const LTKTraceFormat& )"<<endl;

}

/******************************************************************************
* AUTHOR		: Balaji R.
* DATE			: 23-DEC-2004
* NAME			: LTKTrace
* DESCRIPTION	: Trace format initialization constructor
* ARGUMENTS		: traceFormat - format of the incoming data
* RETURNS		: 
* NOTES			:
* CHANGE HISTROY
* Author			Date				Description of change
******************************************************************************/

LTKTrace::LTKTrace(const LTKTraceFormat& traceFormat)
{
	LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
	"Entering: LTKTrace::LTKTrace(const LTKTraceFormat&)"<<endl;

	floatVector tempChannel;

	int numChannels = traceFormat.getNumChannels();

	m_traceFormat = traceFormat;

	m_traceChannels.assign(numChannels, tempChannel);

	LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
	"Exiting: LTKTrace::LTKTrace(const LTKTraceFormat&)"<<endl;

}

/******************************************************************************
* AUTHOR		: Balaji R.
* DATE			: 23-DEC-2004
* NAME			: LTKTrace
* DESCRIPTION	: copy constructor
* ARGUMENTS		: trace - trace to be copied
* RETURNS		: 
* NOTES			:
* CHANGE HISTROY
* Author			Date				Description of change
******************************************************************************/

LTKTrace::LTKTrace(const LTKTrace& trace)
{
	LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
	"Entering: LTKTrace::LTKTrace(const LTKTrace&)"<<endl;

	m_traceChannels = trace.m_traceChannels;
	m_traceFormat   = trace.m_traceFormat;
	
	LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
	"Exiting: LTKTrace::LTKTrace(const LTKTrace&)"<<endl;

}

/******************************************************************************
* AUTHOR		: Balaji R.
* DATE			: 23-DEC-2004
* NAME			: operator=
* DESCRIPTION	: assignment operator
* ARGUMENTS		: trace - trace to be assigned 
* RETURNS		: 
* NOTES			:
* CHANGE HISTROY
* Author			Date				Description of change
******************************************************************************/

LTKTrace& LTKTrace::operator=(const LTKTrace& trace)
{
	LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
	"Entering: LTKTrace::operator=()"<<endl;

	if ( this != &trace )
	{
		m_traceChannels = trace.m_traceChannels;
		m_traceFormat   = trace.m_traceFormat;
	}

	LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
	"Exiting: LTKTrace::operator=()"<<endl;

	return *this;
}

/******************************************************************************
* AUTHOR		: Balaji R.
* DATE			: 23-DEC-2004
* NAME			: getNumberOfPoints
* DESCRIPTION	: get number of points in the trace
* ARGUMENTS		: 
* RETURNS		: number of points in the trace
* NOTES			:
* CHANGE HISTROY
* Author			Date				Description of change
******************************************************************************/

int LTKTrace::getNumberOfPoints() const
{
	LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
	"Entering: LTKTrace::getNumberOfPoints()"<<endl;
    
    
  	LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
	"Exiting: LTKTrace::getNumberOfPoints()"<<endl;
   
    return m_traceChannels[0].size();	
	
}

/******************************************************************************
* AUTHOR		: Balaji R.
* DATE			: 23-DEC-2004
* NAME			: getPointAt
* DESCRIPTION	: returns the point at a specified index
* ARGUMENTS		: pointIndex - index of the point whose values are required
* RETURNS		: point at the specified index
* NOTES			:
* CHANGE HISTROY
* Author			Date				Description of change
******************************************************************************/

int LTKTrace::getPointAt(int pointIndex, floatVector& outPointCoordinates) const
{
	LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
	"Entering: LTKTrace::getPointAt()"<<endl;
	
	if ( pointIndex < 0 || pointIndex >= m_traceChannels[0].size() )
	{
			LOG( LTKLogger::LTK_LOGLEVEL_ERR) << 
			"Error: "<<EPOINT_INDEX_OUT_OF_BOUND <<": "<<
			getErrorMessage(EPOINT_INDEX_OUT_OF_BOUND) <<
			"LTKTrace::getPointAt() "<<endl;

		LTKReturnError(EPOINT_INDEX_OUT_OF_BOUND);
	}

	vector<floatVector>::const_iterator channelIterator = m_traceChannels.begin();

	vector<floatVector>::const_iterator traceChannelsEnd = m_traceChannels.end();

	for(; channelIterator != traceChannelsEnd; ++channelIterator)
	{
		outPointCoordinates.push_back((*channelIterator)[pointIndex]);
	}

	LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
	"Exiting: LTKTrace::getPointAt()"<<endl;
	
	return SUCCESS;
}
	
/******************************************************************************
* AUTHOR		: Balaji R.
* DATE			: 23-DEC-2004
* NAME			: getChannelValues
* DESCRIPTION	: get the values of the channel given its name
* ARGUMENTS		: channelName - name of the channel whose values are required
* RETURNS		: values of the channel with the specified name
* NOTES			:
* CHANGE HISTROY
* Author			Date				Description of change
******************************************************************************/
int LTKTrace::getChannelValues(const string& channelName, 
                                   floatVector& outChannelValues) const
{
	LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
	"Entering: LTKTrace::getChannelValues(const string&, floatVector&)"<<endl;
	
	int channelIndex = -1;
	
	int errorCode = 0;

    if ((errorCode=m_traceFormat.getChannelIndex(channelName, channelIndex)) != SUCCESS )
    {
        	LOG( LTKLogger::LTK_LOGLEVEL_ERR) << 
			"Error: LTKTrace::getChannelValues(string&, floatVector&) "<<endl;

		LTKReturnError(errorCode);
    }
    
    outChannelValues = m_traceChannels[channelIndex];

	LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
	"Exiting: LTKTrace::getChannelValues(string&, floatVector&)"<<endl;
	
    return SUCCESS;
}

/******************************************************************************
* AUTHOR		: Balaji R.
* DATE			: 23-DEC-2004
* NAME			: getChannelValues
* DESCRIPTION	: get the values of the channel given its index
* ARGUMENTS		: channelIndex - index of the channel whose values are required
* RETURNS		: values of the channel at the specified index
* NOTES			:
* CHANGE HISTROY
* Author			Date				Description of change
******************************************************************************/
int LTKTrace::getChannelValues(int channelIndex,
                               floatVector& outChannelValues) const
{
	LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
	"Entering: LTKTrace::getChannelValues(int, floatVector&)"<<endl;

	if(channelIndex < 0 || channelIndex >= m_traceFormat.getNumChannels())
	{
			LOG( LTKLogger::LTK_LOGLEVEL_ERR) << 
			"Error: "<<ECHANNEL_INDEX_OUT_OF_BOUND <<": "<<
			getErrorMessage(ECHANNEL_INDEX_OUT_OF_BOUND) <<
			"LTKTrace::getChannelValues() "<<endl;

		LTKReturnError(ECHANNEL_INDEX_OUT_OF_BOUND);
	}

    outChannelValues = m_traceChannels[channelIndex];

	LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
	"Exiting: LTKTrace::getChannelValues(int, floatVector&)"<<endl;
	
    return SUCCESS;
}

/******************************************************************************
* AUTHOR		: Balaji R.
* DATE			: 23-DEC-2004
* NAME			: getChannelValueAt
* DESCRIPTION	: gets the value of a particular channel at a particular point
* ARGUMENTS		: channelName - name of the channel to get the value from
*				  pointIndex - index of the point at which the channel value 
*                 is required
* RETURNS		: value of the specified channel at the specified point
* NOTES			:
* CHANGE HISTROY
* Author			Date				Description of change
******************************************************************************/
int LTKTrace::getChannelValueAt(const string& channelName, int pointIndex, 
                                    float& outValue) const
{
	LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
	"Entering: LTKTrace::getChannelValueAt(const string&, floatVector&)"<<endl;

	if (pointIndex < 0 || pointIndex >= m_traceChannels[0].size() )
	{
			LOG( LTKLogger::LTK_LOGLEVEL_ERR) << 
			"Error: "<<ECHANNEL_INDEX_OUT_OF_BOUND <<": "<<
			getErrorMessage(ECHANNEL_INDEX_OUT_OF_BOUND) <<
			"LTKTrace::getChannelValueAt() "<<endl;

		LTKReturnError(EPOINT_INDEX_OUT_OF_BOUND);
	}

    int channelIndex = -1;

    if (m_traceFormat.getChannelIndex(channelName, channelIndex) != SUCCESS )
    {
			LOG( LTKLogger::LTK_LOGLEVEL_ERR) << 
			"Error: "<<ECHANNEL_NOT_FOUND <<": "<<
			getErrorMessage(ECHANNEL_NOT_FOUND) <<
			"LTKTrace::getChannelValueAt() "<<endl;

        LTKReturnError(ECHANNEL_NOT_FOUND);
    }

    outValue = m_traceChannels[channelIndex][pointIndex];
    
	LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
	"Exiting: LTKTrace::getChannelValueAt()"<<endl;
	
	return SUCCESS;
	
}

/******************************************************************************
* AUTHOR		: Balaji R.
* DATE			: 23-DEC-2004
* NAME			: setChannelValues
* DESCRIPTION	: resets the data of the given channel 
* ARGUMENTS		: channelName - name of the channel whose data is to be reset
*				  channelData - new data for the channel reset
* RETURNS		: SUCCESS on successful reset
* NOTES			:
* CHANGE HISTROY
* Author			Date				Description of change
******************************************************************************/
int LTKTrace::reassignChannelValues(const string &channelName, 
							   const floatVector &channelData)
{
	LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
	"Entering: LTKTrace::reassignChannelValues(const string&, floatVector&)"<<endl;

	if(channelData.size() != m_traceChannels[0].size())
	{
			LOG( LTKLogger::LTK_LOGLEVEL_ERR) << 
			"Error: "<<ECHANNEL_SIZE_MISMATCH <<": "<<
			getErrorMessage(ECHANNEL_SIZE_MISMATCH) <<
			"LTKTrace::reassignChannelValues() "<<endl;

		LTKReturnError(ECHANNEL_SIZE_MISMATCH);
	}

    int channelIndex = -1;

    if (m_traceFormat.getChannelIndex(channelName, channelIndex) != SUCCESS )
    {
			LOG( LTKLogger::LTK_LOGLEVEL_ERR) << 
			"Error: "<<ECHANNEL_NOT_FOUND <<": "<<
			getErrorMessage(ECHANNEL_NOT_FOUND) <<
			"LTKTrace::reassignChannelValues() "<<endl;

        LTKReturnError(ECHANNEL_NOT_FOUND);
    }
    
	// updating the changed values of a channel in  m_traceChannels vector.
	m_traceChannels[channelIndex] = channelData; 

	LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
	"Exiting: LTKTrace::reassignChannelValues()"<<endl;
	
	return SUCCESS;
}


/******************************************************************************
* AUTHOR		: Balaji R.
* DATE			: 23-DEC-2004
* NAME			: setAllChannelValues
* DESCRIPTION	: This method reassigns the values of all the channels. The number 
*                 of rows in the input 2D vector must be equal to the current number 
*                 of channels with each row having the same length. And this assumes 
*                 one-to-one correspondence with the channel vector.
* ARGUMENTS		: allChannelValues - new values of all the channels  
*				  channelData - new data for the channel reset
* RETURNS		: SUCCESS on successful reset
* NOTES			:
* CHANGE HISTROY
* Author			Date				Description of change
******************************************************************************/

int LTKTrace::setAllChannelValues(const float2DVector& allChannelValues)
{
	LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
	"Entering: LTKTrace::setAllChannelValues()"<<endl;

    if(allChannelValues.size() != m_traceFormat.getNumChannels())
    {

			LOG( LTKLogger::LTK_LOGLEVEL_ERR) << 
			"Error: "<<ENUM_CHANNELS_MISMATCH <<": "<<
			getErrorMessage(ENUM_CHANNELS_MISMATCH) <<
			"LTKTrace::setAllChannelValues() "<<endl;

			 LTKReturnError(ENUM_CHANNELS_MISMATCH);
    }
    
    if(allChannelValues[0].size()==0)
    {
        	LOG( LTKLogger::LTK_LOGLEVEL_ERR) << 
			"Error: "<<EEMPTY_VECTOR <<": "<<
			getErrorMessage(EEMPTY_VECTOR) <<
			"LTKTrace::setAllChannelValues() "<<endl;

       LTKReturnError(EEMPTY_VECTOR);                               
    }
    
    int prevRowSize=allChannelValues[0].size();
    int currRowSize=0;
    
    for(int i=1; i<allChannelValues.size(); ++i)
    {
         currRowSize = allChannelValues[i].size();
         
         if(currRowSize != prevRowSize)
         {
           	LOG( LTKLogger::LTK_LOGLEVEL_ERR) << 
				"Error: "<<EUNEQUAL_LENGTH_VECTORS <<": "<<
				getErrorMessage(EUNEQUAL_LENGTH_VECTORS) <<
				"LTKTrace::setAllChannelValues() "<<endl;

           LTKReturnError(EUNEQUAL_LENGTH_VECTORS);              
         }
         
         prevRowSize = currRowSize;
    }
    
    m_traceChannels = allChannelValues;

	LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
	"Exiting: LTKTrace::setAllChannelValues()"<<endl;
	
    
    return SUCCESS;
}



/******************************************************************************
* AUTHOR		: Balaji R.
* DATE			: 23-DEC-2004
* NAME			: addPoint
* DESCRIPTION	: adds a point to the trace
* ARGUMENTS		: pointVec - point to be added to the trace
* RETURNS		: SUCCESS on successful addition
* NOTES			:
* CHANGE HISTROY
* Author			Date				Description of change
******************************************************************************/
int LTKTrace::addPoint(const floatVector& pointVec)
{
	LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
	"Entering: LTKTrace::setAllChannelValues()"<<endl;

	int numChannels = m_traceFormat.getNumChannels();

	if ( pointVec.size() != numChannels )
	{
			LOG( LTKLogger::LTK_LOGLEVEL_ERR) << 
				"Error: "<<EUNEQUAL_LENGTH_VECTORS <<": "<<
				getErrorMessage(EUNEQUAL_LENGTH_VECTORS) <<
				"LTKTrace::setAllChannelValues() "<<endl;

		LTKReturnError(ENUM_CHANNELS_MISMATCH);
	}

	// Adding the new point in m_traceChannels vector.
	for(int index=0; index < numChannels; ++index)
	{
		(m_traceChannels[index]).push_back(pointVec[index]);
	}
	
	LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
	"Exiting: LTKTrace::setAllChannelValues()"<<endl;
	
	return SUCCESS;
}

/******************************************************************************
* AUTHOR		: Balaji R.
* DATE			: 23-DEC-2004
* NAME			: addChannel
* DESCRIPTION	: adds a new channel to the trace
* ARGUMENTS		: channelValuesVec - values of the new channel
*				  channelName - new channel name
* RETURNS		: SUCCESS on successful addition
* NOTES			:
* CHANGE HISTROY
* Author			Date				Description of change
*******************************************************************************/

int LTKTrace::addChannel(const floatVector &channelValuesVec, 
						 const LTKChannel& channel)
{
	LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
	"Entering: LTKTrace::addChannel()"<<endl;

	if ( m_traceChannels[0].size() !=0 && 
        channelValuesVec.size()  != m_traceChannels[0].size() )
	{
		LOG( LTKLogger::LTK_LOGLEVEL_ERR) << 
			"Error: "<<ECHANNEL_SIZE_MISMATCH <<": "<<
			m_traceChannels[0].size() <<
			"LTKTrace::addChannel() "<<endl;

		LTKReturnError(ECHANNEL_SIZE_MISMATCH);
	}

    int errorCode = m_traceFormat.addChannel(channel);

    if (errorCode != SUCCESS)
    {
        LTKReturnError(errorCode);
    }

	m_traceChannels.push_back(channelValuesVec);

	LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
	"Exiting: LTKTrace::addChannel()"<<endl;
	
	return SUCCESS;
}


/******************************************************************************
* AUTHOR		: Balaji R.
* DATE			: 23-DEC-2004
* NAME			: ~LTKTrace
* DESCRIPTION	: destructor
* ARGUMENTS		: 
* RETURNS		: 
* NOTES			:
* CHANGE HISTROY
* Author			Date				Description of change
******************************************************************************/

LTKTrace::~LTKTrace()
{
}

/******************************************************************************
* AUTHOR		: Bharath A
* DATE			: 17-DEC-2007
* NAME			: emptyTrace
* DESCRIPTION	: To empty the channel values but retain the trace format
* ARGUMENTS		: 
* RETURNS		: 
* NOTES			:
* CHANGE HISTROY
* Author			Date				Description of change
*******************************************************************************/
void LTKTrace::emptyTrace()
{
	LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
	"Entering: LTKTrace::emptyTrace()"<<endl;

    for(int i=0;i<m_traceChannels.size();++i)
    {
       m_traceChannels[i].clear();
    }
	LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
	"Exiting: LTKTrace::emptyTrace()"<<endl;
	
}


/******************************************************************************
* AUTHOR		: Dinesh M
* DATE			: 17-Dec-2007
* NAME			: isEmpty
* DESCRIPTION	: Checks if the data vector is empty
* ARGUMENTS		: 
* RETURNS		: 
* NOTES			:
* CHANGE HISTROY
* Author			Date				Description of change
******************************************************************************/
bool LTKTrace::isEmpty() const
{
	LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
	"Entering: LTKTrace::isEmpty()"<<endl;

 
	LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
	"Exiting: LTKTrace::isEmpty()"<<endl;
	
    return (m_traceChannels[0].size()==0);
}


/******************************************************************************
* AUTHOR		: Dinesh M
* DATE			: 17-Dec-2007
* NAME			: getTraceFormat
* DESCRIPTION	: Getter on the current trace format
* ARGUMENTS		: 
* RETURNS		: const LTKTraceFormat&
* NOTES			:
* CHANGE HISTROY
* Author			Date				Description of change
******************************************************************************/

const LTKTraceFormat& LTKTrace::getTraceFormat() const
{
	LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
	"Entering: LTKTrace::getTraceFormat()"<<endl;

 
	LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) <<
	"Exiting: LTKTrace::getTraceFormat()"<<endl;
	
  return m_traceFormat;    
}