C:/Projets/hexamonkey/core/objecttype.h
Go to the documentation of this file.
00001 //This file is part of the HexaMonkey project, a multimedia analyser
00002 //Copyright (C) 2013  Sevan Drapeau-Martin, Nicolas Fleury
00003 
00004 //This program is free software; you can redistribute it and/or
00005 //modify it under the terms of the GNU General Public License
00006 //as published by the Free Software Foundation; either version 2
00007 //of the License, or (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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00017 
00018 #ifndef OBJECTTYPE_H
00019 #define OBJECTTYPE_H
00020 
00021 #include <vector>
00022 
00023 #include "core/variant.h"
00024 
00025 class ObjectTypeTemplate;
00026 
00038 class ObjectType
00039 {
00040 public:
00045     ObjectType();
00053     ObjectType(const ObjectTypeTemplate& typeTemplate);
00054 
00059     const ObjectTypeTemplate &typeTemplate() const;
00065     const Variant& parameterValue(size_t index) const;
00066 
00070     bool parameterSpecified(size_t index) const;
00071 
00077     void setParameter(size_t index, const Variant& value);
00078 
00082     const std::string& name() const;
00083     void setName(const std::string& name);
00084 
00088     template<typename... Args> void setParameters(Args... args){return _setParameters(0, args...);}
00089 
00094     const ObjectType &importParameters(const ObjectType& other);
00095 
00099     bool isNull() const;
00100 
00113     bool extendsDirectly(const ObjectType& other) const;
00114 
00119     const Variant &elementType() const;
00120     void setElementType(const ObjectType& type);
00121 
00127     const Variant &elementCount() const;
00128     void setElementCount(long long count);
00129 
00130 
00136     std::ostream& display(std::ostream& out) const;
00137 
00138     int numberOfParameters() const;
00139 
00140     int numberOfDisplayableParameters() const;
00141 
00142     friend void swap(ObjectType& a, ObjectType& b);
00143     ObjectType& operator=(ObjectType other);
00144 
00145 private:
00146     friend class AbstractTypeScope;
00147     const ObjectTypeTemplate* _typeTemplate;
00148     std::vector<Variant> _parametersValue;
00149     Variant _name;
00150     Variant _elementType;
00151     Variant _elementCount;
00152 
00153     void _setParameters(int first);
00154 
00155     template<typename... Args>
00156     void _setParameters(int first, const Variant& v, Args... args)
00157     {
00158         setParameter(first, v);
00159         _setParameters(first+1, args...);
00160     }
00161 };
00162 
00163 bool operator==(const ObjectType& a, const ObjectType& b);
00164 bool operator!=(const ObjectType& a, const ObjectType& b);
00165 bool operator< (const ObjectType& a, const ObjectType& b);
00166 
00167 std::ostream& operator<<(std::ostream& out, const ObjectType& type);
00168 
00169 #endif // OBJECTTYPE_H