OK, I'm continuing to plug away at my Ananke code and I would like some advice on structuring my code. As I've added in beacons, multiple meshes and so on I've found that the member functions of the Ananke class are getting a little bloated. To try and keep the code readable and maintainable, it is my thought to move some parts of this code into other classes, like this:
The Ananke constructor (or clbkPostCreation?) would create a new instance of BEACON_MANAGER/MESH_MANAGER for each instance of Ananke. The destructor could remove those instances when a vessel is deleted.
First question, is this a reasonable way to approach the problem? If not, any other suggestions?
I'll proceed on the assumption that I am on the right track. What is a good way for the members of BEACON_MANAGER/MESH_MANAGER to get access to the members of Ananke (eg, SomeFunction/SomeVariable)? Do I need to make those members public and then pass an Ananke pointer to the BEACON_MANAGER/MESH_MANAGER constructors? If so, how would I declare such a pointer? I can't do this because class Ananke would not be defined at the point of the declaration (see comment):
Final question, I have some global "const"s that define various properties of the vessel (eg, masses and size of various components). Would these be better or worse as "static const" members of the Ananke class?
Any advice/opinions are appreciated. Apologies for the long winded post - my last attempt at restructuring AttitudeMFD so I could implement some new features ended up making the code even harder for me to maintain/debug and I don't want to make the same mistake with this vessel. Thanks in advance.
Code:
class BEACON_MANAGER {
//...
};
class MESH_MANAGER {
//...
};
class Ananke: public VESSEL2 {
//...
void SomeFunction();
SOME_TYPE SomeVariable;
BEACON_MANAGER *BeaconManager;
MESH_MANAGER *MeshManager;
//...
}
First question, is this a reasonable way to approach the problem? If not, any other suggestions?
I'll proceed on the assumption that I am on the right track. What is a good way for the members of BEACON_MANAGER/MESH_MANAGER to get access to the members of Ananke (eg, SomeFunction/SomeVariable)? Do I need to make those members public and then pass an Ananke pointer to the BEACON_MANAGER/MESH_MANAGER constructors? If so, how would I declare such a pointer? I can't do this because class Ananke would not be defined at the point of the declaration (see comment):
Code:
class BEACON_MANAGER {
BEACON_MANAGER(Ananke *hAnanke) { //invalid because class Ananke not defined yet?
//...
};
//...
};
class Ananke: public VESSEL2 {
public:
Ananke (OBJHANDLE hVessel, int flightmodel)
: VESSEL2 (hVessel, flightmodel);
//...
private:
BEACON_MANAGER *BeaconManager;
//...
}
Ananke::Ananke (OBJHANDLE hVessel, int flightmodel) {
BeaconManager = new BEACON_MANAGER;
}
Any advice/opinions are appreciated. Apologies for the long winded post - my last attempt at restructuring AttitudeMFD so I could implement some new features ended up making the code even harder for me to maintain/debug and I don't want to make the same mistake with this vessel. Thanks in advance.
--> :dance2:-->