Le 07/12/2012 09:25, Jean-Michel Caricand a écrit :
> Le 06/12/2012 23:17, Tommi Mäkitalo a écrit :
>> Am 06.12.2012 22:48, schrieb Jean-Michel Caricand:
>>> Hello,
>>>
>>> I want to use variables defined in tntnet.xml outside a component. How
>>> to get an instance of tnt :: Config? Is it possible?
>>>
>>>
>>> Thanks,
>>>
>>> Jean-Michel
>> tnt::Config is handled as a singleton. You get a reference to the static
>> instance using:
>>
>> tnt::TntConfig::it()
>>
>> So if you for example want to get the session timeout, you use:
>>
>> unsigned sessionTimeout = tnt::TntConfig::it().sessionTimeout;
>>
>> TntConfig is a structure, where all settings are stored in public variables.
>>
>> Tommi
>>
>> ------------------------------------------------------------------------------
>> LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
>> Remotely access PCs and mobile devices and provide instant support
>> Improve your efficiency, and focus on delivering more value-add services
>> Discover what IT Professionals Know. Rescue delivers
>> http://p.sf.net/sfu/logmein_12329d2d
>> _______________________________________________
>> Tntnet-general mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/tntnet-general
> Hi Tommi,
>
> And if I want to access my variables, not predefined variables ?
>
> Jean-Michel
>
>
> ------------------------------------------------------------------------------
> LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
> Remotely access PCs and mobile devices and provide instant support
> Improve your efficiency, and focus on delivering more value-add services
> Discover what IT Professionals Know. Rescue delivers
> http://p.sf.net/sfu/logmein_12329d2d
> _______________________________________________
> Tntnet-general mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/tntnet-general

Hello,

std::string v;
tnt::TntConfig::it().config.getMember<std::string>("myvariable", v);
log_info(v);

That works :) !

Jean-Michel




------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
Tntnet-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tntnet-general

Reply via email to