DataFactory.hpp

Go to the documentation of this file.
00001 /*
00002 Copyright 2007, 2008, 2009, 2010, 2011 Instituto de Sistemas e Robotica, Instituto Superior Tecnico
00003 
00004 This file is part of MeRMaID.
00005 
00006 MeRMaID is free software: you can redistribute it and/or modify
00007 it under the terms of the GNU Lesser General Public License as published by
00008 the Free Software Foundation, either version 3 of the License, or
00009 (at your option) any later version.
00010 
00011 MeRMaID is distributed in the hope that it will be useful,
00012 but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 GNU Lesser General Public License for more details.
00015 
00016 You should have received a copy of the GNU Lesser General Public License
00017 along with MeRMaID.  If not, see <http://www.gnu.org/licenses/>.
00018 */
00019 
00020 
00021 
00022 /**
00023  * @Filename DataFactory.hpp
00024  * @Description DataFactory class definition.
00025  * @Status Implementing
00026  * @Version $Id: DataFactory.hpp 1 2011-03-04 18:13:18Z jreis $
00027  * @Maintainer Marco Barbosa + Nelson Ramos
00028  */
00029 
00030 #ifndef __DATASTRUCTURE_DATAFACTORY_H_
00031 #define __DATASTRUCTURE_DATAFACTORY_H_
00032 
00033 #include <yarp/os/all.h>
00034 
00035 #include <string>
00036 #include "Boolean.hpp"
00037 #include "DataBox.hpp"
00038 #include "DataBoxArray.hpp"
00039 #include "DataStructureDescription.hpp"
00040 #include "DataValueVector.hpp"
00041 #include "Double.hpp"
00042 #include "DoubleArray.hpp"
00043 #include "Integer.hpp"
00044 #include "IntegerArray.hpp"
00045 #include "String.hpp"
00046 #include "StringArray.hpp"
00047 #include "XmlDocument.hpp"
00048 
00049 
00050 
00051 #include <map>
00052 
00053 namespace mermaid
00054 {
00055   namespace support
00056   {
00057     namespace data
00058     {
00059     
00060       using boost::shared_ptr;
00061       using mermaid::support::xml::XmlDocument;
00062       using mermaid::support::xml::XmlElement;
00063       using mermaid::support::xml::XmlElementVector;
00064       
00065       using yarp::os::Bottle;
00066       
00067       /**
00068       * @Class DataFactory DataFactory.hpp "DataFactory.hpp"
00069       * @Description Class representing a Data factory.
00070       * @Description This class is able to build Data from XML descriptions.
00071       * @Author Marco Barbosa + Nelson Ramos
00072       */
00073       
00074       class DataFactory
00075       {
00076       
00077         public:
00078           /**
00079           * @Description This method builds Integer from int value
00080           * @Argument value int value
00081           * @Returns Integer Class.
00082           */
00083           static shared_ptr<Integer> buildInteger (int value = 0);
00084           
00085           static shared_ptr<IntegerArray> buildDynamicIntegerArray();
00086           
00087           static shared_ptr<IntegerArray> buildStaticIntegerArray (int size);
00088           
00089           /**
00090           * @Description This method builds Double from float value
00091           * @Argument value double value
00092           * @Returns Double Class.
00093           */
00094           static shared_ptr<Double> buildDouble (double value = 0.0);
00095           
00096           static shared_ptr<DoubleArray> buildDynamicDoubleArray();
00097           
00098           static shared_ptr<DoubleArray> buildStaticDoubleArray (int size);
00099           
00100           /**
00101           * @Description This method builds String from string value
00102           * @Argument value string value
00103           * @Returns String Class.
00104           */
00105           static shared_ptr<String> buildString (std::string value = std::string (""));
00106           
00107           static shared_ptr<StringArray> buildDynamicStringArray();
00108           
00109           static shared_ptr<StringArray> buildStaticStringArray (int size);
00110           
00111           /**
00112            * @Description This method builds a DataBox from its type name
00113            * æArgument typeName Name of the DataBox type.
00114            */
00115           static shared_ptr<DataBox> buildDataBox (std::string typeName);
00116           
00117           static shared_ptr<DataBox> buildDataBoxFromStructureAndBottle (std::string structureTypeName, Bottle &bottle);
00118           static shared_ptr<DataBox> buildDataBoxFromStructureAndValueVector (std::string structureTypeName, shared_ptr<DataValueVector> vv);
00119           
00120           static shared_ptr<DataBoxArray> buildDynamicDataBoxArray (std::string typeName);
00121           
00122           static shared_ptr<DataBoxArray> buildStaticDataBoxArray (std::string typeName, int size);
00123           
00124           
00125           static shared_ptr<DataValueVector> buildDataValueVector (Bottle& b);
00126           static shared_ptr<DataValueVector> buildDataValueVector();
00127           
00128           
00129           static void loadDataDescription (shared_ptr<XmlDocument> document);
00130           
00131           static void writeDataBoxToBottle (shared_ptr<DataBox> box, Bottle &bottle);
00132           
00133           static shared_ptr<DataStructureDescription> getDataStructureDescription (std::string dataStructureName);
00134           
00135         private:
00136         
00137           static std::map<std::string, shared_ptr<DataStructureDescription> > dataStructureDescriptionMap;
00138           
00139       }; // DataFactory
00140     } // namespace data
00141   } // namespace support
00142 } // namespace mermaid
00143 
00144 #endif // __DATASTRUCTURE_DATAFACTORY_H_
Generated on Fri Mar 4 22:14:58 2011 for MeRMaID::support by  doxygen 1.6.3