Click here to Skip to main content
15,890,512 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Where is printf? Pin
CPallini10-Jun-09 21:24
mveCPallini10-Jun-09 21:24 
QuestionWrong help file afxhelp.hm path in VC 6.0 SOLVED Pin
Vaclav_10-Jun-09 10:00
Vaclav_10-Jun-09 10:00 
AnswerRe: Wrong help file afxhelp.hm path in VC 6.0 Pin
Randor 10-Jun-09 10:42
professional Randor 10-Jun-09 10:42 
GeneralRe: Wrong help file afxhelp.hm path in VC 6.0 Pin
Vaclav_11-Jun-09 7:27
Vaclav_11-Jun-09 7:27 
QuestionSharing a singleton in an executable and a runtime DLL Pin
Dustin Henry10-Jun-09 6:50
Dustin Henry10-Jun-09 6:50 
AnswerRe: Sharing a singleton in an executable and a runtime DLL Pin
Stuart Dootson10-Jun-09 8:40
professionalStuart Dootson10-Jun-09 8:40 
GeneralRe: Sharing a singleton in an executable and a runtime DLL Pin
Dustin Henry11-Jun-09 11:19
Dustin Henry11-Jun-09 11:19 
GeneralRe: Sharing a singleton in an executable and a runtime DLL Pin
Stuart Dootson11-Jun-09 22:09
professionalStuart Dootson11-Jun-09 22:09 
I went back and had a look at the reporting implementation I wrote - I think the main difference is that I put my logger in a DLL, not the EXE. That way it's a lot easier for everything to link against it and be able to call it at run-time.

However, the implementation boiled down to what I described - there's a class with a single static function allowing reporting, and purely static (i.e. single instance for the whole class) data members:

Header file:
class Reporter
{
public:
   Reporter();

   /// Output a message at a specified level.
   static void Report(TMessageLevel level, const std::string& message);

   /// Determine if a message level is enabled and has attached output sink(s).
   static bool Reporting(TMessageLevel level);

private:
   static TMessageLevel level_; // Store message levels to be output - a bitmask
   static implementation-defined message_; // Output sink mechanism
   enum { ReportLevelCount = sizeof(Reporter::level_) * 8 };
};


C++ file:
Reporter::Reporter()
{
}

void Reporter::Report(TMessageLevel level, const std::string& message)
{
   if (Reporting(level)) {
      message_(message);
   }
}

// Reporter::Reporting
//
// Is the specified reporting level active? OnError is treated separately to other
// levels, as there's a separate reporting channel for errors
bool Reporter::Reporting(TMessageLevel level)
{
   int levelMask = (level < ReportLevelCount)?(1<<level):0;
   return (level_ & levelMask) && !message_.empty();
}


message_ is effectively a function object that allows me to hook up the output mechanism at runtime.

Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

QuestionStructure Value is not getting updated Pin
sakthii10-Jun-09 4:59
sakthii10-Jun-09 4:59 
AnswerRe: Structure Value is not getting updated Pin
«_Superman_»10-Jun-09 5:18
professional«_Superman_»10-Jun-09 5:18 
AnswerRe: Structure Value is not getting updated Pin
Stephen Hewitt10-Jun-09 5:25
Stephen Hewitt10-Jun-09 5:25 
AnswerRe: Structure Value is not getting updated Pin
Roger Stoltz10-Jun-09 5:42
Roger Stoltz10-Jun-09 5:42 
AnswerRe: Structure Value is not getting updated Pin
Randor 10-Jun-09 6:05
professional Randor 10-Jun-09 6:05 
QuestionRe: Structure Value is not getting updated Pin
David Crow10-Jun-09 7:47
David Crow10-Jun-09 7:47 
AnswerRe: Structure Value is not getting updated Pin
sakthii10-Jun-09 20:14
sakthii10-Jun-09 20:14 
GeneralRe: Structure Value is not getting updated Pin
Cedric Moonen10-Jun-09 20:24
Cedric Moonen10-Jun-09 20:24 
GeneralRe: Structure Value is not getting updated Pin
sakthii11-Jun-09 0:30
sakthii11-Jun-09 0:30 
AnswerRe: Structure Value is not getting updated Pin
chirag_chauhan10-Jun-09 20:46
chirag_chauhan10-Jun-09 20:46 
QuestionMCF question Pin
Anderson Jogie10-Jun-09 4:38
Anderson Jogie10-Jun-09 4:38 
QuestionRe: MCF question Pin
Maximilien10-Jun-09 4:42
Maximilien10-Jun-09 4:42 
AnswerRe: MCF question Pin
Anderson Jogie10-Jun-09 4:55
Anderson Jogie10-Jun-09 4:55 
GeneralRe: MCF question Pin
David Crow10-Jun-09 5:02
David Crow10-Jun-09 5:02 
GeneralRe: MCF question Pin
Anderson Jogie10-Jun-09 7:22
Anderson Jogie10-Jun-09 7:22 
GeneralRe: MCF question Pin
Anderson Jogie10-Jun-09 9:54
Anderson Jogie10-Jun-09 9:54 
AnswerRe: MCF question Pin
David Crow10-Jun-09 10:40
David Crow10-Jun-09 10:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.