<Other public methods of off_TmrSrv. >+= (<-U) [<-D->]
// Returns a navigator for timer servers.
off_Navigator *get_navigator(void) { return NULL; }
<Off timer server dependencies. >+= (U->) [<-D->] #include <klib/nav.h> // for off_Navigator et al.
\subsubsection{Timer server inspection}
We have to implement get_url and nameof.
<Other public methods of off_TmrSrv. >+= (<-U) [<-D->]
// Get the timer server URL.
const char *get_url(void);
// Returns the timer server name.
const char *nameof(void);
The URL for a timer server is that of its node with tmrsrv.html
appended. We use a new member, a character array initialized the very
first time it is needed.
<Other private members of off_TmrSrv. >+= (<-U) [<-D->]
static char *t_url; // URL for this TmrSrv.
<Off timer server static members. >= (U->) char *off_TmrSrv::t_url=NULL; // URL for this TmrSrv.
<off_TmrSrv::get_url implementation. >= (U->)
// Get the timer server URL.
const char *off_TmrSrv::get_url(void)
{
assert(valid());
if (!t_url){
t_url=new char[strlen(nd.get_url())+strlen(OFF_TMRSRV_URL)+1]; //+1 for \0
if (t_url){
strcpy(t_url,nd.get_url());
strcat(t_url,OFF_TMRSRV_URL);
}
}
return t_url;
}
Where he have to define the relative URL for timer servers.
<Off source code urls. >= [D->] const char OFF_TMRSRV_URL[]="/tmrsrv.html";
<Off timer server dependencies. >+= (U->) [<-D] #include <klib/url.h> // for OFF_TMRSRV_URL
<Off timer server implementation dependencies. >+= (U->) [<-D->] #include <string.h> // for strcat strdup et al #include <node/Node.h> // for nd
The name for a timer server is that of its node complemented with a
little suffix. The implementation is almost the same of get_url.
<off_TmrSrv::nameof implementation. >= (U->)
// Returns the timer server name.
const char *off_TmrSrv::nameof(void)
{
assert(valid());
if (!t_name){
t_name = new char[strlen(nd.nameof())+strlen("/tmr")+9]; // for N...N\0
if (t_name){
char number[9];
strcpy(t_name,nd.nameof());
strcat(t_name,"/tmr");
sprintf(number,"%08x",(natural_t)get_id());
strcat(t_name,number);
}
}
return t_name;
}
<Other private members of off_TmrSrv. >+= (<-U) [<-D]
char *t_name; // name for this TmrSrv
<Initialize other aggregate members of off_TmrSrv. >+= (<-U) [<-D]
t_name(NULL)
\subsubsection{Timer inspection}
We need get_rurl and get_url_holder for timers to support
ResUnit::get_url.
<Other protected methods of off_Tmr. >+= (<-U) [<-D->]
// Get the timer url
virtual const char *get_rurl(void) const { return OFF_TMR_URL; }
// Returns the timer name.
virtual char *&get_url_holder(void);
He have to define the relative URL for timers.
<Off source code urls. >+= [<-D] const char OFF_TMR_URL[]="#Tmr";
DefinesOFF_TMR_URL(links are to index).
<Off timer dependencies. >+= (U->) [<-D] #include <klib/url.h> // for OFF_TMR_URL
<Off timer implementation dependencies. >+= (U->) [<-D] #include <stdio.h> // for sprintf et al
URLs are the same for all timers.
<Other private members of off_Tmr. >= (<-U)
static char *t_url; // URL for this timer.
<off_Tmr::get_url_holder implementation. >= (U->)
char *&off_Tmr::get_url_holder(void) { return t_url; }
<Off timer static members. >= (U->) char *off_Tmr::t_url=NULL; // URL for timers.
NOTE: Not yet implemented.