[PATCH 2/2] [mama] Stats wrapper class


Ian Bell <IBell@...>
 

From 1cc93a8f2a0889650b91a1e6b57e871b7821dee7 Mon Sep 17 00:00:00 2001

Message-Id: <1cc93a8f2a0889650b91a1e6b57e871b7821dee7.1348677184.git.ibell@...>

In-Reply-To: <47121238854a5b7c5049bf869c7cb28c11404552.1348677184.git.ibell@...>

References: <47121238854a5b7c5049bf869c7cb28c11404552.1348677184.git.ibell@...>

From: Ian Bell <ibell@...>

Date: Wed, 26 Sep 2012 17:32:41 +0100

Subject: [PATCH 2/2] [mama] Stats wrapper class

 

Added c++ stats wrapper classes

 

Signed-off-by: Ian Bell <ibell@...>

---

mama/c_cpp/src/cpp/MamaStat.cpp              |  139 ++++++++++++++++++++++++++

mama/c_cpp/src/cpp/MamaStatImpl.h            |   73 ++++++++++++++

mama/c_cpp/src/cpp/MamaStatsCollector.cpp    |  126 +++++++++++++++++++++++

mama/c_cpp/src/cpp/MamaStatsCollectorImpl.h  |   72 +++++++++++++

mama/c_cpp/src/cpp/mama/MamaStat.h           |   70 +++++++++++++

mama/c_cpp/src/cpp/mama/MamaStatsCollector.h |   63 ++++++++++++

6 files changed, 543 insertions(+)

 

diff --git a/mama/c_cpp/src/cpp/MamaStat.cpp b/mama/c_cpp/src/cpp/MamaStat.cpp

new file mode 100644

index 0000000..f12fc51

--- /dev/null

+++ b/mama/c_cpp/src/cpp/MamaStat.cpp

@@ -0,0 +1,139 @@

+/* $Id$

+ *

+ * OpenMAMA: The open middleware agnostic messaging API

+ * Copyright (C) 2011 NYSE Technologies, Inc.

+ *

+ * This library is free software; you can redistribute it and/or

+ * modify it under the terms of the GNU Lesser General Public

+ * License as published by the Free Software Foundation; either

+ * version 2.1 of the License, or (at your option) any later version.

+ *

+ * This library is distributed in the hope that it will be useful,

+ * but WITHOUT ANY WARRANTY; without even the implied warranty of

+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU

+ * Lesser General Public License for more details.

+ *

+ * You should have received a copy of the GNU Lesser General Public

+ * License along with this library; if not, write to the Free Software

+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA

+ * 02110-1301 USA

+ */

+

+#include "MamaStatImpl.h"

+#include "mamacppinternal.h"

+

+namespace Wombat

+{

+

+    MamaStat::~MamaStat (void)

+    {

+        if (mSimpl)

+        {

+            delete mSimpl;

+            mSimpl = NULL;

+        }

+    }

+

+    MamaStat::MamaStat (MamaStatImpl* impl)

+        : mSimpl (impl)

+    {

+    }

+

+    MamaStat::MamaStat (void)

+        : mSimpl (new MamaStatImpl (this))

+    {

+    }

+

+    void MamaStat::create (MamaStatsCollector*  statsCollector,

+                           int                  lockable,

+                           const char*          name,

+                           mama_fid_t           fid)

+    {

+        mSimpl->create (statsCollector, lockable, name, fid);

+    }

+

+    void MamaStat::increment ()

+    {

+        mSimpl->increment ();

+    }

+

+    void MamaStat::decrement ()

+    {

+        mSimpl->decrement ();

+    }

+

+    void MamaStat::reset ()

+    {

+        mSimpl->reset ();

+    }

+

+    void MamaStat::setLog (int log)

+    {

+        mSimpl->setLog (log);

+    }

+

+    void MamaStat::setPublish (int publish)

+    {

+        mSimpl->setPublish (publish);

+    }

+

+    void MamaStat::destroy ()

+    {

+        mSimpl->destroy();

+    }

+

+    void MamaStatImpl::create (MamaStatsCollector* statsCollector,

+                               int                 lockable,

+                               const char*         name,

+                               mama_fid_t          fid)

+    {

+        if (mStat)

+        {

+            throw MamaStatus (MAMA_STATUS_INVALID_ARG);

+        }

+

+        mamaTry (mamaStat_create (&mStat,

+                                  statsCollector->getStatsCollector(),

+                                  lockable,

+                                  name,

+                                  fid));

+

+    }

+

+    void MamaStatImpl::increment ()

+    {

+        mamaTry (mamaStat_increment (mStat));

+    }

+

+    void MamaStatImpl::decrement ()

+    {

+        mamaTry (mamaStat_decrement (mStat));

+    }

+

+    void MamaStatImpl::reset ()

+    {

+        mamaTry (mamaStat_reset (mStat));

+    }

+

+    void MamaStatImpl::setLog (int log)

+    {

+        mamaTry (mamaStat_setLog (mStat, log));

+    }

+

+    void MamaStatImpl::setPublish (int publish)

+    {

+        mamaTry (mamaStat_setPublish (mStat, publish));

+    }

+

+    void MamaStatImpl::destroy ()

+    {

+        if (mStat)

+        {

+            mamaTry (mamaStat_destroy (mStat));

+            mStat = NULL;

+        }

+    }

+

+} //namespace Wombat

+

+

diff --git a/mama/c_cpp/src/cpp/MamaStatImpl.h b/mama/c_cpp/src/cpp/MamaStatImpl.h

new file mode 100644

index 0000000..6ea5810

--- /dev/null

+++ b/mama/c_cpp/src/cpp/MamaStatImpl.h

@@ -0,0 +1,73 @@

+/* $Id$

+ *

+ * OpenMAMA: The open middleware agnostic messaging API

+ * Copyright (C) 2011 NYSE Technologies, Inc.

+ *

+ * This library is free software; you can redistribute it and/or

+ * modify it under the terms of the GNU Lesser General Public

+ * License as published by the Free Software Foundation; either

+ * version 2.1 of the License, or (at your option) any later version.

+ *

+ * This library is distributed in the hope that it will be useful,

+ * but WITHOUT ANY WARRANTY; without even the implied warranty of

+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU

+ * Lesser General Public License for more details.

+ *

+ * You should have received a copy of the GNU Lesser General Public

+ * License along with this library; if not, write to the Free Software

+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA

+ * 02110-1301 USA

+ */

+

+#ifndef MAMA_STAT_IMPL_CPP_H__

+#define MAMA_STAT_IMPL_CPP_H__

+

+#include <mama/MamaStat.h>

+

+namespace Wombat

+{

+    class MamaStatImpl

+    {

+    public:

+        MamaStatImpl  (void)

+            : mParent (NULL)

+            , mStat   (0)

+        {

+        };

+

+        MamaStatImpl  (MamaStat* stat)

+            : mParent (stat)

+            , mStat   (0)

+        {

+        };

+

+        virtual ~MamaStatImpl (void)

+        {

+            destroy ();

+        }

+        virtual void create             (MamaStatsCollector*    statsCollector,

+                                         int                    lockable,

+                                         const char*            name,

+                                         mama_fid_t             fid);

+

+        virtual void increment          ();

+

+        virtual void decrement          ();

+

+        virtual void reset              ();

+

+        virtual void setLog             (int                    log);

+

+        virtual void setPublish         (int                    publish);

+

+        virtual void destroy            ();

+

+    protected:

+        MamaStat*    mParent;

+

+        mamaStat     mStat;

+    };

+

+} //namespace Wombat

+

+#endif //MAMA_STAT_IMPL_CPP_H__

diff --git a/mama/c_cpp/src/cpp/MamaStatsCollector.cpp b/mama/c_cpp/src/cpp/MamaStatsCollector.cpp

new file mode 100644

index 0000000..65ba303

--- /dev/null

+++ b/mama/c_cpp/src/cpp/MamaStatsCollector.cpp

@@ -0,0 +1,126 @@

+/* $Id$

+ *

+ * OpenMAMA: The open middleware agnostic messaging API

+ * Copyright (C) 2011 NYSE Technologies, Inc.

+ *

+ * This library is free software; you can redistribute it and/or

+ * modify it under the terms of the GNU Lesser General Public

+ * License as published by the Free Software Foundation; either

+ * version 2.1 of the License, or (at your option) any later version.

+ *

+ * This library is distributed in the hope that it will be useful,

+ * but WITHOUT ANY WARRANTY; without even the implied warranty of

+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU

+ * Lesser General Public License for more details.

+ *

+ * You should have received a copy of the GNU Lesser General Public

+ * License along with this library; if not, write to the Free Software

+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA

+ * 02110-1301 USA

+ */

+

+#include "MamaStatsCollectorImpl.h"

+#include "mamacppinternal.h"

+

+namespace Wombat

+{

+    MamaStatsCollector::~MamaStatsCollector (void)

+    {

+        if (mSimpl)

+        {

+            delete mSimpl;

+            mSimpl = NULL;

+        }

+    }

+

+    MamaStatsCollector::MamaStatsCollector (MamaStatsCollectorImpl* impl)

+        : mSimpl (impl)

+    {

+    }

+

+    MamaStatsCollector::MamaStatsCollector (void)

+        : mSimpl (new MamaStatsCollectorImpl (this))

+    {

+    }

+

+    void MamaStatsCollector::create (mamaStatsCollectorType type,

+                                     const char*            name,

+                                     const char*            middleware)

+    {

+        mSimpl->create (type, name, middleware);

+    }

+

+    void MamaStatsCollector::incrementStat (mama_fid_t   identifier)

+    {

+        mSimpl->incrementStat (identifier);

+    }

+

+    void MamaStatsCollector::setName (const char* name)

+    {

+        mSimpl->setName (name);

+    }

+

+    void MamaStatsCollector::setLog (int log)

+    {

+        mSimpl->setLog (log);

+    }

+

+    void MamaStatsCollector::setPublish (int publish)

+    {

+        mSimpl->setPublish (publish);

+    }

+

+    void MamaStatsCollector::destroy ()

+    {

+        mSimpl->destroy ();

+    }

+

+    mamaStatsCollector MamaStatsCollector::getStatsCollector ()

+    {

+        return (mSimpl->mStatsCollector);

+    }

+

+    void MamaStatsCollectorImpl::create (mamaStatsCollectorType   type,

+                                         const char*              name,

+                                         const char*              middleware)

+    {

+        mamaTry (mamaStatsCollector_create (&mStatsCollector,

+                                            type,

+                                            name,

+                                            middleware));

+    }

+

+    void MamaStatsCollectorImpl::incrementStat (mama_fid_t identifier)

+    {

+        mamaTry (mamaStatsCollector_incrementStat (mStatsCollector,

+                                                   identifier));

+    }

+

+    void MamaStatsCollectorImpl::setName (const char* name)

+    {

+        mamaTry (mamaStatsCollector_setName (mStatsCollector,

+                                             name));

+    }

+

+    void MamaStatsCollectorImpl::setLog (int log)

+    {

+        mamaTry (mamaStatsCollector_setLog (mStatsCollector,

+                                             log));

+    }

+

+    void MamaStatsCollectorImpl::setPublish (int publish)

+    {

+        mamaTry (mamaStatsCollector_setPublish (mStatsCollector,

+                                                publish));

+    }

+

+    void MamaStatsCollectorImpl::destroy (void)

+    {

+        if (mStatsCollector)

+        {

+            mamaTry (mamaStatsCollector_destroy (mStatsCollector));

+            mStatsCollector = NULL;

+        }

+    }

+

+} //namespace Wombat

diff --git a/mama/c_cpp/src/cpp/MamaStatsCollectorImpl.h b/mama/c_cpp/src/cpp/MamaStatsCollectorImpl.h

new file mode 100644

index 0000000..c35be1c

--- /dev/null

+++ b/mama/c_cpp/src/cpp/MamaStatsCollectorImpl.h

@@ -0,0 +1,72 @@

+/* $Id$

+ *

+ * OpenMAMA: The open middleware agnostic messaging API

+ * Copyright (C) 2011 NYSE Technologies, Inc.

+ *

+ * This library is free software; you can redistribute it and/or

+ * modify it under the terms of the GNU Lesser General Public

+ * License as published by the Free Software Foundation; either

+ * version 2.1 of the License, or (at your option) any later version.

+ *

+ * This library is distributed in the hope that it will be useful,

+ * but WITHOUT ANY WARRANTY; without even the implied warranty of

+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU

+ * Lesser General Public License for more details.

+ *

+ * You should have received a copy of the GNU Lesser General Public

+ * License along with this library; if not, write to the Free Software

+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA

+ * 02110-1301 USA

+ */

+

+#ifndef MAMA_STATS_COLLECTOR_IMPL_H__

+#define MAMA_STATS_COLLECTOR_IMPL_H__

+

+#include <mama/MamaStatsCollector.h>

+

+namespace Wombat

+{

+

+    class MamaStatsCollectorImpl

+    {

+    public:

+        MamaStatsCollectorImpl (void)

+            : mParent          (NULL)

+            , mStatsCollector  (0)

+        {

+        };

+

+        MamaStatsCollectorImpl (MamaStatsCollector* statsCollector)

+            : mParent          (statsCollector)

+            , mStatsCollector  (0)

+        {

+        };

+

+        virtual ~MamaStatsCollectorImpl (void)

+        {

+            destroy ();

+        }

+

+        virtual void create          (mamaStatsCollectorType type,

+                                      const char*            name,

+                                      const char*            middleware);

+

+        virtual void incrementStat   (mama_fid_t             identifier);

+

+        virtual void setName         (const char*            name);

+

+        virtual void setLog          (int                    log);

+

+        virtual void setPublish      (int                    publish);

+

+        virtual void destroy         ();

+

+        MamaStatsCollector*          mParent;

+

+

+        mamaStatsCollector         mStatsCollector;

+    };

+

+} //namespace Wombat

+

+#endif //MAMA_STATS_COLLECTOR_IMPL_H__

diff --git a/mama/c_cpp/src/cpp/mama/MamaStat.h b/mama/c_cpp/src/cpp/mama/MamaStat.h

new file mode 100644

index 0000000..1ea7647

--- /dev/null

+++ b/mama/c_cpp/src/cpp/mama/MamaStat.h

@@ -0,0 +1,70 @@

+/* $Id$

+ *

+ * OpenMAMA: The open middleware agnostic messaging API

+ * Copyright (C) 2011 NYSE Technologies, Inc.

+ *

+ * This library is free software; you can redistribute it and/or

+ * modify it under the terms of the GNU Lesser General Public

+ * License as published by the Free Software Foundation; either

+ * version 2.1 of the License, or (at your option) any later version.

+ *

+ * This library is distributed in the hope that it will be useful,

+ * but WITHOUT ANY WARRANTY; without even the implied warranty of

+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU

+ * Lesser General Public License for more details.

+ *

+ * You should have received a copy of the GNU Lesser General Public

+ * License along with this library; if not, write to the Free Software

+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA

+ * 02110-1301 USA

+ */

+

+#ifndef MAMA_STAT_CPP_H__

+#define MAMA_STAT_CPP_H__

+

+#include "mama/types.h"

+#include "mama/mamacpp.h"

+#include "mama/stat.h"

+#include "mama/statfields.h"

+#include "mama/statscollector.h"

+#include "mama/MamaStatsCollector.h"

+

+namespace Wombat

+{

+

+    class MamaStatImpl;

+

+    class MAMACPPExpDLL MamaStat

+    {

+    public:

+        MamaStat (void);

+

+        virtual ~MamaStat (void);

+

+        virtual void create             (MamaStatsCollector*    statsCollector,

+                                         int                    lockable,

+                                         const char*            name,

+                                         mama_fid_t             fid);

+

+        virtual void increment          ();

+

+        virtual void decrement          ();

+

+        virtual void reset              ();

+       

+        virtual void setLog             (int                    log);

+

+        virtual void setPublish         (int                    publish);

+

+        virtual void destroy            (void);

+

+    protected:

+        MamaStat      (MamaStatImpl*);

+       

+        MamaStatImpl* mSimpl;

+

+    };

+

+} //namespace Wombat

+

+#endif //MAMA_STAT_CPP_H__

diff --git a/mama/c_cpp/src/cpp/mama/MamaStatsCollector.h b/mama/c_cpp/src/cpp/mama/MamaStatsCollector.h

new file mode 100644

index 0000000..795cdf9

--- /dev/null

+++ b/mama/c_cpp/src/cpp/mama/MamaStatsCollector.h

@@ -0,0 +1,63 @@

+/* $Id$

+ *

+ * OpenMAMA: The open middleware agnostic messaging API

+ * Copyright (C) 2011 NYSE Technologies, Inc.

+ *

+ * This library is free software; you can redistribute it and/or

+ * modify it under the terms of the GNU Lesser General Public

+ * License as published by the Free Software Foundation; either

+ * version 2.1 of the License, or (at your option) any later version.

+ *

+ * This library is distributed in the hope that it will be useful,

+ * but WITHOUT ANY WARRANTY; without even the implied warranty of

+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU

+ * Lesser General Public License for more details.

+ *

+ * You should have received a copy of the GNU Lesser General Public

+ * License along with this library; if not, write to the Free Software

+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA

+ * 02110-1301 USA

+ */

+

+#ifndef MAMA_STATS_COLLECTOR_CPP_H__

+#define MAMA_STATS_COLLECTOR_CPP_H__

+

+#include "mama/types.h"

+#include "mama/statscollector.h"

+

+namespace Wombat

+{

+    class MamaStatsCollectorImpl;

+

+    class MAMACPPExpDLL MamaStatsCollector

+    {

+        public:

+            MamaStatsCollector (void);

+

+            virtual ~MamaStatsCollector (void);

+

+            virtual void create          (mamaStatsCollectorType type,

+                                          const char*            name,

+                                          const char*            middleware);

+

+            virtual void incrementStat   (mama_fid_t             identifier);

+

+            virtual void setName         (const char*            name);

+

+            virtual void setLog          (int                    log);

+

+            virtual void setPublish      (int                    publish);

+

+            virtual void destroy         (void);

+

+            virtual mamaStatsCollector  getStatsCollector       ();

+

+        protected:

+            MamaStatsCollector      (MamaStatsCollectorImpl*);

+

+            MamaStatsCollectorImpl* mSimpl;

+    };

+

+} // namespace Wombat

+

+#endif //MAMA_STATS_COLLECTOR_CPP_H__

--

1.7.9.5

 




Please consider the environment before printing this e-mail.

This e-mail may contain confidential and/or privileged information. If you are not the intended recipient or have received this e-mail in error, please advise the sender immediately by reply e-mail and delete this message and any attachments without retaining a copy.

Any unauthorised copying, disclosure or distribution of the material in this e-mail is strictly forbidden.

Join Openmama-dev@lists.openmama.org to automatically receive all group messages.