Problem in creating a time_keeping application

jeferson lemos via gtkmm-list <[email protected]> Sat, 21 May 2022 20:20:44 -0300
Newsgroups gmane.comp.gnome.gtkmm
Message-ID <CAN5QtHM_G1qZ2GTZ7-Kjy3WNtHsm-jfA0Apbb5yY0vRx41wuSA@mail.gmail.com>
--===============8399058177349686881==
Content-Type: multipart/alternative; boundary="000000000000c1cb2105df8ddb5f"

--000000000000c1cb2105df8ddb5f
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

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 =3D Glib::DateTime::create_now_local(); };
//bool operator =3D=3D ( Time_Keeper *t) { return t =3D=3D 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
=E2=80=98Time_Keeper& Time_Keeper::operator=3D(const Time_Keeper&)=E2=80=99
71 |                 bind_time [position] =3D *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: =E2=80=98Time_Keeper&
Time_Keeper::operator=3D(const Time_Keeper&)=E2=80=99 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
=E2=80=98Glib::Timer& Glib::Timer::operator=3D(const Glib::Timer&)=E2=80=99
In file included from /usr/include/glibmm-2.4/glibmm.h:158,
...
45 |   Timer& operator=3D(const Timer&) =3D 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

--000000000000c1cb2105df8ddb5f
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"auto"><div dir=3D"ltr"><div>I am having problems with as to Gli=
b::Timer seems to be no copyable</div><div><br></div><div>on the code bello=
w</div><div><br></div><div>#ifndef _TIME_KEEPER_H_<br>#define _TIME_KEEPER_=
H_<br><br>#include &lt;glibmm/datetime.h&gt;<br>#include &lt;glibmm/timer.h=
&gt;<br><br>class Time_Keeper<br>{<br>public:<br>	void start_timer(){ /*tim=
er.start();*/ };<br>	void stop_timer(){ /*timer.stop();*/ };<br>	void reset=
_timer(){ /*timer.reset();*/ };<br>	std::string display_timer() { return &q=
uot;&quot; /*( std::to_string(((int) (timer.elapsed()/3600)))+\<br>	 =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 &quot;:&quot;+std::to_string(((in=
t) (timer.elapsed()/60)))+\<br>	 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 &quot;:&quot;+std::to_string(timer.elapsed() ))*/; };<br>	//const st=
d::string hasheable (){ return (( const std::string) display_timer()); };<b=
r>	//Time_Keeper(){ start_time =3D Glib::DateTime::create_now_local(); };<b=
r>	//bool operator =3D=3D ( Time_Keeper *t) { return t =3D=3D this; };<br><=
br>protected:<br><br>private:<br>	Glib::DateTime start_time;<br>	Glib::Time=
Span elapsed_time; <br>	//Glib::Timer timer;<br>};<br><br>#endif // _TIME_K=
EEPER_H_</div><div><br></div><div>if I try to uncomment the timer variable =
I immediately get the error</div><div>.../time_keeper/src/u-i-controller.cc=
:71:41: error: use of deleted function =E2=80=98Time_Keeper&amp; Time_Keepe=
r::operator=3D(const Time_Keeper&amp;)=E2=80=99</div><div>71 | =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 bind_time [position] =3D *tim=
e;</div><div>| =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 ^~~~~</div><div>In file included from .../time_keeper/src/u-i-contro=
ller.h:26,</div><div>from .../time_keeper/src/u-i-controller.cc:20:</div><d=
iv>.../time_keeper/src/time-keeper.h:26:7: note: =E2=80=98Time_Keeper&amp; =
Time_Keeper::operator=3D(const Time_Keeper&amp;)=E2=80=99 is implicitly del=
eted because the default definition would be ill-formed:</div><div><br></di=
v><div>26 | class Time_Keeper</div><div>| =C2=A0 =C2=A0 =C2=A0 ^~~~~~~~~~~<=
/div><div>.../time_keeper/src/time-keeper.h:26:7: error: use of deleted fun=
ction =E2=80=98Glib::Timer&amp; Glib::Timer::operator=3D(const Glib::Timer&=
amp;)=E2=80=99</div><div>In file included from /usr/include/glibmm-2.4/glib=
mm.h:158,</div><div>...</div><div>45 | =C2=A0 Timer&amp; operator=3D(const =
Timer&amp;) =3D delete;</div><div><br></div><div>It seems to be deliberatel=
y enforced for some reason, but is there some workaround?</div><div>I was t=
rying to show a couple of timers on the interface, which requires managing =
objects<br></div></div></div>

--000000000000c1cb2105df8ddb5f--

--===============8399058177349686881==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
gtkmm-list mailing list
[email protected]
https://mail.gnome.org/mailman/listinfo/gtkmm-list

--===============8399058177349686881==--