Who can join me in a new open source project?

Pages: 12
May 13, 2011 at 12:25am
Hi, the project seems interesting.
A few things:
_ why classes instead of objects?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
class FootUnit : public LengthUnit
	{
		//Constructors
	public:
		FootUnit() : LengthUnit()
		{ }
		
		//Helpers
	protected:
		virtual LPCTSTR GetSymbolNoPrefix() const { return _T("ft"); }
		virtual Unit* Clone() const { return new FootUnit(); }
		
		//Public Interface
	public:
		virtual double GetFactor() const { return 0.3048; }
		virtual LPCTSTR GetName() const { return _T("foot"); }
		
		//Singleton
	public:
		static const FootUnit Foot;
	};
//instead you could doo
extern LengthUnit Feet; // .h
LengthUnit Feet (0.3048, "foot", "ft"); // .cpp 


_ You could store in the SI, and just do the conversions in input/output (maybe I'm misreading the code)

_ what does LPTSTR mean?
May 13, 2011 at 12:27am
Hi. Thanks for pointing out the error.

No, I am not ignoring errors or warnings. I just don't get those in MS VS 2008. If you see errors, please, by all means point them out. I just updated the code to include all classes inside a namespace and define some shortcuts.

As usual, I get a bunch of errors from the online compiler that MS VS2008 do not. Feel free to critique further.
May 13, 2011 at 12:50am
Hello ne555. Thanks for dropping by. Glad you like the project.

I know what you mean:

1
2
3
4
5
6
7
8
9
10
class LengthUnit : public Unit
{
...
public:
    static const LengthUnit Foot;
    static const LengthUnit Meter;
};

const LengthUnit LengthUnit::Foot("foot", "ft", 0.3048, false);
const LengthUnit LengthUnit::Meter("meter", "m", 1.0, true);


The answer is: It could be. Right now, I am not 100% if I need entire classes to differentiate. I did this "just in case", just as I did LengthUnit, TimeUnit, etc. Maybe the class tree can be reduced.

Now I know LengthUnit, TimeUnit, etc. were good choices because objects of type Length, Time, etc. can reject units that are not of the correct dimensions (correct base unit type).

EDIT: So sorry I left one of your questions hanging: LPTSTR is char * if _UNICODE is not defined, and it is wchar_t* if _UNICODE is defined. It fits the scheme used by the Windows SDK, and actually it is exactly what the Windows SDK does.
Last edited on May 13, 2011 at 1:03am
May 13, 2011 at 4:36am
FYI, I won't be online for two days. Back on Sunday or Monday.

Feel free to point out the many errors you encounter, especially those that I don't catch/know because I'm such a Windows groupie, hehe. This should compile for any OS, so your help in this regard is much appreciated.
Last edited on May 13, 2011 at 4:37am
May 13, 2011 at 4:57pm
The idea about using LengthUnit as an object is kind of close to what I suggested from the beginning (different thread). If it comes to a vote that's the way I would want to go. But either way I'm too interested in this idea to abandon it because a tiny difference in opinion like that.
May 15, 2011 at 12:11am
Hello, I'm back one day early; trip got cut off in half.

I'll see how I would program Temperature to see if it affects the Temperature units.
May 15, 2011 at 12:44am
What is best: A static library, or a DLL? Is there an equivalent in Linux for a DLL? Can the source code be kept portable?
May 15, 2011 at 6:45am
In linux almost all is contained in "DLLs", which are linux shared library with .so extension. Very few programs are statically compiled.

Source code can of course be portable if you use frameworks like QT, wxWidgets or whatever ...
May 15, 2011 at 4:36pm
Does this library just convert between SI units and things like this, or does/will it have classes to e.g. calculate quantities like force and velocity, do vector math, that kind of thing?

If so, I'd be very interested in helping with that sort of thing. I've written a Euclidean vector class already, I can post it if you'd like. It depends on a vertex class I wrote as well.
May 15, 2011 at 4:45pm
@ chrisname: We'll get there, but the goal is to be able to process those calculations regardless of input. In order to do this we need to be able to move seemlessly between Imperial units and Metric.
May 15, 2011 at 7:04pm
Hello everyone. I decided to stick with CodePlex. My apologies if this is disappointing for anyone. I like 2 things there: 1. No extra username as I can log in using my Live ID; 2. I can use SVN.

I have no cool name for this yet, so for now it is called "Dimensional Values" and is not yet published. Since the coding so far has been small (more class definitions than anything else), I decided it would be nice to see how it behaves as a static library. I guess we can later change the project type or even maybe have both? If MFC and ATL can be both, why can't we, right?

I'll continue moving some code around and then I'll publish. If you guys (willing to participate) have Live ID's, I guess I'll need them to give you access to the projects. PM me those so they are kept private.
Topic archived. No new replies allowed.
Pages: 12