Problem in creating a time_keeping application



I am having problems with as to Glib::Timer seems to be no copyable

on the code bellow

#ifndef _TIME_KEEPER_H_
#define _TIME_KEEPER_H_

#include <glibmm/datetime.h>
#include <glibmm/timer.h>

class Time_Keeper
{
public:
void start_timer(){ /*timer.start();*/ };
void stop_timer(){ /*timer.stop();*/ };
void reset_timer(){ /*timer.reset();*/ };
std::string display_timer() { return "" /*( std::to_string(((int) (timer.elapsed()/3600)))+\
                                                        ":"+std::to_string(((int) (timer.elapsed()/60)))+\
                                                        ":"+std::to_string(timer.elapsed() ))*/; };
//const std::string hasheable (){ return (( const std::string) display_timer()); };
//Time_Keeper(){ start_time = Glib::DateTime::create_now_local(); };
//bool operator == ( Time_Keeper *t) { return t == this; };

protected:

private:
Glib::DateTime start_time;
Glib::TimeSpan elapsed_time;
//Glib::Timer timer;
};

#endif // _TIME_KEEPER_H_

if I try to uncomment the timer variable I immediately get the error
.../time_keeper/src/u-i-controller.cc:71:41: error: use of deleted function ‘Time_Keeper& Time_Keeper::operator=(const Time_Keeper&)’
71 |                 bind_time [position] = *time;
|                                         ^~~~~
In file included from .../time_keeper/src/u-i-controller.h:26,
from .../time_keeper/src/u-i-controller.cc:20:
.../time_keeper/src/time-keeper.h:26:7: note: ‘Time_Keeper& Time_Keeper::operator=(const Time_Keeper&)’ is implicitly deleted because the default definition would be ill-formed:

26 | class Time_Keeper
|       ^~~~~~~~~~~
.../time_keeper/src/time-keeper.h:26:7: error: use of deleted function ‘Glib::Timer& Glib::Timer::operator=(const Glib::Timer&)’
In file included from /usr/include/glibmm-2.4/glibmm.h:158,
...
45 |   Timer& operator=(const Timer&) = delete;

It seems to be deliberately enforced for some reason, but is there some workaround?
I was trying to show a couple of timers on the interface, which requires managing objects


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]