/home/tetron/hack/vos/libs/vos/vos/parentchildrel.hh
Go to the documentation of this file.00001 /* 00002 00003 This file is part of the Virtual Object System of 00004 the Interreality project (http://interreality.org). 00005 00006 Copyright (C) 2001-2003 Peter Amstutz 00007 00008 This library is free software; you can redistribute it and/or 00009 modify it under the terms of the GNU Lesser General Public 00010 License as published by the Free Software Foundation; either 00011 version 2 of the License, or (at your option) any later version. 00012 00013 This library is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 Lesser General Public License for more details. 00017 00018 You should have received a copy of the GNU Lesser General Public 00019 License along with this library; if not, write to the Free Software 00020 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00021 00022 Peter Amstutz <http://www.interreality.org> 00023 */ 00024 00025 #ifndef _PARENTCHILDREL_HH_ 00026 #define _PARENTCHILDREL_HH_ 00027 00028 /** @file 00029 Defines Vobjec 00030 */ 00031 00032 #include <vos/vos/vosdefs.hh> 00033 #include <vos/vutil/refcount.hh> 00034 #include <vos/vutil/log.hh> 00035 00036 #include <deque> 00037 #include <stdexcept> 00038 00039 00040 namespace VOS 00041 { 00042 class Vobject; 00043 00044 /** @class ParentChildRelation parentchildrel.hh vos/vos/parentchildrel.hh 00045 @ingroup libvos 00046 00047 This class represents the link from a parent to a child, 00048 describing the entry in the parent's child list. 00049 */ 00050 class VOS_API ParentChildRelation : public VUtil::RefCounted 00051 { 00052 private: 00053 int position; 00054 std::string contextual_name; 00055 Vobject* child; 00056 Vobject* parent; 00057 00058 void decPosition() { position--; } 00059 void incPosition() { position++; } 00060 00061 public: 00062 /** Constructor 00063 @param parent the parent vobject 00064 @param child the linked-to child vobject 00065 @param pos the position in the child list 00066 @param cn the contextual name in the child list 00067 */ 00068 ParentChildRelation(Vobject* parent, Vobject* child, 00069 int pos, const std::string& cn); 00070 00071 /** Destructor */ 00072 virtual ~ParentChildRelation(); 00073 00074 /** @return position of the child in the parent's child list */ 00075 int getPosition(); 00076 00077 /** @return contextual name describing the link in the parent's child list */ 00078 const std::string& getContextualName(); 00079 00080 /** @return child end of the link */ 00081 VUtil::vRef<Vobject> getChild(); 00082 00083 /** @return parent end of the link */ 00084 VUtil::vRef<Vobject> getParent(); 00085 00086 friend class VobjectState; 00087 }; 00088 } 00089 00090 #endif