src/include/common/spdm/ManagementNode.h

00001 /*
00002  * Copyright (C) 2003-2007 Funambol
00003  *
00004  * This program is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License as published by
00006  * the Free Software Foundation; either version 2 of the License, or
00007  * (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017  */
00018 
00019 #ifndef INCL_MANAGEMENT_NODE
00020 #define INCL_MANAGEMENT_NODE
00021 
00023 #include "base/fscapi.h"
00024 #include "base/util/ArrayElement.h"
00025 #include "base/util/ArrayList.h"
00026 #include "spdm/constants.h"
00027 
00028 /*
00029  * This class represents a management node, so that a configuration
00030  * object under the device manager control.
00031  * This is an abstract class that defines the interface of platform
00032  * specific concrete implementations.
00033  *
00034  * See the design documents for more information.
00035  */
00036 class ManagementNode : public ArrayElement {
00037 
00038     protected:
00039         char *name;
00040         char *context;
00041         //
00042         // Children are dinamically allocated inside this class and given to
00043         // the list. The list will delete all created objects at descruction
00044         // time.
00045         //
00046         ArrayList children;
00047 
00048         /*
00049          * Set node attributes (name, context, fullcontext) from a Full Name string
00050          *
00051          */
00052         int setFullName(const char *name);
00053 
00054     public:
00055 
00056         // -------------------------------------------- Constructors & Destructors
00057 
00058         /*
00059          * Constructor.
00060          *
00061          * @param parent - a ManagementNode is usually under the context of a
00062          *                 parent node.
00063          * @param name - the node name
00064          *
00065          */
00066         ManagementNode(const char*  parent, const char*  name) EXTRA_SECTION_02;
00067         /*
00068          * Constructor.
00069          *
00070          * @param fullcontext - the complete path to the node. The last
00071          *                      component is used as name, the rest as context
00072          *
00073          */
00074         ManagementNode(const char*  fullcontext) EXTRA_SECTION_02;
00075 
00076         /* Base class destructor */
00077         virtual ~ManagementNode() EXTRA_SECTION_02;
00078 
00079 
00080         // ----------------------------------------------------- Virtual methods
00081 
00082         /*
00083          * Returns this node's child, at index specified
00084          *
00085          * @param index - the index of the child to get
00086          *
00087          * @return the node or NULL on failure.
00088          *         Caller MUST NOT delete the object
00089          */
00090         virtual ManagementNode * getChild(int index);
00091 
00095         virtual ManagementNode * getChild(const char* name);
00096 
00102                 virtual void addChild(ManagementNode &child);
00103 
00104         /*
00105          * Returns how many children belong to this node (how many have been added)
00106          */
00107                 virtual int getChildrenCount();
00108 
00109         /*
00110          * Returns the full node name in a newly allocated buffer,
00111          * caller must free it with delete [].
00112          *
00113          */
00114         virtual char* createFullName();
00115 
00119         virtual const char *getName();
00120 
00121         // ---------------------------------------------------- Abstract methods
00122 
00123         /*
00124          * Find how many children are defined for this node in the underlying
00125                  * config system.
00126          */
00127         virtual int getChildrenMaxCount() = 0;
00128 
00129         /* Returns the names of the children nodes, in a new-allocated
00130          * string array
00131          *
00132          * @return NULL on failure
00133          */
00134         virtual char **getChildrenNames() = 0;
00135 
00136         /*
00137          * Returns the value of the given property
00138          *
00139          * @param property - the property name
00140          *
00141          * @return - the property value. MUST be deleted by the caller with delete [];
00142          *           never NULL, for non-existant properties an empty string is returned
00143          */
00144         virtual char* readPropertyValue(const char*  property) = 0;
00145 
00146         /*
00147          * Sets a property value.
00148          *
00149          * @param property - the property name
00150          * @param value - the property value (zero terminated string)
00151          */
00152         virtual void setPropertyValue(const char*  property, const char*  value) = 0;
00153 
00154         /*
00155          * Creates a new ManagementNode with the exact content of this object.
00156          * The new instance MUST be created with the C++ new opertator.
00157          */
00158         virtual ArrayElement* clone() = 0;
00159 
00160 };
00161 
00163 #endif
00164 

Generated on Fri Apr 27 12:29:18 2007 for Funambol C++ Client Library by  doxygen 1.5.2