I have a template queue classe..
template < class T, size_t N > class LocklessQueue;
Now I want to create a STATIC queue that both a reader thread and writer thread can access. No problem right? Just inherit the static class to both 'reader' and 'writer' thread.
The problem is, if I do that, both the reader and writer thread have unrestricted access to the queue object (the reader can write, when it should only be able to read, ect...).
So I decided to make a little 'QueReader/QueWriter' wrapper class, that would restrict access to the base LocklessQueue class...
template < class T, size_t N > class QueReader {
public:
Reader( LocklessQueue<T,N>* ptr ) : mQuePtr(ptr) {}
//read functions go here, they use the mQuePtr
private:
LocklessQueue<T,N>* mQuePtr;
};
Seems good so far, right?
So to recap, the idea is we start with a static base class LocklessQueue, from that we sub class a 'QueReader' (which restricts access to the LocklessQueue), then we inherit THAT 'QueReader' class to the 'reader thread' (so it can only READ from the que, not write to it).
Heres what I got so far...
template < class T, size_t N > class QueReader {
public:
QueReader( LQ::LocklessQueue<T,N>* ptr ) : mQuePtr(ptr) {}
//read functions go here
private:
LQ::LocklessQueue<T,N>* mQuePtr;
};
class SysNameQue {
public:
static LQ::LocklessQueue< int, 4 > que;
};
class SysNameQueReader : public SysNameQue {
public:
QueReader< int, 4 > mMyReader( static &que );
};
...I get the following error...
c:\zealengine\application\systems\template\sysnameque.h(30) : warning C4042: 'que' : has bad storage class
c:\zealengine\application\systems\template\sysnameque.h(30) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Im guessing im misusing static in some way?
Thanks in advance for any info!