/usr/share/cruisecontrol-bin-2.6.1/projects/qpid-trunk/cpp/src/qpid/management/ManagementObject.h

00001 #ifndef _ManagementObject_
00002 #define _ManagementObject_
00003 
00004 /*
00005  *
00006  * Licensed to the Apache Software Foundation (ASF) under one
00007  * or more contributor license agreements.  See the NOTICE file
00008  * distributed with this work for additional information
00009  * regarding copyright ownership.  The ASF licenses this file
00010  * to you under the Apache License, Version 2.0 (the
00011  * "License"); you may not use this file except in compliance
00012  * with the License.  You may obtain a copy of the License at
00013  * 
00014  *   http://www.apache.org/licenses/LICENSE-2.0
00015  * 
00016  * Unless required by applicable law or agreed to in writing,
00017  * software distributed under the License is distributed on an
00018  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
00019  * KIND, either express or implied.  See the License for the
00020  * specific language governing permissions and limitations
00021  * under the License.
00022  *
00023  */
00024 
00025 #include "Manageable.h"
00026 #include "qpid/sys/Time.h"
00027 #include "qpid/sys/Mutex.h"
00028 #include <qpid/framing/Buffer.h>
00029 #include <boost/shared_ptr.hpp>
00030 #include <map>
00031 
00032 namespace qpid { 
00033 namespace management {
00034 
00035 class Manageable;
00036 
00037 class ManagementObject
00038 {
00039   protected:
00040     
00041     uint64_t    createTime;
00042     uint64_t    destroyTime;
00043     uint64_t    objectId;
00044     bool        configChanged;
00045     bool        instChanged;
00046     bool        deleted;
00047     Manageable* coreObject;
00048     sys::RWlock accessLock;
00049 
00050     static const uint8_t TYPE_U8        = 1;
00051     static const uint8_t TYPE_U16       = 2;
00052     static const uint8_t TYPE_U32       = 3;
00053     static const uint8_t TYPE_U64       = 4;
00054     static const uint8_t TYPE_SSTR      = 6;
00055     static const uint8_t TYPE_LSTR      = 7;
00056     static const uint8_t TYPE_ABSTIME   = 8;
00057     static const uint8_t TYPE_DELTATIME = 9;
00058     static const uint8_t TYPE_REF       = 10;
00059     static const uint8_t TYPE_BOOL      = 11;
00060     static const uint8_t TYPE_FLOAT     = 12;
00061     static const uint8_t TYPE_DOUBLE    = 13;
00062     static const uint8_t TYPE_UUID      = 14;
00063     static const uint8_t TYPE_FTABLE    = 15;
00064 
00065     static const uint8_t ACCESS_RC = 1;
00066     static const uint8_t ACCESS_RW = 2;
00067     static const uint8_t ACCESS_RO = 3;
00068 
00069     static const uint8_t DIR_I     = 1;
00070     static const uint8_t DIR_O     = 2;
00071     static const uint8_t DIR_IO    = 3;
00072 
00073     static const uint8_t FLAG_CONFIG = 0x01;
00074     static const uint8_t FLAG_INDEX  = 0x02;
00075     static const uint8_t FLAG_END    = 0x80;
00076 
00077     void writeTimestamps (qpid::framing::Buffer& buf);
00078 
00079   public:
00080     typedef boost::shared_ptr<ManagementObject> shared_ptr;
00081     typedef void (*writeSchemaCall_t) (qpid::framing::Buffer&);
00082 
00083     ManagementObject (Manageable* _core) :
00084         destroyTime(0), objectId (0), configChanged(true),
00085         instChanged(true), deleted(false), coreObject(_core)
00086     { createTime = uint64_t (qpid::sys::Duration (qpid::sys::now ())); }
00087     virtual ~ManagementObject () {}
00088 
00089     virtual writeSchemaCall_t getWriteSchemaCall (void) = 0;
00090     virtual void writeConfig          (qpid::framing::Buffer& buf) = 0;
00091     virtual void writeInstrumentation (qpid::framing::Buffer& buf,
00092                                        bool skipHeaders = false) = 0;
00093     virtual void doMethod             (std::string            methodName,
00094                                        qpid::framing::Buffer& inBuf,
00095                                        qpid::framing::Buffer& outBuf) = 0;
00096 
00097     virtual std::string  getClassName   (void) = 0;
00098     virtual std::string  getPackageName (void) = 0;
00099     virtual uint8_t*     getMd5Sum      (void) = 0;
00100 
00101     void         setObjectId      (uint64_t oid) { objectId = oid; }
00102     uint64_t     getObjectId      (void) { return objectId; }
00103     inline  bool getConfigChanged (void) { return configChanged; }
00104     virtual bool getInstChanged   (void) { return instChanged; }
00105     inline  void setAllChanged    (void)
00106     {
00107         configChanged = true;
00108         instChanged   = true;
00109     }
00110 
00111     inline void resourceDestroy  (void) {
00112         destroyTime = uint64_t (qpid::sys::Duration (qpid::sys::now ()));
00113         deleted     = true;
00114     }
00115     bool isDeleted (void) { return deleted; }
00116 
00117 };
00118 
00119 typedef std::map<uint64_t,ManagementObject::shared_ptr> ManagementObjectMap;
00120 
00121 }}
00122             
00123 
00124 
00125 #endif  

Generated on Thu Apr 10 11:08:18 2008 for Qpid by  doxygen 1.4.7