|
peterchen wrote:
Count me in, but we should do our homework before.
Jeeesh, for someone so critical about CPP you sure are obsessed about it *
As for SourceForge; SF is not Code Project. Why would we want to put CP things on something that is not CP? All of us would have to sign up as SF members, learn how SF works and it would loose all the cool orange. I do see the point that SF has all the right tools, but...
...this is a Code Project initiative. It is going to have the CP stamp, it is CP members, Chris is already bending over backwards to accomodate it, it is all CP so lets keep it in house and keep the spirit alive.
Afterall a well ordered but heartless project is not going to work, while a less-ordered but spirited project is at the very least going to be a blast.
We are CPians, CP is our base, all your base are belong to us
* hey! relax, that was a poke... peterchen.. put DOWN the flamethrow... yeeeeaaarrgghhhhh
Paul Watson Bluegrass Cape Town, South Africa
Chris Losinger wrote:
i hate needles so much i can't even imagine allowing one near The Little Programmer
|
|
|
|
|
Yep, Munich doesn't want to upgrade NT->XP, they wanna go IBM+Suse.
Wonder what it's going to cost:
>> Retraining Staff?
heck, these are Resis from the Wiesn, they get nervous when you reaarange the desktop icons, and when they see your toolbar alignment they say "my word looks different"
>> cost of applications? StarOffice won't run a town, will it?
>> New Administrators?
>> what if SCO sues them?
"Der Geist des Kriegers ist erwacht / Ich hab die Macht" StS
sighist | Agile Programming | doxygen
|
|
|
|
|
Rationale: I needed reference counted C++ objects in a large project that heavily relies on ATL anyway. So why not reuse the COM smart pointer classes?
(See my reply for copypastable code)
template <class ThreadModel = CComSingleThreadModel>
class CRefCountableBase
{
private:
LONG _ref;
public:
CRefCountableBase()
{
_ref = 0;
}
~CRefCountableBase()
{
_ASSERTE(_ref == 0);
}
ULONG AddRef()
{
return ThreadModel::Increment(&_ref);
}
ULONG Release()
{
LONG zero = ThreadModel::Decrement(&_ref);
if (zero == 0)
delete this;
return zero;
}
HRESULT QueryInterface(REFIID riid, void ** ppvObject)
{
return E_NOTIMPL;
}
template <class T>
static void CreateInstance(_com_ptr_t< _com_IIID<T, &GUID_NULL> > & ptr)
{
T * instance = new T;
if (instance == 0)
return;
ptr.Attach(instance, true);
}
};
typedef CRefCountableBase<CComSingleThreadModel> CRefCountableBaseST;
typedef CRefCountableBase<CComMultiThreadModel> CRefCountableBaseMT;
#define CPP_SMARTPTR_TYPEDEF(CLASS) \
typedef _com_ptr_t< _com_IIID<CLASS, &GUID_NULL> > CLASS ## Ptr;
"Der Geist des Kriegers ist erwacht / Ich hab die Macht" StS
sighist | Agile Programming | doxygen
|
|
|
|
|
// ==============================================================
// CRefcountableBase
// --------------------------------------------------------------
/// This class allows to reuse _com_ptr_t smart pointers for
/// generic C++ classes.
/// Inherit the class to be refcounted from CRefCountableBaseST
/// for single threaded, or CRefCountableBaseMT for thread-safe refcounting.
/// use CPP_SMARTPTR_TYPEDEF(CMyClass) to declare the CMyClassPtr smart pointer.
//
template <class ThreadModel = CComSingleThreadModel>
class CRefCountableBase
{
private:
LONG _ref;
public:
CRefCountableBase()
{
_ref = 0;
}
~CRefCountableBase()
{
_ASSERTE(_ref == 0);
}
ULONG AddRef()
{
return ThreadModel::Increment(&_ref);
}
ULONG Release()
{
LONG zero = ThreadModel::Decrement(&_ref);
if (zero == 0)
delete this;
return zero;
}
HRESULT QueryInterface(REFIID riid, void ** ppvObject)
{
return E_NOTIMPL;
}
template <class T>
static void CreateInstance(_com_ptr_t< _com_IIID<T, &GUID_NULL> > & ptr)
{
T * instance = new T;
if (instance == 0)
return;
ptr.Attach(instance, true);
}
};
typedef CRefCountableBase<CComSingleThreadModel> CRefCountableBaseST;
typedef CRefCountableBase<CComMultiThreadModel> CRefCountableBaseMT;
#define CPP_SMARTPTR_TYPEDEF(CLASS) \
typedef _com_ptr_t< _com_IIID<CLASS, &GUID_NULL> > CLASS ## Ptr;
|
|
|
|
|
|
I agree 100 % on your article on Agile Programming.
However, most people think I am crazy when I start talkning about Agile Programming or Xtreeme Programming. But I know I am right.
|
|
|
|