//////////////////////////////////////////////////////////////////////////////// /*! @file Nodes.h A node of the RANet Knowledgebase. - Part of RANet - Research Assistant Net Library (based on ANSI C++). - Copyright(C) 1994-2010, Viktor E. Bursian, St.Petersburg, Russia. Viktor.Bursian@mail.ioffe.ru */////////////////////////////////////////////////////////////////////////////// #ifndef Nodes_H #define Nodes_H //#include "Undo.h" #include "Time.h" #include "NodePtr.h" #include #include #include namespace RA { //------------------------------------------------------------------------------ //ANNOUNCE_ABSTRACT_CLASS(sNode) //already predeclared in NodeLocation.h //template node_class * Replica (node_class * node); //ANNOUNCE_ABSTRACT_CLASS(sUndoNodeDirectAction) //ANNOUNCE_ABSTRACT_CLASS(sUndoNodeCorrectAction) //ANNOUNCE_ABSTRACT_CLASS(sRedoNetOperation) //-------------------------------------------------------------------- sNode --- /*! Abstract base class for any kind of nodes of the net. */ class RANet_EXPORT sNode : virtual public sStorable { ABSTRACT_STORABLE(sNode) public://types enum tIOStatus {cNewborn ,cSynchronized ,cEdited }; public://static static float RefreshingPeriod;/*s*/ static size_t CutOffLengthForLaconic; public: virtual ~sNode (); virtual sString Text (eTextFormat /*F=Plain*/ ,eTextDetalization D=Casual ); //!< visual representation for user virtual bool BodyHasToBeSaved () const; virtual bool BodyHasToBeRefreshed () const; virtual bool AttrsHaveToBeSaved () const; virtual bool AttrsHaveToBeRefreshed () const; protected: sNode (); pcsNodeLocation Location (); void MarkAsEdited (); virtual void CopyFrom (psNode); protected: //!@todo{Net} это всё вообще тут лишнее теперь? или для демонов? virtual sNodePtr GetAttr (sAttrName AName); virtual void SetAttr (sAttribute); virtual sNodePtr AscribeAttr (sAttribute); // virtual bool AscribeModel (sNodePtr ModelPtr); // virtual bool DelAttr (rsAttributeFinger); // //if successful, argument is shifted to the next // //attribute; othervise it remains unchanged virtual void DelAttr (sAttrName); virtual void DelAttr (sNodePtr value_ptr);//Nameless only virtual void DeleteAllAttributes (); protected://fields QMutex BodyMutex; private://types typedef std::list tListOfPtrs; private: // это, вообще говоря, запрещенные операции над узлами explicit sNode (rcsNode) :sAdam(),sStorable() {} void operator = (rcsNode) {} void operator & (); private: void RegisterPointer (psNodePtr); void UnregisterPointer (psNodePtr); void InformThePointers (); virtual bool Allocate (); virtual bool Allocate (psNode host ,rcsAttrName); private: //fields QMutex LocationMutex; psNodeLocation TheLocation; sNodePtr PrimaryHostForDelayedAllocation; sAttrName AttrNameForDelayedAllocation; QMutex PtrListMutex; tListOfPtrs Pointers; tIOStatus IOStatus; sTime StatusTimeStamp; #ifdef RANET_DEBUG public: static long int Counter; #endif friend class sNet; friend class sNodePtr; friend class sFolderNode; // virtual bool Strip (); //returns true if any of // //unstripable nodes down the net // //have to be saved (i.e. are Edited) // virtual void PurgeAttributes () // {}; // virtual void Preallocate (sNodePtr Host // ,sAttrName AN); // virtual void PreallocateAttributes () // {}; // virtual void AllocateMandatory (sNodeLocation::eType LType // ,rcsString LPath); // virtual void Save (); // virtual sNodePtr Copy () const =0; // virtual void AssignIntrinsicContent (sNodePtr); // virtual bool HasAttributes () // { return false; }; // virtual bool IsNullNode () const // { return false; }; // virtual bool IsLostNode () const // { return false; }; // virtual pcsTag PType4Nameless () const // { return NULL; }; // virtual pcsTag PType4Numeric () const // { return NULL; }; // virtual bool AscribePType4Nameless (pcsTag) // { return false; }; // virtual bool AscribePType4Numeric (pcsTag) // { return false; }; /* virtual psNode new_Similar (psNode N) const =0; //creates new object of this class //and fills it up with the contents of *N //?!т.е. копирует все, что за ним потянется?! */ // protected: // virtual psClusterNavigator // new_Navigator (); // private: // void DisconnectAllPtrs (); // virtual void IncHosts (); // public: //! @todo{elegancy} bad publicity because of sFolderNode::~sFolderNode // virtual void DecHosts (); // private: // void assign_intrinsic_content (sNodePtr NP) // { AssignIntrinsicContent(NP); }; // private: //fields // public: /*! @todo{elegancy} bad publicity because of BasicNet::BasicNet // and sBasicNet::Allocate(both) // and sBasicNet::PreallocateNode // */ // int NumberOfHosts; // private: //fields // sNodePtr Redirector; // public: /*! @todo{elegancy} bad publicity because of sRANetMonitor::EditAllocation // and BasicNet::BasicNet, sBasicNet::Allocate, AllocateMandatory // and sBasicNet::PreallocateNode // */ // bool LocationEdited; // private: //fields // public: //DEBUG // sString DebugInfo (); // friend class sAttributeFinger; // friend class sCluster; // friend class sUndoInsertAttr; //calls DecHosts() // friend class sUndoRemoveAttr; //calls IncHosts() //DEBUG?? friend class sBasicNet; }; /*! @todo{Net} Хреновая штука. Тип подставляется статически. */ template node_class * Replica (node_class * node) { node_class * R = new node_class; R->CopyFrom(node); return R; } ////------------------------------------------------------------------------------ //class RANet_EXPORT sUndoNodeDirectAction : public sUndoItem //{ // public: // sUndoNodeDirectAction (sNodePtr NP) // :NodePtr(NP) // {}; // protected: // fields // sNodePtr NodePtr; //}; ////------------------------------------------------------------------------------ //class RANet_EXPORT sUndoNodeCorrectAction : public sUndoRedoItem //{ // public: // sUndoNodeCorrectAction (sNodePtr NP) // :NodePtr(NP) // {}; // protected: // fields // sNodePtr NodePtr; //}; ////------------------------------------------------------------------------------ //class RANet_EXPORT sRedoNetOperation : public sRedoItem //{ // public: // sRedoNetOperation (sNodePtr NP) // :NodePtr(NP) // {}; // protected: // fields // sNodePtr NodePtr; //}; //------------------------------------------------------------------------------ } //namespace RA #endif