You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by tr...@apache.org on 2010/02/04 18:25:19 UTC
svn commit: r906573 - in /qpid/trunk/qpid/cpp: include/qpid/management/
managementgen/qmfgen/ managementgen/qmfgen/templates/ src/qpid/management/
Author: tross
Date: Thu Feb 4 17:25:19 2010
New Revision: 906573
URL: http://svn.apache.org/viewvc?rev=906573&view=rev
Log:
Added encode/decode/encodedSize methods for management objects.
Made methods on generated code public.
Modified:
qpid/trunk/qpid/cpp/include/qpid/management/ManagementObject.h
qpid/trunk/qpid/cpp/managementgen/qmfgen/management-types.xml
qpid/trunk/qpid/cpp/managementgen/qmfgen/schema.py
qpid/trunk/qpid/cpp/managementgen/qmfgen/templates/Class.cpp
qpid/trunk/qpid/cpp/managementgen/qmfgen/templates/Class.h
qpid/trunk/qpid/cpp/src/qpid/management/ManagementObject.cpp
Modified: qpid/trunk/qpid/cpp/include/qpid/management/ManagementObject.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/include/qpid/management/ManagementObject.h?rev=906573&r1=906572&r2=906573&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/include/qpid/management/ManagementObject.h (original)
+++ qpid/trunk/qpid/cpp/include/qpid/management/ManagementObject.h Thu Feb 4 17:25:19 2010
@@ -62,7 +62,8 @@
QPID_COMMON_EXTERN ObjectId(const std::string&);
QPID_COMMON_EXTERN bool operator==(const ObjectId &other) const;
QPID_COMMON_EXTERN bool operator<(const ObjectId &other) const;
- QPID_COMMON_EXTERN void encode(framing::Buffer& buffer);
+ QPID_COMMON_EXTERN uint32_t encodedSize() const { return 16; };
+ QPID_COMMON_EXTERN void encode(framing::Buffer& buffer) const;
QPID_COMMON_EXTERN void decode(framing::Buffer& buffer);
QPID_COMMON_EXTERN void setV2Key(const std::string& key) { v2Key = key; }
QPID_COMMON_EXTERN const std::string& getV2Key() const { return v2Key; }
@@ -119,19 +120,20 @@
uint64_t destroyTime;
uint64_t updateTime;
ObjectId objectId;
- bool configChanged;
+ mutable bool configChanged;
bool instChanged;
bool deleted;
Manageable* coreObject;
- sys::Mutex accessLock;
+ mutable sys::Mutex accessLock;
uint32_t flags;
static int nextThreadIndex;
bool forcePublish;
QPID_COMMON_EXTERN int getThreadIndex();
- QPID_COMMON_EXTERN void writeTimestamps(qpid::framing::Buffer& buf);
+ QPID_COMMON_EXTERN void writeTimestamps(qpid::framing::Buffer& buf) const;
QPID_COMMON_EXTERN void readTimestamps(qpid::framing::Buffer& buf);
+ QPID_COMMON_EXTERN uint32_t writeTimestampsSize() const;
public:
QPID_COMMON_EXTERN static int maxThreads;
@@ -146,7 +148,8 @@
virtual writeSchemaCall_t getWriteSchemaCall() = 0;
virtual void readProperties(qpid::framing::Buffer& buf) = 0;
- virtual void writeProperties(qpid::framing::Buffer& buf) = 0;
+ virtual uint32_t writePropertiesSize() const = 0;
+ virtual void writeProperties(qpid::framing::Buffer& buf) const = 0;
virtual void writeStatistics(qpid::framing::Buffer& buf,
bool skipHeaders = false) = 0;
virtual void doMethod(std::string& methodName,
@@ -182,6 +185,10 @@
return other.getClassName() == getClassName() &&
other.getPackageName() == getPackageName();
}
+
+ QPID_COMMON_EXTERN void encode(qpid::framing::Buffer& buf) const { writeProperties(buf); }
+ QPID_COMMON_EXTERN void decode(qpid::framing::Buffer& buf) { readProperties(buf); }
+ QPID_COMMON_EXTERN uint32_t encodedSize() const { return writePropertiesSize(); }
};
typedef std::map<ObjectId, ManagementObject*> ManagementObjectMap;
Modified: qpid/trunk/qpid/cpp/managementgen/qmfgen/management-types.xml
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/managementgen/qmfgen/management-types.xml?rev=906573&r1=906572&r2=906573&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/managementgen/qmfgen/management-types.xml (original)
+++ qpid/trunk/qpid/cpp/managementgen/qmfgen/management-types.xml Thu Feb 4 17:25:19 2010
@@ -19,38 +19,38 @@
under the License.
-->
-<type name="objId" base="REF" cpp="::qpid::management::ObjectId" encode="#.encode(@)" decode="#.decode(@)" stream="#.getV2Key()" accessor="direct" init="::qpid::management::ObjectId()" byRef="y"/>
-<type name="uint8" base="U8" cpp="uint8_t" encode="@.putOctet(#)" decode="# = @.getOctet()" stream="#" accessor="direct" init="0"/>
-<type name="uint16" base="U16" cpp="uint16_t" encode="@.putShort(#)" decode="# = @.getShort()" stream="#" accessor="direct" init="0"/>
-<type name="uint32" base="U32" cpp="uint32_t" encode="@.putLong(#)" decode="# = @.getLong()" stream="#" accessor="direct" init="0"/>
-<type name="uint64" base="U64" cpp="uint64_t" encode="@.putLongLong(#)" decode="# = @.getLongLong()" stream="#" accessor="direct" init="0"/>
-<type name="int8" base="S8" cpp="int8_t" encode="@.putInt8(#)" decode="# = @.getInt8()" stream="#" accessor="direct" init="0"/>
-<type name="int16" base="S16" cpp="int16_t" encode="@.putInt16(#)" decode="# = @.getInt16()" stream="#" accessor="direct" init="0"/>
-<type name="int32" base="S32" cpp="int32_t" encode="@.putInt32(#)" decode="# = @.getInt32()" stream="#" accessor="direct" init="0"/>
-<type name="int64" base="S64" cpp="int64_t" encode="@.putInt64(#)" decode="# = @.getInt64()" stream="#" accessor="direct" init="0"/>
-<type name="bool" base="BOOL" cpp="uint8_t" encode="@.putOctet(#?1:0)" decode="# = @.getOctet()==1" stream="#" accessor="direct" init="0"/>
-<type name="sstr" base="SSTR" cpp="std::string" encode="@.putShortString(#)" decode="@.getShortString(#)" stream="#" accessor="direct" init='""' byRef="y"/>
-<type name="lstr" base="LSTR" cpp="std::string" encode="@.putMediumString(#)" decode="@.getMediumString(#)" stream="#" accessor="direct" init='""' byRef="y"/>
-<type name="absTime" base="ABSTIME" cpp="int64_t" encode="@.putLongLong(#)" decode="# = @.getLongLong()" stream="#" accessor="direct" init="0"/>
-<type name="deltaTime" base="DELTATIME" cpp="uint64_t" encode="@.putLongLong(#)" decode="# = @.getLongLong()" stream="#" accessor="direct" init="0"/>
-<type name="float" base="FLOAT" cpp="float" encode="@.putFloat(#)" decode="# = @.getFloat()" stream="#" accessor="direct" init="0."/>
-<type name="double" base="DOUBLE" cpp="double" encode="@.putDouble(#)" decode="# = @.getDouble()" stream="#" accessor="direct" init="0."/>
-<type name="uuid" base="UUID" cpp="::qpid::framing::Uuid" encode="#.encode(@)" decode="#.decode(@)" stream="#" accessor="direct" init="::qpid::framing::Uuid()" byRef="y"/>
-<type name="map" base="FTABLE" cpp="::qpid::framing::FieldTable" encode="#.encode(@)" decode="#.decode(@)" stream="#" accessor="direct" init="::qpid::framing::FieldTable()" byRef="y"/>
+<type name="objId" base="REF" cpp="::qpid::management::ObjectId" encode="#.encode(@)" decode="#.decode(@)" stream="#.getV2Key()" size="16" accessor="direct" init="::qpid::management::ObjectId()" byRef="y"/>
+<type name="uint8" base="U8" cpp="uint8_t" encode="@.putOctet(#)" decode="# = @.getOctet()" stream="#" size="1" accessor="direct" init="0"/>
+<type name="uint16" base="U16" cpp="uint16_t" encode="@.putShort(#)" decode="# = @.getShort()" stream="#" size="2" accessor="direct" init="0"/>
+<type name="uint32" base="U32" cpp="uint32_t" encode="@.putLong(#)" decode="# = @.getLong()" stream="#" size="4" accessor="direct" init="0"/>
+<type name="uint64" base="U64" cpp="uint64_t" encode="@.putLongLong(#)" decode="# = @.getLongLong()" stream="#" size="8" accessor="direct" init="0"/>
+<type name="int8" base="S8" cpp="int8_t" encode="@.putInt8(#)" decode="# = @.getInt8()" stream="#" size="1" accessor="direct" init="0"/>
+<type name="int16" base="S16" cpp="int16_t" encode="@.putInt16(#)" decode="# = @.getInt16()" stream="#" size="2" accessor="direct" init="0"/>
+<type name="int32" base="S32" cpp="int32_t" encode="@.putInt32(#)" decode="# = @.getInt32()" stream="#" size="4" accessor="direct" init="0"/>
+<type name="int64" base="S64" cpp="int64_t" encode="@.putInt64(#)" decode="# = @.getInt64()" stream="#" size="8" accessor="direct" init="0"/>
+<type name="bool" base="BOOL" cpp="uint8_t" encode="@.putOctet(#?1:0)" decode="# = @.getOctet()==1" stream="#" size="1" accessor="direct" init="0"/>
+<type name="sstr" base="SSTR" cpp="std::string" encode="@.putShortString(#)" decode="@.getShortString(#)" stream="#" size="(1 + #.length())" accessor="direct" init='""' byRef="y"/>
+<type name="lstr" base="LSTR" cpp="std::string" encode="@.putMediumString(#)" decode="@.getMediumString(#)" stream="#" size="(2 + #.length())" accessor="direct" init='""' byRef="y"/>
+<type name="absTime" base="ABSTIME" cpp="int64_t" encode="@.putLongLong(#)" decode="# = @.getLongLong()" stream="#" size="8" accessor="direct" init="0"/>
+<type name="deltaTime" base="DELTATIME" cpp="uint64_t" encode="@.putLongLong(#)" decode="# = @.getLongLong()" stream="#" size="8" accessor="direct" init="0"/>
+<type name="float" base="FLOAT" cpp="float" encode="@.putFloat(#)" decode="# = @.getFloat()" stream="#" size="4" accessor="direct" init="0."/>
+<type name="double" base="DOUBLE" cpp="double" encode="@.putDouble(#)" decode="# = @.getDouble()" stream="#" size="8" accessor="direct" init="0."/>
+<type name="uuid" base="UUID" cpp="::qpid::framing::Uuid" encode="#.encode(@)" decode="#.decode(@)" stream="#" size="16" accessor="direct" init="::qpid::framing::Uuid()" byRef="y"/>
+<type name="map" base="FTABLE" cpp="::qpid::framing::FieldTable" encode="#.encode(@)" decode="#.decode(@)" stream="#" size="#.encodedSize()" accessor="direct" init="::qpid::framing::FieldTable()" byRef="y"/>
-<type name="hilo8" base="U8" cpp="uint8_t" encode="@.putOctet(#)" decode="# = @.getOctet()" style="wm" stream="#" accessor="counter" init="0"/>
-<type name="hilo16" base="U16" cpp="uint16_t" encode="@.putShort(#)" decode="# = @.getShort()" style="wm" stream="#" accessor="counter" init="0"/>
-<type name="hilo32" base="U32" cpp="uint32_t" encode="@.putLong(#)" decode="# = @.getLong()" style="wm" stream="#" accessor="counter" init="0"/>
-<type name="hilo64" base="U64" cpp="uint64_t" encode="@.putLongLong(#)" decode="# = @.getLongLong()" style="wm" stream="#" accessor="counter" init="0"/>
+<type name="hilo8" base="U8" cpp="uint8_t" encode="@.putOctet(#)" decode="# = @.getOctet()" style="wm" stream="#" size="1" accessor="counter" init="0"/>
+<type name="hilo16" base="U16" cpp="uint16_t" encode="@.putShort(#)" decode="# = @.getShort()" style="wm" stream="#" size="2" accessor="counter" init="0"/>
+<type name="hilo32" base="U32" cpp="uint32_t" encode="@.putLong(#)" decode="# = @.getLong()" style="wm" stream="#" size="4" accessor="counter" init="0"/>
+<type name="hilo64" base="U64" cpp="uint64_t" encode="@.putLongLong(#)" decode="# = @.getLongLong()" style="wm" stream="#" size="8" accessor="counter" init="0"/>
-<type name="count8" base="U8" cpp="uint8_t" encode="@.putOctet(#)" decode="# = @.getOctet()" stream="#" accessor="counter" init="0" perThread="y"/>
-<type name="count16" base="U16" cpp="uint16_t" encode="@.putShort(#)" decode="# = @.getShort()" stream="#" accessor="counter" init="0" perThread="y"/>
-<type name="count32" base="U32" cpp="uint32_t" encode="@.putLong(#)" decode="# = @.getLong()" stream="#" accessor="counter" init="0" perThread="y"/>
-<type name="count64" base="U64" cpp="uint64_t" encode="@.putLongLong(#)" decode="# = @.getLongLong()" stream="#" accessor="counter" init="0" perThread="y"/>
+<type name="count8" base="U8" cpp="uint8_t" encode="@.putOctet(#)" decode="# = @.getOctet()" stream="#" size="1" accessor="counter" init="0" perThread="y"/>
+<type name="count16" base="U16" cpp="uint16_t" encode="@.putShort(#)" decode="# = @.getShort()" stream="#" size="2" accessor="counter" init="0" perThread="y"/>
+<type name="count32" base="U32" cpp="uint32_t" encode="@.putLong(#)" decode="# = @.getLong()" stream="#" size="4" accessor="counter" init="0" perThread="y"/>
+<type name="count64" base="U64" cpp="uint64_t" encode="@.putLongLong(#)" decode="# = @.getLongLong()" stream="#" size="8" accessor="counter" init="0" perThread="y"/>
<!-- Min/Max/Average statistics -->
-<type name="mma32" base="U32" cpp="uint32_t" encode="@.putLong(#)" decode="# = @.getLong()" style="mma" stream="#" accessor="direct" init="0" perThread="y"/>
-<type name="mma64" base="U64" cpp="uint64_t" encode="@.putLongLong(#)" decode="# = @.getLongLong()" style="mma" stream="#" accessor="direct" init="0" perThread="y"/>
-<type name="mmaTime" base="DELTATIME" cpp="uint64_t" encode="@.putLongLong(#)" decode="# = @.getLongLong()" style="mma" stream="#" accessor="direct" init="0" perThread="y"/>
+<type name="mma32" base="U32" cpp="uint32_t" encode="@.putLong(#)" decode="# = @.getLong()" style="mma" stream="#" size="4" accessor="direct" init="0" perThread="y"/>
+<type name="mma64" base="U64" cpp="uint64_t" encode="@.putLongLong(#)" decode="# = @.getLongLong()" style="mma" stream="#" size="8" accessor="direct" init="0" perThread="y"/>
+<type name="mmaTime" base="DELTATIME" cpp="uint64_t" encode="@.putLongLong(#)" decode="# = @.getLongLong()" style="mma" stream="#" size="8" accessor="direct" init="0" perThread="y"/>
</schema-types>
Modified: qpid/trunk/qpid/cpp/managementgen/qmfgen/schema.py
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/managementgen/qmfgen/schema.py?rev=906573&r1=906572&r2=906573&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/managementgen/qmfgen/schema.py (original)
+++ qpid/trunk/qpid/cpp/managementgen/qmfgen/schema.py Thu Feb 4 17:25:19 2010
@@ -59,6 +59,7 @@
self.decode = None
self.style = "normal"
self.stream = "#"
+ self.size = "1"
self.accessor = None
self.init = "0"
self.perThread = False
@@ -89,6 +90,9 @@
elif key == 'stream':
self.stream = val
+ elif key == 'size':
+ self.size = val
+
elif key == 'accessor':
self.accessor = val
@@ -388,6 +392,15 @@
stream.write (" ft.setString (DESC, \"" + self.desc + "\");\n")
stream.write (" buf.put (ft);\n\n")
+ def genSize (self, stream):
+ indent = " "
+ if self.isOptional:
+ stream.write(" if (presenceMask[presenceByte_%s] & presenceMask_%s) {\n" % (self.name, self.name))
+ indent = " "
+ stream.write("%ssize += %s; // %s\n" % (indent, self.type.type.size.replace("#", self.name), self.name))
+ if self.isOptional:
+ stream.write(" }\n")
+
def genRead (self, stream):
indent = " "
if self.isOptional:
@@ -1211,6 +1224,10 @@
if inst.type.type.perThread:
inst.genAssign (stream)
+ def genSizeProperties (self, stream, variables):
+ for prop in self.properties:
+ prop.genSize (stream)
+
def genReadProperties (self, stream, variables):
for prop in self.properties:
prop.genRead (stream)
Modified: qpid/trunk/qpid/cpp/managementgen/qmfgen/templates/Class.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/managementgen/qmfgen/templates/Class.cpp?rev=906573&r1=906572&r2=906573&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/managementgen/qmfgen/templates/Class.cpp (original)
+++ qpid/trunk/qpid/cpp/managementgen/qmfgen/templates/Class.cpp Thu Feb 4 17:25:19 2010
@@ -124,6 +124,16 @@
}
/*MGEN:ENDIF*/
+uint32_t /*MGEN:Class.NameCap*/::writePropertiesSize() const
+{
+ uint32_t size = writeTimestampsSize();
+/*MGEN:IF(Class.ExistOptionals)*/
+ size += /*MGEN:Class.PresenceMaskBytes*/;
+/*MGEN:ENDIF*/
+/*MGEN:Class.SizeProperties*/
+ return size;
+}
+
void /*MGEN:Class.NameCap*/::readProperties (Buffer& buf)
{
::qpid::sys::Mutex::ScopedLock mutex(accessLock);
@@ -135,7 +145,7 @@
/*MGEN:Class.ReadProperties*/
}
-void /*MGEN:Class.NameCap*/::writeProperties (Buffer& buf)
+void /*MGEN:Class.NameCap*/::writeProperties (Buffer& buf) const
{
::qpid::sys::Mutex::ScopedLock mutex(accessLock);
configChanged = false;
Modified: qpid/trunk/qpid/cpp/managementgen/qmfgen/templates/Class.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/managementgen/qmfgen/templates/Class.h?rev=906573&r1=906572&r2=906573&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/managementgen/qmfgen/templates/Class.h (original)
+++ qpid/trunk/qpid/cpp/managementgen/qmfgen/templates/Class.h Thu Feb 4 17:25:19 2010
@@ -73,12 +73,12 @@
void aggregatePerThreadStats(struct PerThreadStats*);
/*MGEN:ENDIF*/
- // Private Methods
+ public:
static void writeSchema(::qpid::framing::Buffer& buf);
+ uint32_t writePropertiesSize() const;
void readProperties(::qpid::framing::Buffer& buf);
- void writeProperties(::qpid::framing::Buffer& buf);
- void writeStatistics(::qpid::framing::Buffer& buf,
- bool skipHeaders = false);
+ void writeProperties(::qpid::framing::Buffer& buf) const;
+ void writeStatistics(::qpid::framing::Buffer& buf, bool skipHeaders = false);
void doMethod(std::string& methodName,
::qpid::framing::Buffer& inBuf,
::qpid::framing::Buffer& outBuf);
@@ -89,7 +89,6 @@
bool getInstChanged() { return false; }
bool hasInst() { return false; }
/*MGEN:ENDIF*/
- public:
/*MGEN:Class.NameCap*/(::qpid::management::ManagementAgent* agent,
::qpid::management::Manageable* coreObject/*MGEN:Class.ParentArg*//*MGEN:Class.ConstructorArgs*/);
Modified: qpid/trunk/qpid/cpp/src/qpid/management/ManagementObject.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/management/ManagementObject.cpp?rev=906573&r1=906572&r2=906573&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/management/ManagementObject.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/management/ManagementObject.cpp Thu Feb 4 17:25:19 2010
@@ -121,7 +121,7 @@
return (first < otherFirst) || ((first == otherFirst) && (second < other.second));
}
-void ObjectId::encode(framing::Buffer& buffer)
+void ObjectId::encode(framing::Buffer& buffer) const
{
if (agent == 0)
buffer.putLongLong(first);
@@ -158,7 +158,7 @@
int ManagementObject::maxThreads = 1;
int ManagementObject::nextThreadIndex = 0;
-void ManagementObject::writeTimestamps (framing::Buffer& buf)
+void ManagementObject::writeTimestamps (framing::Buffer& buf) const
{
buf.putShortString (getPackageName ());
buf.putShortString (getClassName ());
@@ -184,6 +184,17 @@
unusedObjectId.decode(buf);
}
+uint32_t ManagementObject::writeTimestampsSize() const
+{
+ return 1 + getPackageName().length() + // str8
+ 1 + getClassName().length() + // str8
+ 16 + // bin128
+ 8 + // uint64
+ 8 + // uint64
+ 8 + // uint64
+ objectId.encodedSize(); // objectId
+}
+
void ManagementObject::setReference(ObjectId) {}
int ManagementObject::getThreadIndex() {
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org