StatusCreateFactory moved to misc, bitSet ref. counting added, minor Status mods

This commit is contained in:
Matej Sekoranja
2010-12-20 16:17:48 +01:00
parent b7f5dc5444
commit f522fe8e07
7 changed files with 67 additions and 11 deletions

1
.hgignore Normal file
View File

@@ -0,0 +1 @@
QtC-pvData.creator.user

View File

@@ -41,6 +41,7 @@ LIBSRCS += timeFunction.cpp
LIBSRCS += timer.cpp
LIBSRCS += queueVoid.cpp
LIBSRCS += messageQueue.cpp
LIBSRCS += StatusCreateFactory.cpp
SRC_DIRS += $(PVDATA)/pv
@@ -83,7 +84,6 @@ LIBSRCS += PVDataCreateFactory.cpp
LIBSRCS += Convert.cpp
LIBSRCS += StandardField.cpp
LIBSRCS += StandardPVField.cpp
LIBSRCS += StatusCreateFactory.cpp
SRC_DIRS += $(PVDATA)/property

View File

@@ -8,7 +8,7 @@
#include <cstdlib>
#include <string>
#include <cstdio>
#include <lock.h>
#include "lock.h"
#include "factory.h"
#include "byteBuffer.h"
#include "showConstructDestruct.h"
@@ -53,6 +53,13 @@ class StatusImpl : public Status
{
public:
StatusImpl(StatusType type, String message) :
m_type(type), m_message(message)
{
Lock xx(globalMutex);
totalConstruct++;
}
StatusImpl(StatusType type, String message, String stackDump) :
m_type(type), m_message(message), m_stackDump(stackDump)
{
@@ -150,13 +157,18 @@ class StatusCreateImpl : public StatusCreate {
m_ok = createStatus(STATUSTYPE_OK, "OK", 0);
}
~StatusCreateImpl()
{
delete m_ok;
}
virtual Status* getStatusOK() {
return m_ok;
}
virtual Status* createStatus(StatusType type, String message, BaseException* cause) {
if (cause == 0)
return new StatusImpl(type, message, "");
return new StatusImpl(type, message);
else
{
std::string stackDump;

View File

@@ -7,19 +7,63 @@
#include "string.h"
#include "stdio.h"
#include "bitSet.h"
#include "lock.h"
namespace epics { namespace pvData {
//static DebugLevel debugLevel = lowDebug;
static volatile int64 totalConstruct = 0;
static volatile int64 totalDestruct = 0;
static Mutex *globalMutex = 0;
static int64 getTotalConstruct()
{
Lock xx(globalMutex);
return totalConstruct;
}
static int64 getTotalDestruct()
{
Lock xx(globalMutex);
return totalDestruct;
}
static ConstructDestructCallback *pConstructDestructCallback;
static void init()
{
static Mutex mutex = Mutex();
Lock xx(&mutex);
if(globalMutex==0) {
globalMutex = new Mutex();
pConstructDestructCallback = new ConstructDestructCallback(
String("bitSet"),
getTotalConstruct,getTotalDestruct,0);
}
}
BitSet::BitSet() : words(0), wordsLength(0), wordsInUse(0) {
initWords(BITS_PER_WORD);
init();
Lock xx(globalMutex);
totalConstruct++;
}
BitSet::BitSet(uint32 nbits) : words(0), wordsLength(0), wordsInUse(0) {
initWords(nbits);
init();
Lock xx(globalMutex);
totalConstruct++;
}
BitSet::~BitSet() {
delete words;
Lock xx(globalMutex);
totalDestruct++;
}
void BitSet::initWords(uint32 nbits) {
@@ -315,8 +359,6 @@ namespace epics { namespace pvData {
return !(*this == set);
}
void BitSet::toString(StringBuilder buffer) { toString(buffer, 0); }
void BitSet::toString(StringBuilder buffer, int indentLevel) const
{
*buffer += '{';

View File

@@ -8,6 +8,8 @@
#define BITSET_H
#include <stdexcept>
#include <pvType.h>
#include "factory.h"
#include "showConstructDestruct.h"
//#include "byteBuffer.h"
//#include "serialize.h"
namespace epics { namespace pvData {
@@ -213,9 +215,7 @@ namespace epics { namespace pvData {
bool operator!=(const BitSet &set) const;
void toString(StringBuilder buffer);
void toString(StringBuilder buffer, int indentLevel) const;
void toString(StringBuilder buffer, int indentLevel = 0) const;
private:

View File

@@ -95,7 +95,7 @@ namespace epics { namespace pvData {
* @param cause exception that caused an error. Optional.
* @return status instance.
*/
virtual Status* createStatus(StatusType type, String message, BaseException* cause) = 0;
virtual Status* createStatus(StatusType type, String message, BaseException* cause = 0) = 0;
/**
* Deserialize status.

View File

@@ -11,8 +11,8 @@
#include <stddef.h>
#include <string.h>
#include <stdio.h>
#include "bitSet.h"
#include <bitSet.h>
#include <showConstructDestruct.h>
#include <epicsAssert.h>
@@ -143,6 +143,7 @@ int main(int argc,char *argv[])
{
testGetSetClearFlip();
testOperators();
//getShowConstructDestruct()->constuctDestructTotals(stdout);
return(0);
}