Design issue

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Airslash
    New Member
    • Nov 2007
    • 221

    #1

    Design issue

    Hello,

    not really sure if this is the right forum, but I have a slight design issue with my 2 classes. I currently have a Drive class which represents a physical harddrive in a computer and relies on the Windows API call to fetch information from the drive such as free space, total space etc.

    I also have a DriveManager class which is a Singleton and contains an internal vector of Drive objects. The DriveManager has several functions that takes a long as RecordId from the database and a Drive** pointer to return a reference to one of the internal drive objects.

    I've made all the function so that the pointer needs to be a Const Drive* pointer to prevent changes to be made to the internal drive objects, yet returning them to the outside without danger.
    I currently do have the issues, that I need to be able to make 1 fundamental change to a drive object, namely that I need to be able to mark it as unusable if the drive is damaged for example.

    Due the use of const, I simply cant update the object since its const.
    I've been thinking of making the setter on the Drive object const, but this kinda violates the usage of const then.

    I could simply remove const from all my functions, but then it becomes rather unsafe to release the class.....

    Anyone have a clean suggestion how I can keep my const but have a function that would be able to change such an object?
Working...