Click here to Skip to main content
15,887,267 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: C++ class initialization Pin
Albert Holguin20-Jan-15 9:57
professionalAlbert Holguin20-Jan-15 9:57 
GeneralRe: C++ class initialization Pin
CPallini20-Jan-15 10:26
mveCPallini20-Jan-15 10:26 
General[SOLVED] Re: C++ class initialization Pin
Vaclav_22-Jan-15 8:00
Vaclav_22-Jan-15 8:00 
GeneralRe: [SOLVED] Re: C++ class initialization Pin
CPallini22-Jan-15 9:06
mveCPallini22-Jan-15 9:06 
GeneralRe: [REOPEN} C++ class initialization and scheme Pin
Vaclav_23-Jan-15 6:49
Vaclav_23-Jan-15 6:49 
GeneralRe: [REOPEN} C++ class initialization and scheme Pin
Mike Nordell2-Feb-15 10:14
Mike Nordell2-Feb-15 10:14 
GeneralRe: [REOPEN} C++ class initialization and scheme Pin
Vaclav_2-Feb-15 10:57
Vaclav_2-Feb-15 10:57 
GeneralRe: [REOPEN} C++ class initialization and scheme Pin
Mike Nordell2-Feb-15 12:46
Mike Nordell2-Feb-15 12:46 
To me, just based on this comment, it seems you'd have:
A "base", the driver. The singleton. This owns one or more
USBBus objects, each handling a physical connection. These in turn owns zero or more
USBDevice's, each representing a device on that bus.

Each USBDevice would in turn probably have one or more "functions" (e.g. a USB mouse with buttons, wheel, and some more clickable buttons could easily present 3 or more functions/sub-devices).

It also seems logical that each device (and function and so on) might need (hold) a reference to its owner, to f.ex. be able to notify it about events. Not to mention the obvious - verify correctness in such a highly dynamic and unpredictable system Smile | :)

I see no obvious reason any of the USB types should ever touch the global/static parts. But should the need arise; don't give them access to the data (if you ever used MFC, consider that the anti-thesis of good design). Instead provide them an interface - and not only an interface that returns a ref or ptr to the global/static var's, but something that actually do some work.

Which brings me to another good rule-of-thumb (actually, this one is more like a law of nature):
- Interfaces shall be minimal and complete.

Additionally:
- Member functions should do two things; Use the object's state (directly or indirectly), and not leak the objects state to the outside. If a function is not using the object's state, it has no business being a member function (not counting corner cases). If it's not hiding the internal state, it's "leaking" it to other types to use or abuse, and making it hard-to-impossible to change the implementation later on.

That last point, not leaking internal state to the outside, is worth hammering in over and over until you say "Obviously, anything else would be insanity!".

Later, if needed, "on the side" you might even find it useful to have a "registry" of devices, no matter what bus they are on, to save lookup time or whatever. F.ex. the system input handler might poll you about input events, and then you could have one list of devices dedicated to HID input. Another case could be the user requests "Put all storage devices to sleep" and instead of walking the busses and their devices (which in turn may have an expander (hub-ish) with another bus to dive into) you have a single list to iterate. You get the idea.

++luck;
Questionbinary data to image VC++ Pin
Mukund Pradeep16-Jan-15 18:40
Mukund Pradeep16-Jan-15 18:40 
QuestionRe: binary data to image VC++ Pin
CPallini16-Jan-15 22:33
mveCPallini16-Jan-15 22:33 
AnswerRe: binary data to image VC++ Pin
Richard MacCutchan16-Jan-15 22:45
mveRichard MacCutchan16-Jan-15 22:45 
GeneralRe: binary data to image VC++ Pin
Mukund Pradeep19-Jan-15 18:39
Mukund Pradeep19-Jan-15 18:39 
GeneralRe: binary data to image VC++ Pin
Mukund Pradeep3-Feb-15 18:08
Mukund Pradeep3-Feb-15 18:08 
GeneralRe: binary data to image VC++ Pin
Richard MacCutchan3-Feb-15 22:42
mveRichard MacCutchan3-Feb-15 22:42 
GeneralRe: binary data to image VC++ Pin
Mukund Pradeep9-Feb-15 20:17
Mukund Pradeep9-Feb-15 20:17 
QuestionRe: binary data to image VC++ Pin
Richard MacCutchan9-Feb-15 22:10
mveRichard MacCutchan9-Feb-15 22:10 
AnswerRe: binary data to image VC++ Pin
Mukund Pradeep9-Feb-15 22:36
Mukund Pradeep9-Feb-15 22:36 
GeneralRe: binary data to image VC++ Pin
Richard MacCutchan9-Feb-15 23:20
mveRichard MacCutchan9-Feb-15 23:20 
GeneralRe: binary data to image VC++ Pin
Mukund Pradeep10-Feb-15 17:21
Mukund Pradeep10-Feb-15 17:21 
GeneralRe: binary data to image VC++ Pin
Richard MacCutchan10-Feb-15 21:22
mveRichard MacCutchan10-Feb-15 21:22 
GeneralRe: binary data to image VC++ Pin
Mukund Pradeep10-Feb-15 22:05
Mukund Pradeep10-Feb-15 22:05 
AnswerRe: binary data to image VC++ Pin
Chris Losinger18-Jan-15 8:49
professionalChris Losinger18-Jan-15 8:49 
Questioncan a function return WCHAR Pin
bkelly1316-Jan-15 6:07
bkelly1316-Jan-15 6:07 
AnswerRe: can a function return WCHAR Pin
CPallini16-Jan-15 7:54
mveCPallini16-Jan-15 7:54 
GeneralRe: can a function return WCHAR Pin
bkelly1316-Jan-15 13:54
bkelly1316-Jan-15 13:54 

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.