DataDirector API
DDD_AttributeList.h
Go to the documentation of this file.
1 #ifndef _DDD_AttributeList_h_
2 #define _DDD_AttributeList_h_
3 
4 /*! \file DDD_AttributeList.h
5  \brief The DDD_AttributeList class. Maintains a list of Data Director attributes.
6 
7  \par Copyright Information
8 
9  Copyright (c) 2012 The DiSTI Corporation.<br>
10  11301 Corporate Blvd; Suite 100<br>
11  Orlando, Florida 32817<br>
12  USA<br>
13  <br>
14  All rights reserved.<br>
15 
16  This Software contains proprietary trade secrets of DiSTI and may not be
17 reproduced, in whole or part, in any form, or by any means of electronic,
18 mechanical, or otherwise, without the written permission of DiSTI. Said
19 permission may be derived through the purchase of applicable DiSTI product
20 licenses which detail the distribution rights of this content and any
21 Derivative Works based on this or other copyrighted DiSTI Software.
22 
23  NO WARRANTY. THE SOFTWARE IS PROVIDED "AS-IS," WITHOUT WARRANTY OF ANY KIND,
24 AND ANY USE OF THIS SOFTWARE PRODUCT IS AT YOUR OWN RISK. TO THE MAXIMUM EXTENT
25 PERMITTED BY APPLICABLE LAW, DISTI AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES
26 AND CONDITIONS, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
27 IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY AND/OR FITNESS FOR A
28 PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT, WITH REGARD TO THE SOFTWARE.
29 
30  LIMITATION OF LIABILITY. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW,
31 IN NO EVENT SHALL DISTI OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
32 INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION,
33 DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS
34 INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
35 INABILITY TO USE THE SOFTWARE, EVEN IF DISTI HAS BEEN ADVISED OF THE POSSIBLITY
36 OF SUCH DAMAGES. DISTI'S ENTIRE LIABILITY AND YOUR EXCLUSIVE REMEDY SHALL NOT
37 EXCEED FIVE DOLLARS (US$5.00).
38 
39  The aforementioned terms and restrictions are governed by the laws of the
40 State of Florida and the United States of America.
41 
42 */
43 
44 #include "DDD_AttributeBase.h"
45 #include "dynamic_ptr_array.h"
46 #include <string>
47 
48 namespace disti
49 {
50 /** \brief The DDD_AttributeList class. Maintains a list of Data Director attributes.
51  */
52 class DDD_EXPORT DDD_AttributeList : public DynamicPtrArray<DDD_AttributeBase *>
53 {
54 public:
55  /** Constructor. */
57 
58  /** Destructor
59  * The DDD_AttributeList does NOT manage the storage of its attributes.
60  * Prior to calling this destructor, the calling code should free
61  * all of the attributes in this list.
62  */
64 
65  /** Get the value of the named attribute and return it as a parameter
66  * \param name The name of the attribute to get
67  * \param returnedValue Will contain the attribute value if found
68  * \return True if the attribute was found, false otherwise
69  */
70  bool GetValueString(const std::string &name,std::string &returnedValue);
71 
72  /** Add an attribute to the list and set its observer
73  * \param attr The attribute to add
74  * \param observer An observer (or NULL) that will observe the attribute
75  */
76  void Add(DDD_AttributeBase *attr,DDD_AttributeObserver *observer);
77 
78  /** Find the attribute with the given name within this attribute list
79  * \param name The name of the attribute to find
80  * \return A pointer to the attribute or NULL if not found
81  */
82  DDD_AttributeBase *Find(const std::string &name);
83 
84  /** Get the list index of the attribute with the given name within this attribute list
85  * \param name The name of the attribute to find
86  * \return The (0 based) list index of the attribute or -1 if not found
87  */
88  int IndexOf(const std::string &name);
89 
90  /** Find the attribute with the given name within this attribute list and remove it
91  * \param name The name of the attribute to find
92  */
93  void Remove(const std::string &name);
94 
95  /** Find the attribute with the given name within this attribute list and replace it
96  * \param name The name of the attribute to find
97  * \param newAttr The new attribute with which to replace it
98  */
99  void Replace(DDD_AttributeBase *oldAttr,DDD_AttributeBase *newAttr);
100 
101  /** Copies the attribute values from the supplied list into this list.
102  * Only attributes that exist in both lists will be updated/
103  * \param attrList A list of attributes
104  * \param notifyObservers If true, the attributes whose values are overwritten will notify their observers
105  */
106  void CopyValues(DDD_AttributeList &attrList, bool notifyObservers = false);
107 
108  /** Utility method that converts an attribute list into a single formatted string using the specified delimiter.
109  * NOTE: No trailing delimeter will be added to the string.
110  * \param delim1 The delimiter to separate name/value pairs.
111  * \param delim2 The delimiter to sepatate names from values.
112  * \return A string containing the attribute list, e.g. "name1=value1;name2=value2"
113  */
114  std::string ToString(const std::string& delim1 = ";", const std::string& delim2 = "=");
115 
116  /** Utility method that converts formatted string into an attribute list
117  * NOTE: No trailing delimeter will be expected in the string.
118  * NOTE!: This method DOES NOT CHECK FOR DUPLICATE NAMES. IT IS EXPECTED THAT THE CALLER FIRST EMPTY THIS LIST.
119  * \param str A string containing the attribute list, e.g. "name1=value1;name2=value2"
120  * \param delim1 The delimiter to separate name/value pairs.
121  * \param delim2 The delimiter to sepatate names from values.
122  */
123  void FromString(const std::string& str, const std::string& delim1 = ";", const std::string& delim2 = "=");
124 
125  /** Merges another attribute list into this one
126  * \param otherList Another attribute list
127  */
128  void Merge(const DDD_AttributeList &otherList);
129 
130  /** Deletes and deallocates all of the attributes in this list that are not marked with the "Persistent" flag
131  */
132  void DeleteDynamicAttributes();
133 
134  /** Reverts all of the attributes in this list that are marked with the "Revertable" flag
135  */
136  void RevertAttributes();
137 };
138 
139 } // namespace disti
140 
141 #endif
142 
A templated array of object pointers. The array dynamically resizes as needed.
Definition: dynamic_ptr_array.h:55
A virtual interface class for all DataDirector attribute types.
Definition: DDD_AttributeBase.h:87
The DDD_AttributeList class. Maintains a list of Data Director attributes.
Definition: DDD_AttributeList.h:52
A virtual interface class for observers of attributes. AttributeObserver-derived objects are able to ...
Definition: DDD_AttributeBase.h:66
The disti::DynamicPtrArray class. A templated array of objects pointers capable of dynamically growin...
Definition: AttributeChangedEmitter.h:46